diff options
| author | mitchell <unknown> | 2020-04-25 16:26:31 -0400 |
|---|---|---|
| committer | mitchell <unknown> | 2020-04-25 16:26:31 -0400 |
| commit | fad15f79b1230b3076be515d6894c8919562809b (patch) | |
| tree | 72c848ef02c3331de5ca54eff7adaea3a9a6fb88 /lexlua/man.lua | |
| parent | 1fd02a367dec125c0b49dd9246a0928433866b96 (diff) | |
| download | scintilla-mirror-fad15f79b1230b3076be515d6894c8919562809b.tar.gz | |
Reformatted Lua LPeg lexers and added new convenience functions and pattern.
`lexer.range()` replaces `lexer.delimited_range()` and `lexer.nested_pair()`.
`lexer.to_eol()` replaces `patt * lexer.nonnewline^0` constructs.
`lexer.number` replaces `lexer.float + lexer.integer`.
Also added unit tests for lexer functions.
Diffstat (limited to 'lexlua/man.lua')
| -rw-r--r-- | lexlua/man.lua | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lexlua/man.lua b/lexlua/man.lua index efe765480..3a875f6b9 100644 --- a/lexlua/man.lua +++ b/lexlua/man.lua @@ -11,19 +11,16 @@ local lex = lexer.new('man') lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) -- Markup. -lex:add_rule('rule1', token(lexer.STRING, '.' * ('B' * P('R')^-1 + - 'I' * P('PR')^-1) * - lexer.nonnewline^0)) -lex:add_rule('rule2', token(lexer.NUMBER, '.' * S('ST') * 'H' * - lexer.nonnewline^0)) +lex:add_rule('rule1', token(lexer.STRING, '.' * + lexer.to_eol('B' * P('R')^-1 + 'I' * P('PR')^-1))) +lex:add_rule('rule2', token(lexer.NUMBER, lexer.to_eol('.' * S('ST') * 'H'))) lex:add_rule('rule3', token(lexer.KEYWORD, P('.br') + '.DS' + '.RS' + '.RE' + - '.PD')) + '.PD')) lex:add_rule('rule4', token(lexer.LABEL, '.' * (S('ST') * 'H' + '.TP'))) lex:add_rule('rule5', token(lexer.VARIABLE, '.B' * P('R')^-1 + - '.I' * S('PR')^-1 + - '.PP')) + '.I' * S('PR')^-1 + '.PP')) lex:add_rule('rule6', token(lexer.TYPE, '\\f' * S('BIPR'))) lex:add_rule('rule7', token(lexer.PREPROCESSOR, lexer.starts_line('.') * - lexer.alpha^1)) + lexer.alpha^1)) return lex |
