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/glsl.lua | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'lexlua/glsl.lua') diff --git a/lexlua/glsl.lua b/lexlua/glsl.lua index 31440f0a6..d6bef2b44 100644 --- a/lexlua/glsl.lua +++ b/lexlua/glsl.lua @@ -19,21 +19,15 @@ lex:modify_rule('keyword', token(lexer.KEYWORD, word_match[[ ]]) + lex:get_rule('keyword')) -- Types. -lex:modify_rule('type', - token(lexer.TYPE, - S('bdiu')^-1 * 'vec' * R('24') + - P('d')^-1 * 'mat' * R('24') * ('x' * R('24')^-1) + - S('iu')^-1 * 'sampler' * R('13') * 'D' + - 'sampler' * R('12') * 'D' * P('Array')^-1 * 'Shadow' + - S('iu')^-1 * 'sampler' * (R('12') * 'DArray' + - word_match[[ - Cube 2DRect Buffer 2DMS 2DMSArray 2DMSCubeArray - ]]) + - word_match[[ - samplerCubeShadow sampler2DRectShadow - samplerCubeArrayShadow - ]]) + - lex:get_rule('type') + +lex:modify_rule('type', token(lexer.TYPE, S('bdiu')^-1 * 'vec' * R('24') + + P('d')^-1 * 'mat' * R('24') * ('x' * R('24')^-1) + + S('iu')^-1 * 'sampler' * R('13') * 'D' + + 'sampler' * R('12') * 'D' * P('Array')^-1 * 'Shadow' + + S('iu')^-1 * 'sampler' * (R('12') * 'DArray' + word_match[[ + Cube 2DRect Buffer 2DMS 2DMSArray 2DMSCubeArray + ]]) + + word_match[[samplerCubeShadow sampler2DRectShadow samplerCubeArrayShadow]]) + + lex:get_rule('type') + -- Functions. token(lexer.FUNCTION, word_match[[ -- cgit v1.2.3