Home | History | Annotate | Download | only in functional
      1 lexer grammar t019lexer;
      2 options {
      3     language=JavaScript;
      4     filter=true;
      5 }
      6 
      7 IMPORT
      8 	:	'import' WS name=QIDStar WS? ';'
      9 	;
     10 	
     11 /** Avoids having "return foo;" match as a field */
     12 RETURN
     13 	:	'return' (options {greedy=false;}:.)* ';'
     14 	;
     15 
     16 CLASS
     17 	:	'class' WS name=ID WS? ('extends' WS QID WS?)?
     18 		('implements' WS QID WS? (',' WS? QID WS?)*)? '{'
     19 	;
     20 	
     21 COMMENT
     22     :   '/*' (options {greedy=false;} : . )* '*/'
     23     ;
     24 
     25 STRING
     26     :	'"' (options {greedy=false;}: ESC | .)* '"'
     27 	;
     28 
     29 CHAR
     30 	:	'\'' (options {greedy=false;}: ESC | .)* '\''
     31 	;
     32 
     33 WS  :   (' '|'\t'|'\n')+
     34     ;
     35 
     36 fragment
     37 QID :	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  */
     44 fragment
     45 QIDStar
     46 	:	ID ('.' ID)* '.*'?
     47 	;
     48 
     49 fragment
     50 TYPE:   QID '[]'?
     51     ;
     52     
     53 fragment
     54 ARG :   TYPE WS ID
     55     ;
     56 
     57 fragment
     58 ID  :   ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
     59     ;
     60 
     61 fragment
     62 ESC	:	'\\' ('"'|'\''|'\\')
     63 	;
     64 
     65