[antlr-interest] How to do preprocessing in antlr v4?
Martin d'Anjou
martin.danjou14 at gmail.com
Sun Nov 18 18:52:49 PST 2012
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
More information about the antlr-interest
mailing list