[antlr-interest] How to deal with languages with preprocessor s?

mzukowski at bco.com mzukowski at bco.com
Fri Apr 5 07:22:40 PST 2002


> Any ideas please?. How to deal with the preprocessor directives in 
> C/C++ and C#.

For the GCC parser I run the preprocessor externally.  If you prefer to do
it yourself then you might want to make it a filter stream.  If all you want
to do is some includes, then you can handle that in the parser by opening a
new parser and lexer, feeding it the included filename, then attaching the
resulting tree to your current tree.
 
> Is this handled in the Lexer or in the Parser. Any [simple-ish or 
> clear] examples please?

If there's not an example in the examples directory then there is probably a
FAQ about it.
 
> On a more general note,is there some document/tutorial on writing LL
> (k) grammars with ANTLR. 
> 
> Also, any docs/tools on converting YACC/LEX stuff to ANTLR? 

www.javadude.com 's articles include an old antlr tutorial and LALR to LL
conversion which has basic stuff about yacc/lex to antlr.

Monty

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list