[antlr-interest] Trouble with Templates in Tree Grammar
Scott Stevenson
sstevenson638 at gmail.com
Tue Dec 14 19:10:09 PST 2010
I learning how to use templates in a tree grammar. I'm mimicking some of
the examples in the ANTLR Reference. I have a rule:
primary
: INT -> primaryTemplate(text={$INT.text})
| DECIMAL -> primaryTemplate(text={$DECIMAL.text})
| ID -> primaryTemplate(text={$ID.text})
;
where primaryTemplate is the name of the template to evaluate.
In the tree parser code it declares $INT to be type Object.
Object INT4;
and later tries to invoke INT4.getText(). This gives an error because
Object does not have method getText().
Can anyone tell me what am I doing wrong? This looks just like the example
in the book.
Thanks in advance.
More information about the antlr-interest
mailing list