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