1lexer grammar t019lexer; 2options { 3 language=Cpp; 4 filter=true; 5} 6 7@lexer::includes 8{ 9#include "UserTestTraits.hpp" 10} 11@lexer::namespace 12{ Antlr3Test } 13 14IMPORT 15 : 'import' WS name=QIDStar WS? ';' 16 ; 17 18/** Avoids having "return foo;" match as a field */ 19RETURN 20 : 'return' (options {greedy=false;}:.)* ';' 21 ; 22 23CLASS 24 : 'class' WS name=ID WS? ('extends' WS QID WS?)? 25 ('implements' WS QID WS? (',' WS? QID WS?)*)? '{' 26 ; 27 28COMMENT 29 : '/*' (options {greedy=false;} : . )* '*/' 30 ; 31 32STRING 33 : '"' (options {greedy=false;}: ESC | .)* '"' 34 ; 35 36CHAR 37 : '\'' (options {greedy=false;}: ESC | .)* '\'' 38 ; 39 40WS : (' '|'\t'|'\n')+ 41 ; 42 43fragment 44QID : ID ('.' ID)* 45 ; 46 47/** QID cannot see beyond end of token so using QID '.*'? somewhere won't 48 * ever match since k=1 lookahead in the QID loop of '.' will make it loop. 49 * I made this rule to compensate. 50 */ 51fragment 52QIDStar 53 : ID ('.' ID)* '.*'? 54 ; 55 56fragment 57TYPE: QID '[]'? 58 ; 59 60fragment 61ARG : TYPE WS ID 62 ; 63 64fragment 65ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')* 66 ; 67 68fragment 69ESC : '\\' ('"'|'\''|'\\') 70 ; 71 72