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

Terence Parr parrt at cs.usfca.edu
Sun Nov 18 21:40:34 PST 2012

Hi. in the extras code dir from book you'll find a C preprocessor like sample.
On Nov 18, 2012, at 6:52 PM, Martin d'Anjou wrote:

> On 12-11-18 09:51 AM, Bernard Kaiflin wrote:
>> Having said that, if your need is doing some preprocessing before 
>> parsing the C program, you would need a full C grammar combined with a 
>> full C preprocessor, and maybe use the TokenStreamRewriter feature 
>> described in paragraphs Rewriting the Input Stream on page 54 and 
>> Accessing Hidden Channels on page 208 of the beta 3 book.
> I have reached page 54 of the book (awesome book by the way), and had a 
> peek at page 208. If I want to implement a preprocessor using the 
> TokenStreamRewriter, I need the parser to call the listener when it 
> reaches a rule in the parser, which is impossible because there are no 
> preprocessor rules in the parser. So now I have to think about the other 
> parts of the answers that you offered.
> Thanks,
> Martin
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address

More information about the antlr-interest mailing list