• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1lexer grammar Fuzzy;
2options {filter=true; language=ObjC;}
3
4IMPORT
5	:	'import' WS name=QIDStar WS? ';'
6	;
7
8/** Avoids having "return foo;" match as a field */
9RETURN
10	:	'return' (options {greedy=false;}:.)* ';'
11	;
12
13CLASS
14	:	'class' WS name=ID WS? ('extends' WS QID WS?)?
15		('implements' WS QID WS? (',' WS? QID WS?)*)? '{'
16        {NSLog(@"found class \%@", $name.text);}
17	;
18
19METHOD
20    :   TYPE WS name=ID WS? '(' ( ARG WS? (',' WS? ARG WS?)* )? ')' WS?
21       ('throws' WS QID WS? (',' WS? QID WS?)*)? '{'
22        {NSLog(@"found method \%@", $name.text);}
23    ;
24
25FIELD
26    :   TYPE WS name=ID '[]'? WS? (';'|'=')
27        {NSLog(@"found var \%@", $name.text);}
28    ;
29
30STAT:	('if'|'while'|'switch'|'for') WS? '(' ;
31
32CALL
33    :   name=QID WS? '('
34        {/*ignore if this/super */ NSLog(@"found call \%@",$name.text);}
35    ;
36
37COMMENT
38    :   '/*' (options {greedy=false;} : . )* '*/'
39        {NSLog(@"found comment \%@", [self text]);}
40    ;
41
42SL_COMMENT
43    :   '//' (options {greedy=false;} : . )* '\n'
44        {NSLog(@"found // comment \%@", [self text]);}
45    ;
46
47STRING
48	:	'"' (options {greedy=false;}: ESC | .)* '"'
49	;
50
51CHAR
52	:	'\'' (options {greedy=false;}: ESC | .)* '\''
53	;
54
55WS  :   (' '|'\t'|'\n')+
56    ;
57
58fragment
59QID :	ID ('.' ID)*
60	;
61
62/** QID cannot see beyond end of token so using QID '.*'? somewhere won't
63 *  ever match since k=1 lookahead in the QID loop of '.' will make it loop.
64 *  I made this rule to compensate.
65 */
66fragment
67QIDStar
68	:	ID ('.' ID)* '.*'?
69	;
70
71fragment
72TYPE:   QID '[]'?
73    ;
74
75fragment
76ARG :   TYPE WS ID
77    ;
78
79fragment
80ID  :   ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
81    ;
82
83fragment
84ESC	:	'\\' ('"'|'\''|'\\')
85	;
86
87