diff --git a/comp/src/gb.highlight/.src/CCommandLimit.class b/comp/src/gb.highlight/.src/CCommandLimit.class new file mode 100644 index 000000000..b1705d70f --- /dev/null +++ b/comp/src/gb.highlight/.src/CCommandLimit.class @@ -0,0 +1,15 @@ +' Gambas class file + +Inherits CCommand + +Public Sub SetArgs(aArgs As String[]) + + If aArgs.Count Then Error.Raise("Syntax error") + +End + +Public Sub Compile((hState) As CState) + + hState.Limit = True + +End diff --git a/comp/src/gb.highlight/.src/CState.class b/comp/src/gb.highlight/.src/CState.class index 384b1d2f8..aca8d0a49 100644 --- a/comp/src/gb.highlight/.src/CState.class +++ b/comp/src/gb.highlight/.src/CState.class @@ -22,6 +22,7 @@ Public Indent As Integer Public Parent As CState Public Commands As New CCommand[] Public Children As New CState[] +Public Limit As Boolean Private $iCurrentCommand As Integer Private $iCurrentChild As Integer @@ -102,18 +103,20 @@ Public Sub AddCommand(sText As String) Dim I As Integer iPos = InStr(sText, " ") - If iPos = 0 Then Return - - sCommand = Left(sText, iPos - 1) + If iPos = 0 Then + sCommand = sText + aArg = New String[] + Else + sCommand = Left(sText, iPos - 1) + aArg = Split(Mid$(sText, iPos + 1), " ", "", True) + For I = 0 To aArg.Max + aArg[I] = CState.Subst(aArg[I]) + Next + Endif Try hCommand = Object.New("CCommand" & UCase(Left(sCommand)) & Mid$(sCommand, 2)) If Error Then Error.Raise("Unknown command: " & sCommand) - aArg = Split(Mid$(sText, iPos + 1), " ", "", True) - For I = 0 To aArg.Max - aArg[I] = CState.Subst(aArg[I]) - Next - hCommand.SetArgs(aArg) hCommand.Init() Commands.Add(hCommand) @@ -206,6 +209,9 @@ Public Sub Forward(Optional sLen As String, iColorIndex As Integer = ColorIndex) Else Print("Forward(" & CStr(iColorIndex) & ")") Endif + If Limit Then + Print("Me.Limit = True") + Endif End diff --git a/comp/src/gb.highlight/.src/Main.module b/comp/src/gb.highlight/.src/Main.module index 642973f78..467f497ab 100644 --- a/comp/src/gb.highlight/.src/Main.module +++ b/comp/src/gb.highlight/.src/Main.module @@ -17,8 +17,8 @@ Public Sub Main() 'File.Save("~/test.html", TextHighlighter["diff"].ToHTML(File.Load(Application.Path &/ ".hidden/test/diff.txt"))) 'TextHighlighter.Register("~/gambas/git/master/app/src/gambas3/highlight/conflict.highlight") 'File.Save("~/test.html", TextHighlighter["conflict"].ToHTML(File.Load("test/conflict.txt"))) - 'File.Save("~/test.html", TextHighlighter["javascript"].ToHTML(File.Load("~/asap/omogen/master/src/kernel/guygle.cgi/javascript/selectr.js"))) + File.Save("~/test.html", TextHighlighter["javascript"].ToHTML(File.Load("~/asap/omogen/master/src/kernel/guygle.cgi/javascript/selectr.js"))) 'File.Save("~/test.html", TextHighlighter["webpage"].ToHTML(File.Load(Application.Path &/ ".hidden/test/Webpage1.webpage"))) - File.Save("~/test.html", TextHighlighter["sh"].ToHTML(File.Load("~/gambas/git/master/comp/src/gb.desktop/xdg-utils/xdg-open"))) + 'File.Save("~/test.html", TextHighlighter["sh"].ToHTML(File.Load("~/gambas/git/master/acinclude.m4"))) End diff --git a/comp/src/gb.highlight/.src/TextHighlighter.class b/comp/src/gb.highlight/.src/TextHighlighter.class index 213d8928c..9f6115752 100644 --- a/comp/src/gb.highlight/.src/TextHighlighter.class +++ b/comp/src/gb.highlight/.src/TextHighlighter.class @@ -271,7 +271,11 @@ Static Private Sub CreateCustomHighlighter(sHighlight As String, sPath As String sProject = Replace(sProject, "$(startup)", "_TextHighlighter_" & sHighlight) File.Save(sDir &/ ".project", sProject) - Shell "cd " & Shell$(sDir) & " && gbc3 -agt 2>&1 && gba3 2>&1" To sOutput + Shell "cd " & Shell$(sDir) & " && gbc3 -agt 2>&1" To sOutput + sOutput = Trim(sOutput) + If Process.LastValue And If sOutput Then Error.Raise(sOutput) + + Shell "cd " & Shell$(sDir) & " && gba3 2>&1" To sOutput sOutput = Trim(sOutput) If Process.LastValue And If sOutput Then Error.Raise(sOutput) @@ -439,6 +443,8 @@ Public Sub ToHTML(Text As String, Optional Theme As TextHighlighterTheme) As Str HighlightLine(aText[Y]) sLineHtml = "" + + If Y And If Me.Limit Then sLineHtml &= "
" While Not HighlightToken() diff --git a/comp/src/gb.highlight/custom/CustomHighlighter.class b/comp/src/gb.highlight/custom/CustomHighlighter.class index 266236196..228594534 100644 --- a/comp/src/gb.highlight/custom/CustomHighlighter.class +++ b/comp/src/gb.highlight/custom/CustomHighlighter.class @@ -24,6 +24,8 @@ Private $aHighlight As Byte[] Private Sub Init(sText As String) + Me.Limit = False + $sText = sText $iLen = String.Len($sText) $iPos = 1 diff --git a/comp/src/gb.highlight/highlight/diff.highlight b/comp/src/gb.highlight/highlight/diff.highlight index d93faef84..10ee90f6e 100644 --- a/comp/src/gb.highlight/highlight/diff.highlight +++ b/comp/src/gb.highlight/highlight/diff.highlight @@ -1,4 +1,5 @@ diff{Datatype}: + limit from /^diff/ index{Keyword}: from /^index/ diff --git a/comp/src/gb.highlight/highlight/javascript.highlight b/comp/src/gb.highlight/highlight/javascript.highlight index fbfdefadd..a0ce6f0d5 100644 --- a/comp/src/gb.highlight/highlight/javascript.highlight +++ b/comp/src/gb.highlight/highlight/javascript.highlight @@ -32,6 +32,7 @@ number: keyword: keyword @javascript.keyword function: + limit keyword function constant: keyword false null this true undefined NaN Infinity