[antlr-interest] Antlr2 -> antlr 3 tree creation with rule argument as root

Ben Corne ben.corne at gmail.com
Wed May 18 09:41:35 PDT 2011


Hello

I've got this antlr2 rule which I'm trying to convert that goes like this:
================================================================
application![int tokenType, String tokenText]
    : c:canonical a:annotation { #application = #([tokenType,tokenText], c,
a); }
    ;
================================================================

My attempt is:
================================================================
application[int tokenType, String tokenText]
: c=canonical a=annotation -> ^({$tokenType;}[{$tokenText;}] $c $a)
 ;
================================================================
But the ANTLR3 parser returns the following errors:

syntax error: antlr: AmbientTalk.g:310:46: expecting RPAREN, found
'{$tokenText}'
syntax error: antlr: AmbientTalk.g:310:66: expecting SEMI, found ')'

Any thoughts / suggestions?

Regards
Ben C.


More information about the antlr-interest mailing list