From fad15f79b1230b3076be515d6894c8919562809b Mon Sep 17 00:00:00 2001 From: mitchell Date: Sat, 25 Apr 2020 16:26:31 -0400 Subject: 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. --- lexlua/cmake.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lexlua/cmake.lua') diff --git a/lexlua/cmake.lua b/lexlua/cmake.lua index ef3b598b0..2c78d5d25 100644 --- a/lexlua/cmake.lua +++ b/lexlua/cmake.lua @@ -111,7 +111,7 @@ lex:add_rule('variable', token(lexer.VARIABLE, word_match[[ MINGW MSVC MSVC60 MSVC70 MSVC71 MSVC80 MSVC_IDE POST_BUILD PRE_BUILD PROJECT_BINARY_DIR PROJECT_NAME PROJECT_SOURCE_DIR RUN_CONFIGURE TARGET UNIX WIN32 -]] + P('$') * lexer.delimited_range('{}', false, true))) +]] + P('$') * lexer.range('{', '}'))) -- Operators. lex:add_rule('operator', token(lexer.OPERATOR, word_match[[ @@ -123,10 +123,10 @@ lex:add_rule('operator', token(lexer.OPERATOR, word_match[[ lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) -- Strings. -lex:add_rule('string', token(lexer.STRING, lexer.delimited_range('"'))) +lex:add_rule('string', token(lexer.STRING, lexer.range('"'))) -- Comments. -lex:add_rule('comment', token(lexer.COMMENT, '#' * lexer.nonnewline^0)) +lex:add_rule('comment', token(lexer.COMMENT, lexer.to_eol('#'))) -- Fold points. lex:add_fold_point(lexer.KEYWORD, 'IF', 'ENDIF') -- cgit v1.2.3