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/gherkin.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/gherkin.lua')
| -rw-r--r-- | lexlua/gherkin.lua | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lexlua/gherkin.lua b/lexlua/gherkin.lua index 2fe38c57d..eedfe3436 100644 --- a/lexlua/gherkin.lua +++ b/lexlua/gherkin.lua @@ -16,26 +16,27 @@ lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[ ]])) -- Strings. -local doc_str = '"""' * (lexer.any - '"""')^0 * P('"""')^-1 -local dq_str = lexer.delimited_range('"') +local doc_str = lexer.range('"""') +local dq_str = lexer.range('"') lex:add_rule('string', token(lexer.STRING, doc_str + dq_str)) -- Comments. -lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline^0)) +lex:add_rule('comment', token(lexer.COMMENT, lexer.to_eol('#'))) -- Numbers. -local number = token(lexer.NUMBER, lexer.float + lexer.integer) +local number = token(lexer.NUMBER, lexer.number) -- Tags. lex:add_rule('tag', token('tag', '@' * lexer.word^0)) lex:add_style('tag', lexer.STYLE_LABEL) -- Placeholders. -lex:add_rule('placeholder', token('placeholder', lexer.nested_pair('<', '>'))) +lex:add_rule('placeholder', token('placeholder', + lexer.range('<', '>', false, false, true))) lex:add_style('placeholder', lexer.STYLE_VARIABLE) -- Examples. -lex:add_rule('example', token('example', '|' * lexer.nonnewline^0)) +lex:add_rule('example', token('example', lexer.to_eol('|'))) lex:add_style('example', lexer.STYLE_NUMBER) return lex |
