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