[antlr-interest] Resolving conflict between keyword and identifier

John Green greenj at ix.netcom.com
Mon Feb 11 09:48:37 PST 2002


In my lexer I use:

ID
options {
        testLiterals = true;
}
	:	('a'..'z'|'_'|'$')
	etc.

and then for the keyword rule I have a list of token types rather than a
list of string literals.

Works for me, with many hundreds of keywords. (Of course, make the keywords
list big enough and you can run into the old "virtual memory exhausted"
error from G++, but that's another issue)

HTH
John Green
www.joanju.com


> -----Original Message-----
> From: SAGAR BIYANI [mailto:sagarbiyani at yahoo.com]
> Sent: Sunday, February 10, 2002 7:41 PM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Resolving conflict between keyword and
> identifier
>
>
> Hi,
>
> I am writing grammar for SQL. Trying to resolve
> conflict between keyword and identifier through the
> following rules:
>
> keyword: "access" |"admin" ... ;
>
> id: ID |keyword;
>
> The above rule works only if the keywords defined in
> the keyword rule is less. If it exceeds above certain
> limit(approx 100), ANTLR generates wrong code in the
> parsers (starts ignoring predicates) and hence the
> whole thing is not working. Anybody know how to
> resolve this problem?
>
> Thanks in advance.
>
> -Sagar
>
> __________________________________________________
> Do You Yahoo!?
> Send FREE Valentine eCards with Yahoo! Greetings!
> http://greetings.yahoo.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list