[antlr-interest] C++ parser usage ideas

Ric Klaren ric.klaren at gmail.com
Wed Oct 19 10:31:46 PDT 2005


On 10/12/05, Jim Crafton <jim.crafton at gmail.com> wrote:
> My first problem (which I have resolved) was that the parser couldn't
> handle macro code at all. so something like:
>
> class MY_API FooBar {
> //code here
> };

> ... Is there a way to modify the orignal C++ grammar to just skip
> over the macros entirely (this would be great, as it would get around
> the whole issue). Apologies if this isn't strictly antlr specific, and
> if it's inapropriate, just let me know.

A while back I started adding a preprocessor to the grammar from David
Wigg using a tokenstream filter. I had to abandon the project but got
it partially working the results are available for download at (at the
ned of the webpage):

http://pts14043.pts.nl/antlr/

It works as a parser in front of the original C++ parser that replaces
macro's as it goes. I think it should do line tracking ok as well
(it's been a while since I made it). It might be interesting to look
at... it's very rough code though.

Cheers,

Ric


More information about the antlr-interest mailing list