[antlr-interest] Defining keywords with varying length

Lars von Wedel vonwedel at web.de
Tue Nov 29 01:26:25 PST 2005


Hello,

I am about to write parsers for (lots of) input files to an existing 
tool. The language I have to deal with (besides other annoyances) 
permits abbreviated keywords, so you could write something like

 LIBRARY

as a keyword, but since

 LIB

is unique to identify that keyword it would be sufficient, as well as 
anything else such as LIBR, LIBRAR or so. Defining all these variants as 
tokens and dealing with them in the parser does not appear as a clean 
solution to me.

How would I best incorporate this into a lexer/parser developed in Antlr?

Lars




More information about the antlr-interest mailing list