On 05/18/2011 12:41 PM, Ben Corne wrote:
> 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)

I would try:

  : c=canonical a=annotation -> ^($tokenType [$tokenText] $c $a)
or
  : c=canonical a=annotation -> ^([$tokenType, $tokenText] $c $a)

I know the first one works when the $tokenType is replaced with a TOKEN
name constant, but I can only find such uses as GOTO["GOTO"] in my code.

The second case works when the first argument inside the [] is a token
reference (as in:
    t=TOKEN -> ^([$t, spelling] ....)
).

I'm not sure if the tool will take any integer in place of an actual
TOKEN name constant.  Certainly the runtime method that it gets
translated into will.  Look at the generated source code.  I'm using
C/C++, are you using JAVA?

>  ;
> ================================================================
> 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.
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address


-- 
Kevin J. Cummings
[email protected]
[email protected]
[email protected]
Registered Linux User #1232 (http://counter.li.org)

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to