[antlr-interest] Antlr 3 Lexer problem

Geoffrey Zhu gzhu at peak6.com
Tue Jun 26 11:28:18 PDT 2007


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,

grammar T;

options {

ID : ('a'..'z')+;

LPAREN : '(';

LP_SELECT : LPAREN 'select';

prog: (ID | LPAREN | LP_SELECT)+ ;

The  information in this email or in any file attached=0A=
hereto is intended only for the personal and confiden-=0A=
tial  use  of  the individual or entity to which it is=0A=
addressed and may contain information that is  propri-=0A=
etary  and  confidential.  If you are not the intended=0A=
recipient of this message you are hereby notified that=0A=
any  review, dissemination, distribution or copying of=0A=
this message is strictly prohibited.  This  communica-=0A=
tion  is  for information purposes only and should not=0A=
be regarded as an offer to sell or as  a  solicitation=0A=
of an offer to buy any financial product. Email trans-=0A=
mission cannot be guaranteed to be  secure  or  error-=0A=
free. P6070214

More information about the antlr-interest mailing list