diff options
author | mitchell <unknown> | 2018-11-25 01:53:03 -0500 |
---|---|---|
committer | mitchell <unknown> | 2018-11-25 01:53:03 -0500 |
commit | c6566b5ea25fe00b217838343b3df8c8919acab2 (patch) | |
tree | 30fbf066edc43eee821369b9173c0c7735eb3832 | |
parent | 309f7a6a8a659e84d6acdb6141f293f89c95d120 (diff) | |
download | scintilla-mirror-c6566b5ea25fe00b217838343b3df8c8919acab2.tar.gz |
lexlua: Updated ConTeXt lexer.
Thanks to Lars Otter.
-rw-r--r-- | lexlua/context.lua | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/lexlua/context.lua b/lexlua/context.lua index a6e6eb4ba..52be278fa 100644 --- a/lexlua/context.lua +++ b/lexlua/context.lua @@ -1,4 +1,4 @@ --- Copyright 2006-2018 Robert Gieseke. See License.txt. +-- Copyright 2006-2018 Robert Gieseke, Lars Otter. See License.txt. -- ConTeXt LPeg lexer. local lexer = require('lexer') @@ -7,38 +7,42 @@ local P, R, S = lpeg.P, lpeg.R, lpeg.S local lex = lexer.new('context') +-- TeX and ConTeXt mkiv environment definitions. +local beginend = (P('begin') + 'end') +local startstop = (P('start') + 'stop') + -- Whitespace. lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) -- Comments. lex:add_rule('comment', token(lexer.COMMENT, '%' * lexer.nonnewline^0)) --- ConTeXt environments. -local environment = token('environment', '\\' * (P('start') + 'stop') * - lexer.word) -lex:add_rule('environment', environment) -lex:add_style('environment', lexer.STYLE_KEYWORD) - -- Sections. -lex:add_rule('section', token('section', '\\' * word_match[[ +local wm_section = word_match[[ chapter part section subject subsection subsubject subsubsection subsubsubject - title -]])) + subsubsubsection subsubsubsubject title +]] +local section = token('section', '\\' * (wm_section + (startstop * wm_section))) +lex:add_rule('section', section) lex:add_style('section', lexer.STYLE_CLASS) +-- TeX and ConTeXt mkiv environments. +local environment = token(lexer.STRING, '\\' * (beginend + startstop) * lexer.alpha^1) +lex:add_rule('environment', environment) + -- Commands. -local command = token('command', '\\' * (lexer.alpha^1 * - ('\\' * lexer.alpha^0)^-1 + - S('#$&~_^%{}\\'))) +local command = token('command', '\\' * (lexer.alpha^1 * '\\' * lexer.space^1 + + lexer.alpha^1 + + S('!"#$%&\',./;=[\\]_{|}~`^-'))) lex:add_rule('command', command) lex:add_style('command', lexer.STYLE_KEYWORD) -- Operators. -lex:add_rule('operator', token(lexer.OPERATOR, S('$&#{}[]'))) +lex:add_rule('operator', token(lexer.OPERATOR, S('#$_[]{}~^'))) -- Fold points. lex:add_fold_point('environment', '\\start', '\\stop') -lex:add_fold_point('command', '\\begin', '\\end') +lex:add_fold_point('environment', '\\begin', '\\end') lex:add_fold_point(lexer.OPERATOR, '{', '}') lex:add_fold_point(lexer.COMMENT, '%', lexer.fold_line_comments('%')) |