diff --git a/pret-pas.lua b/pret-pas.lua index b49f8c6..a866f4a 100644 --- a/pret-pas.lua +++ b/pret-pas.lua @@ -71,10 +71,10 @@ local function flush_pas_word(word) end end -local incomment, inlongstring, incompdirec, inasm = false, false, false, false +local inlongcomment, incompdirec, inasm = false, false, false function visualizer.reset() - incomment, inlongstring, incompdirec, inasm = false, false, false, false + inlongcomment, incompdirec, inasm = false, false, false end --[[local function written(state, c, i) @@ -94,9 +94,23 @@ end end]] function visualizer.flush_line(str, nested) - local state, instr, inesc, word = 0, false, false, nil + local state, word = 0, nil buffers.currentcolors = colors +--[[ + print("SEARCHING FOR IDENTIFIERS IN: " .. str) + local remain = str + local identifier + repeat + identifier = nil + identifier, remain = string.match(remain, "^[^%a_]*([%a_]+[%a%d_]*)(.*)$") + if identifier then + print("IDENTIFIER: " .. identifier) + --print("REMAIN: " .. remain) + end + until not identifier +]] + --state = buffers.changestate(1, state) for c in string.utfcharacters(str) do if string.find(c, "^[%a_]$") then @@ -106,7 +120,6 @@ function visualizer.flush_line(str, nested) else word = c end - --state = buffers.changestate(2, state) elseif string.find(c, "^[%d]$") then if word and (#word > 1) then -- number, that belongs to identifier @@ -116,7 +129,6 @@ function visualizer.flush_line(str, nested) state = buffers.changestate(3, state) tex.write(c) end - --state = buffers.changestate(3, state) else flush_pas_word(word) word = nil @@ -135,7 +147,6 @@ function visualizer.flush_line(str, nested) tex.write(c) end end - --tex.write(c) state = buffers.finishstate(state) end flush_pas_word(word) diff --git a/test-file/pret-pas_test.tex b/test-file/pret-pas_test.tex index aa74858..9050c48 100644 --- a/test-file/pret-pas_test.tex +++ b/test-file/pret-pas_test.tex @@ -6,8 +6,8 @@ \starttext \startPAS -blub { Comment } blub -blub {$R- compiler directive} blub +normal { Comment } normal +normal {$R- compiler directive} normal procedure TForm1.Button1.Click(Sender: TObject); var // Delphi Comment Number, I, X: Integer;