tree grammar PolyPrinter; options { tokenVocab=Poly; language=ObjC; ASTLabelType=CommonTree; output=template; } poly: ^('+' a=poly b=poly) -> template(a={$a.st} b:b={$b.st}) "+" | ^(MULT a=poly b=poly) -> template(a={$a.st} b:b={$b.st}) "" | ^('^' a=poly b=poly) -> template(a={$a.st} b:b={$b.st}) "^" | INT -> {%{$INT.text}} | ID -> {%{$ID.text}} ;