[antlr-interest] Using an external source for token definitions

Jim Idle jimi at temporal-wave.com
Tue Dec 2 09:51:01 PST 2008


On Tue, 2008-12-02 at 12:07 +0100, lars.vonwedel at bayertechnology.com
wrote:

> 
> 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. 


Why don't you just generate the lexer rules and the statementKeyword
rule instead of the .tokens file? Assuming that you are not changing the
language every week, then it is a one off operation and far simpler than
trying to override the generated code (which you will then have to mess
with every time ANTLR changes). You can then import the generated lexer
and parser rules.


> Can I subclass the parser and override the statementKeyword method to
> perform a lookup in my existing keywords list ? 
> 

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081202/da1c1497/attachment.html 


More information about the antlr-interest mailing list