[antlr-interest] Antlr 3 Lexer problem
Jim Idle
jimi at temporal-wave.com
Tue Jun 26 11:32:14 PDT 2007
Don't try to construct syntactical context in the lexer basically:
grammar T;
options {
language=CSharp;
backtracking=true;
}
ID : ('a'..'z')+;
LPAREN : '(';
SELECT : 'select';
prog: (ID | LPAREN SELECT?)+ ;
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Geoffrey Zhu
> Sent: Tuesday, June 26, 2007 11:28 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Antlr 3 Lexer problem
>
> Hi,
>
> I have a simple lexer problem. The below grammar will fail on "(
> security" in the lexer, because when the lexer sees '(' and then sees
> 's' , it will try to match the LP_SELECT rule, which cannot be
matched.
> In this case, I want the lexer to return LPAREN and then ID. How can I
> do that?
>
> Thanks a lot,
> Geoffrey
>
>
> grammar T;
>
> options {
> language=CSharp;
> backtracking=true;
> }
>
> ID : ('a'..'z')+;
>
> LPAREN : '(';
>
> LP_SELECT : LPAREN 'select';
>
> prog: (ID | LPAREN | LP_SELECT)+ ;
>
> _______________________________________________________
>
> The information in this email or in any file attached
> hereto is intended only for the personal and confiden-
> tial use of the individual or entity to which it is
> addressed and may contain information that is propri-
> etary and confidential. If you are not the intended
> recipient of this message you are hereby notified that
> any review, dissemination, distribution or copying of
> this message is strictly prohibited. This communica-
> tion is for information purposes only and should not
> be regarded as an offer to sell or as a solicitation
> of an offer to buy any financial product. Email trans-
> mission cannot be guaranteed to be secure or error-
> free. P6070214
More information about the antlr-interest
mailing list