t021hoist.g revision 324c4644fee44b9898524c09511bd33c3f12e2df
1grammar t021hoist;
2options {
3    language=JavaScript;
4}
5
6/* With this true, enum is seen as a keyword.  False, it's an identifier */
7@members {
8this.enableEnum = false;
9}
10
11stat returns [enumIs]
12    : identifier    {enumIs = "ID"}
13    | enumAsKeyword {enumIs = "keyword"}
14    ;
15
16identifier
17    : ID
18    | enumAsID
19    ;
20
21enumAsKeyword : {this.enableEnum}? 'enum' ;
22
23enumAsID : {!this.enableEnum}? 'enum' ;
24
25ID  :   ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
26    ;
27
28INT :	('0'..'9')+
29    ;
30
31WS  :   (   ' '
32        |   '\t'
33        |   '\r'
34        |   '\n'
35        )+
36        {$channel=HIDDEN;}
37    ;    
38