1 grammar Lang; 2 options { 3 output=AST; 4 language = ObjC; 5 ASTLabelType=ANTLRCommonTree; 6 } 7 8 tokens {DECL;} // an imaginary node 9 10 start : decl ; 11 12 decl : type ID ';' -> ^(DECL type ID) 13 ; 14 type : INTTYPE // automatic tree construction builds a node for this rule 15 | FLOATTYPE 16 ; 17 18 INTTYPE : 'int' ; 19 FLOATTYPE : 'float' ; 20 ID : 'a'..'z'+ ; 21 INT : '0'..'9'+ ; 22 WS : (' '|'\n') {$channel=HIDDEN;} ; 23