[antlr-interest] #include handling - newbie question

Terence Parr parrt at cs.usfca.edu
Wed Jul 14 11:09:36 PDT 2004

On Jul 14, 2004, at 9:47 AM, Bill Clark wrote:

> Hello,
> I'm looking for tips on the simplest way to handle #include
> directives in a file to be parsed by ANTLR. I've seen the advice
> that it's not a problem that ANTLR is well-suited to solve, but I'm
> not sure what's the best way to go about this. I can easily write a
> preprocessor that just inserts the contents of the included file in
> the stream that's handed to the lexer, but then I don't see a good
> way to provide line numbers/filenames in error messages.
> It seems like there ought to be a simple way to deal with this
> general problem; am I missing it?

ANTLR can do nested lexers no sweat.  I launch a new lexer to handle 
each include file.  I believe at my CS652 site (see the link in 
documentation on antlr.org) I have a lecture (including audio) on 
include files.

CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!
Cofounder, http://www.peerscope.com pure link sharing

Yahoo! Groups Links

<*> To visit your group on the web, go to:

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:

More information about the antlr-interest mailing list