[antlr-interest] Languages where keywords can be used as identifiers

Adam Bishop (DSLWN) AdamB at datacom.co.nz
Tue Feb 7 14:16:53 PST 2006


I am parsing a language where "loop" is a keyword, however a label can
be named loop.  The rule for label expects an identifier token, but the
lexer will return a loop token.  Is there any way to switch testLiterals
for a particular rule?

 

Ideally the Lexer shouldn't be doing testLiterals for any usage of the
token ID in the parser.

 

NOTE:  To make things worse, I am having this problem wherever I have a
rule in the parser that expects an identifier

e.g.

 

"goto" ID

 

Will fail for input "goto loop"

 

And 

 

datatype ID 

 

will fail for "Number length" (since length is a keyword in another
rule)

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060208/4c209697/attachment.html


More information about the antlr-interest mailing list