[antlr-interest] cpp target

Gavin Lambert antlr at mirality.co.nz
Tue Jul 17 01:17:04 PDT 2007

At 09:51 17/07/2007, Waldemar Sauer wrote:
>How do I tell antlr v.3 to output to a .cpp file?
>I need to be able to use my C++ objects in my parser.  I can get 
>to where I need to go by renaming the .c file to .cpp, and doing 
>the ``extern "C"'' thing on each regular C include.  So I think I 
>can accomplish what I need with e.g. a Perl script, but I was 
>wondering if there is maybe a better way to do this, e.g. some 
>option switch somewhere.  I can imagine that I will not be the 
>only one that needs to cross the C/C++ barrier.

Three options that occur to me:

1. Whatever you're doing currently :)
2. Use a compiler option to force compilation as C++ despite the 
.c extension
3. Write a C++ wrapper class to hide your C parser from the rest 
of the C++ code, and corresponding C functions to let your parser 
manipulate C++ objects.  (This may get complicated depending on 
how many classes you want to encapulate this way.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070717/4d2181cf/attachment.html 

More information about the antlr-interest mailing list