Hi,

I've run into problems trying to do something like this:

options {PREFIX;}

prefix : a=('-' | '+') prefix -> ^(PREFIX $a prefix)
          | int
          ;
int : '0'..'9'+

To generate trees such as:

(FACTOR  - (FACTOR - 12))

Which is to say, how do I identify which token was selected and add it
to my rewrite rule?

At the moment I've identified two workarounds:

prefix : '-' prefix -> ^(PREFIX '-' prefix)
          | '+' prefix -> ^(PREFIX '+' prefix)
          | int
          ;

and

prefix : umOK prefix -> ^(PREFIX umok prefix)
          | int
          ;
umOK : ('-'|'+') ;

The first isn't great, and the second is OK (but I'm not wild about
it).  I've been scratching around on the online documentation and
Terence's book, but I'm a little overwhelmed :).

Thanks
-Blake

P.S. Apologies for the cryptic subject, wasn't all that sure how to
describe the problem.

List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/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