At 19:39 12/09/2008, Fabian Baboschi wrote:
>element : BAR NAME
> ;
>
>BAR : 'bar'
> ;
>
>NAME
> : ('a'..'z'|'A'..'Z')('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
> ;
[...]
>I tried to use the following input: bar bar
>and I get errors because the parser doesn't recognize that the
>second bar should be treated as a name.
The other common solution to this (the first being what Matt just
suggested) is to leave your BAR rule in place but change element
like so:
element : BAR name ;
name : NAME | BAR ;
The key point to realise in all of this is that lexing happens
first, without any parser context. So given a choice between an
exact-match keyword and a vague-match identifier rule, the keyword
will win.
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
-~----------~----~----~----~------~----~------~--~---