Here's my non-working toy grammar:
grammar test;
tokens {
CAT = 'cat' ;
LP = '(' ;
RP = ')' ;
}
them
: (cat)=> cat
| NAME
;
cat : CAT LP RP ;
NAME : 'a'..'z'+ ;
The lexer insists that "cat" is a CAT instead of a NAME. In the real
grammar, all keywords can also be identifiers. How can this be done?
None of the examples I've seen so far really fit this case.
I tried:
cat : c:CAT {if(!input.LT(1).getText().equals("[")) c.setType(NAME);} LP RP ;
but that doesn't seem to work.
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
-~----------~----~----~----~------~----~------~--~---