At 16:22 8/01/2009, Ben Gillis wrote: >per the Definitive Guide to ANTLR, it *seems* like this would >work: > >myRule : 'KEYWORD' '=' keyvalue=(INTEGER | FLOATNUMBER | >HEXNUMBER | identifier | QUOTED_STRING) -> ^(KEYWORD $keyvalue)
You can't assign a label to a () block. But you can assign one to a rule: myRule : 'KEYWORD' '=' keyvalue=myRuleValue -> ^(KEYWORD $keyvalue); myRuleValue : INTEGER | FLOATNUMBER | HEXNUMBER | identifier | QUOTED_STRING; For that matter, you could leave out the label entirely: myRule : 'KEYWORD' '=' myRuleValue -> ^(KEYWORD $myRuleValue); myRuleValue : INTEGER | FLOATNUMBER | HEXNUMBER | identifier | QUOTED_STRING; or: myRule : 'KEYWORD'^ '='! myRuleValue; myRuleValue : INTEGER | FLOATNUMBER | HEXNUMBER | identifier | QUOTED_STRING; or: myRule : 'KEYWORD'^ '='! (INTEGER | FLOATNUMBER | HEXNUMBER | identifier | QUOTED_STRING); (And, yes, ANTLR really ought to issue a compile-time error when you try that [or just silently make it work], instead of producing code that will generate runtime errors. Stuff like this will hopefully be resolved once ANTLR v3 finally gets self-hosted.) 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 -~----------~----~----~----~------~----~------~--~---
