TTree.g revision 324c4644fee44b9898524c09511bd33c3f12e2df
1tree grammar TTree; 2 3options { 4 5 // Default but name it anyway 6 // 7 language = Java; 8 9 // Use the vocab from the parser (not the lexer) 10 // The ANTLR Maven plugin knows how to work out the 11 // relationships between the .g files and it will build 12 // the tree parser after the parser. It will also rebuild 13 // the tree parser if the parser is rebuilt. 14 // 15 tokenVocab = TParser; 16 17 // Use ANTLR built-in CommonToken for tree nodes 18 // 19 ASTLabelType = CommonToken; 20} 21 22// What package should the generated source exist in? 23// 24@header { 25 26 package ${package}; 27} 28 29a : ^(SCRIPT stuff+) 30 | SCRIPT 31 ; 32 33stuff 34 : keyser 35 | expression 36 ; 37 38keyser 39 : ^(KEYSER SOZE) 40 { System.out.println("Found Keyser Soze!!"); } 41 ; 42 43expression 44 : ^(ADD expression expression) 45 | ID 46 | INT 47 | STRING 48 ; 49 50