diff options
author | Marius <mariausol@gmail.com> | 2012-06-25 15:20:28 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2012-06-25 15:20:28 +0300 |
commit | e845f69d0b63d95ffc66a0085756c84f71a495a0 (patch) | |
tree | c3150fa85e89c509abbc7ce32464e1da71f1dc37 /context/data/scite/lexers/scite-context-lexer-txt.lua | |
parent | 912801570b5d1555011b220ecb938143cc32b707 (diff) | |
download | context-e845f69d0b63d95ffc66a0085756c84f71a495a0.tar.gz |
beta 2012.06.25 14:10
Diffstat (limited to 'context/data/scite/lexers/scite-context-lexer-txt.lua')
-rw-r--r-- | context/data/scite/lexers/scite-context-lexer-txt.lua | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/context/data/scite/lexers/scite-context-lexer-txt.lua b/context/data/scite/lexers/scite-context-lexer-txt.lua index 012167aeb..4c4742d54 100644 --- a/context/data/scite/lexers/scite-context-lexer-txt.lua +++ b/context/data/scite/lexers/scite-context-lexer-txt.lua @@ -13,19 +13,20 @@ local token = lexer.token local P, S, Cmt, Cp, Ct = lpeg.P, lpeg.S, lpeg.Cmt, lpeg.Cp, lpeg.Ct local find, match = string.find, string.match -local textlexer = { _NAME = "txt", _FILENAME = "scite-context-lexer-txt" } -local whitespace = lexer.WHITESPACE -local context = lexer.context +local textlexer = { _NAME = "txt", _FILENAME = "scite-context-lexer-txt" } +local whitespace = lexer.WHITESPACE +local context = lexer.context -local space = lexer.space -local any = lexer.any +local space = lexer.space +local any = lexer.any -local wordtoken = context.patterns.wordtoken -local wordpattern = context.patterns.wordpattern -local checkedword = context.checkedword -local styleofword = context.styleofword -local setwordlist = context.setwordlist -local validwords = false +local wordtoken = context.patterns.wordtoken +local wordpattern = context.patterns.wordpattern +local checkedword = context.checkedword +local styleofword = context.styleofword +local setwordlist = context.setwordlist +local validwords = false +local validminimum = 3 -- local styleset = context.newstyleset { -- "default", @@ -37,12 +38,12 @@ local validwords = false local p_preamble = Cmt(#(S("#!-%") * P(" ")), function(input,i,_) -- todo: utf bomb if i == 1 then -- < 10 then - validwords = false + validwords, validminimum = false, 3 local s, e, line = find(input,'^[#!%-%%](.+)[\n\r]',i) if line then local language = match(line,"language=([a-z]+)") if language then - validwords = setwordlist(language) + validwords, validminimum = setwordlist(language) end end end @@ -52,17 +53,8 @@ end) local t_preamble = token("preamble", p_preamble) --- local t_word = --- Cmt(wordpattern, function(_,i,s) --- if validwords then --- return checkedword(validwords,s,i) --- else --- return true, { "text", i } --- end --- end) - local t_word = - Ct( wordpattern / function(s) return styleofword(validwords,s) end * Cp() ) -- the function can be inlined + Ct( wordpattern / function(s) return styleofword(validwords,validminimum,s) end * Cp() ) -- the function can be inlined local t_text = token("default", wordtoken^1) |