[antlr-interest] How to do preprocessing in antlr v4?

Martin d'Anjou martin.danjou14 at gmail.com
Sat Nov 17 16:54:46 PST 2012


Hello,

What is the right approach to implement preprocessor directives 
(#define, #undef, #ifdef,, #ifndef, #if, #elsif, #else, #endif, 
#include, and user defined macros)  in Antlr v4?

I would find it a waste to write a separate preprocessor to tokenize the 
input stream and resolve the directives and macros (and their 
parameters), just to write the token stream back to a file, then 
retokenize with antlr... It looks to me that preprocessor does almost 
the same work as the lexer.

Macro parameters are the reason why I want to tokenize the input to the 
preprocessor. So I want lexer -> preprocessor -> parser.

Thanks,
Martin



More information about the antlr-interest mailing list