1 tree grammar PolyPrinter; 2 options { 3 tokenVocab=Poly; 4 language=ObjC; 5 ASTLabelType=CommonTree; 6 output=template; 7 } 8 9 poly: ^('+' a=poly b=poly) -> template(a={$a.st} b:b={$b.st}) "<a>+<b>" 10 | ^(MULT a=poly b=poly) -> template(a={$a.st} b:b={$b.st}) "<a><b>" 11 | ^('^' a=poly b=poly) -> template(a={$a.st} b:b={$b.st}) "<a>^<b>" 12 | INT -> {%{$INT.text}} 13 | ID -> {%{$ID.text}} 14 ; 15