diff options
Diffstat (limited to 'runtime/JavaScript/tests/functional/t019lexer.g')
-rwxr-xr-x | runtime/JavaScript/tests/functional/t019lexer.g | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/runtime/JavaScript/tests/functional/t019lexer.g b/runtime/JavaScript/tests/functional/t019lexer.g new file mode 100755 index 0000000..3d5b883 --- /dev/null +++ b/runtime/JavaScript/tests/functional/t019lexer.g @@ -0,0 +1,64 @@ +lexer grammar t019lexer; +options { + language=JavaScript; + filter=true; +} + +IMPORT + : 'import' WS name=QIDStar WS? ';' + ; + +/** Avoids having "return foo;" match as a field */ +RETURN + : 'return' (options {greedy=false;}:.)* ';' + ; + +CLASS + : 'class' WS name=ID WS? ('extends' WS QID WS?)? + ('implements' WS QID WS? (',' WS? QID WS?)*)? '{' + ; + +COMMENT + : '/*' (options {greedy=false;} : . )* '*/' + ; + +STRING + : '"' (options {greedy=false;}: ESC | .)* '"' + ; + +CHAR + : '\'' (options {greedy=false;}: ESC | .)* '\'' + ; + +WS : (' '|'\t'|'\n')+ + ; + +fragment +QID : ID ('.' ID)* + ; + +/** QID cannot see beyond end of token so using QID '.*'? somewhere won't + * ever match since k=1 lookahead in the QID loop of '.' will make it loop. + * I made this rule to compensate. + */ +fragment +QIDStar + : ID ('.' ID)* '.*'? + ; + +fragment +TYPE: QID '[]'? + ; + +fragment +ARG : TYPE WS ID + ; + +fragment +ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')* + ; + +fragment +ESC : '\\' ('"'|'\''|'\\') + ; + |