[antlr-interest] simple question on V2 grammar
Nagesh, Harsha
harsha.nagesh at credit-suisse.com
Tue Oct 9 14:20:54 PDT 2007
Hi - Can anybody please help me in this simple grammar ?
My language consists only of Letters (a..z) and a few tokens ("and", "or"). I am trying to match an expression "A and B" using the following
Parser
---------
myOp:
atom (AND atom)*
;
atom: Letter
;
Lexer
-------
tokens { AND = "and";}
Letter: 'a'..'z'
When I feed the expression "A and B" to this, the parser fails. The second token, Instead of matching with AND, matches with Letter and thus fails....I am not sure how can I fix this ? I tried to use syntactic predicate
myOp:
(atom AND) => atom (AND atom)*
;
but antlr ignored it when generating the code saying that syntactic predicate not required when only one alternative exists...
Can anybody please help
Thanks
Harsha
==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071009/305d4a25/attachment-0001.html
More information about the antlr-interest
mailing list