[antlr-interest] #include handling - newbie question
Monty Zukowski
monty at codetransform.com
Wed Jul 14 10:36:12 PDT 2004
You can set up a lexer rule for #include which, in its action, creates
a new lexer for the other file and then switches lexer states to use
that lexer.
See examples/cpp/includeFile in the antlr distribution.
Note to Ter, we ought to have that as a java example as well!
Monty
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?
>
> Thanks,
> Bill
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit --
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list