You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
790 B
51 lines
790 B
grammar t021hoist;
|
|
options {
|
|
language=Cpp;
|
|
}
|
|
|
|
@lexer::includes
|
|
{
|
|
#include "UserTestTraits.hpp"
|
|
}
|
|
@lexer::namespace
|
|
{ Antlr3Test }
|
|
|
|
@parser::includes {
|
|
#include "UserTestTraits.hpp"
|
|
}
|
|
@parser::namespace
|
|
{ Antlr3Test }
|
|
|
|
/* 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}
|
|
;
|