[antlr-interest] simple question on V2 grammar
Nagesh, Harsha
harsha.nagesh at credit-suisse.com
Tue Oct 9 14:39:51 PDT 2007
I have the option "caseSensitive = false;" set in my lexer.
where should I use
AND:'and' ?
I tried it as lexer rule and also as a token, in all cases antlr gives a syntax error...can we really give
singleQuote and singleQuote, anywhere ?
_____
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jim Idle
Sent: Tuesday, October 09, 2007 5:29 PM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] simple question on V2 grammar
You want:
AND : 'and';
I believe. And your Letter rule matches lower case only, but the sample you gave has upper case.
Hope this helps,
Jim
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Nagesh, Harsha
Sent: Tuesday, October 09, 2007 2:21 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] simple question on V2 grammar
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
==============================================================================
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.14.5/1058 - Release Date: 10/8/2007 4:54 PM
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.14.5/1058 - Release Date: 10/8/2007 4:54 PM
==============================================================================
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/36696120/attachment-0001.html
More information about the antlr-interest
mailing list