[antlr-interest] Using an external source for token definitions
lars.vonwedel at bayertechnology.com
lars.vonwedel at bayertechnology.com
Tue Dec 2 03:07:06 PST 2008
Hello,
I have successfully implemented an ANTLR grammar for a small part of the
input language for a tool I am about to reengineer. However, I am a bit
unsure how to scale my current state to the full input language which has
several hundred keywords.
Luckily, all keywords are already available in a machine readable form and
it would be easy to generate a .tokens file from that source. However,
that additional pre-build step is somehow annoying me. Further, I would
need to generate rules of the form
statementKeyword : Keyword1 | Keyword2 | ... | KeywordN;
I would like to have (or implement) a rule of the form
statementKeyword : Keyword1 .. KeywordN;
as it is possible in the lexer, but it seems impossible in the parser.
This would avoid an extra generation step for the grammar.
Can I subclass the parser and override the statementKeyword method to
perform a lookup in my existing keywords list ?
Or are there any better ideas ?
Best Regards
Lars von Wedel
_________________________________________
Bayer Technology Services GmbH
BTS-PT-PD-ES
Leverkusen, E 41
Phone: +49 214 30 56456
Fax: +49 214 30 62677
E-mail: lars.vonwedel at bayertechnology.com
Web: www.bayertechnology.com
Geschäftsführer: Achim Noack
Aufsichtsratsvorsitzender: Dr. Wolfgang Plischke
Sitz der Gesellschaft: Leverkusen | Eintragung: Amtsgericht Köln, HRB
49896
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081202/fcde9b27/attachment.html
More information about the antlr-interest
mailing list