[antlr-interest] treewalker $expression.text?
Terence Parr
parrt at cs.usfca.edu
Thu Sep 6 10:39:50 PDT 2007
$text works in tree grammars only if it's got a single root. A
limitation (for now).
If eitherRule is a single subtree, should work.
get text for multiple elements individually.
Ter
On Sep 6, 2007, at 10:06 AM, Martin Kohl wrote:
> Hello,
>
> Why can't I use the form $ruleName.text in my actions in the tree
> walker grammar? For example:
>
> rule :
> eitherRule {System.out.println($rule.text);}
> | orRule
> ;
>
> works just fine if it's in the normal Parser Grammar, but not if I
> try to do it in the TreeWalker grammar. Is there any way around
> this? Also, I notice I can do this with Tokens in the TreeGrammar
> without problems. So I can get it to print an IDENT, but if there's
> an expression specifying that IDENT to follow, I can't print that
> in the TreeWalker.
>
> Please help, I like the Tree Walker concept and would hate to have
> to revert to moving all the actions to the normal Parser Grammar.
>
> Thanks!
> Martin
More information about the antlr-interest
mailing list