android_mt6572_jiabo/external/antlr/antlr-3.4/runtime/Python/tests/t021hoist.g
2025-09-05 16:56:03 +08:00

37 lines
621 B
Text

grammar t021hoist;
options {
language=Python;
}
/* With this true, enum is seen as a keyword. False, it's an identifier */
@parser::init {
self.enableEnum = False
}
stat returns [enumIs]
: identifier {enumIs = "ID"}
| enumAsKeyword {enumIs = "keyword"}
;
identifier
: ID
| enumAsID
;
enumAsKeyword : {self.enableEnum}? 'enum' ;
enumAsID : {not self.enableEnum}? 'enum' ;
ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
;
INT : ('0'..'9')+
;
WS : ( ' '
| '\t'
| '\r'
| '\n'
)+
{$channel=HIDDEN}
;