[antlr-interest] Simple C++ Support
Christian Schladetsch
christian.schladetsch at gmail.com
Sun Apr 6 02:44:32 PDT 2008
Hello [Jim],
There is a very simple way to allow C++ support via your C target (for ANTLR
3.1b). All that has to happen is that the StringTemplate that generates the
FooParser.c from Foo.g3pl generates:
/* End of Header action.
*
=============================================================================
*/
/* -----------------------------------------
* Include the ANTLR3 generated header file.
*/
extern "C"
{
#include "FooParser.h"
}
/* ----------------------------------------- */
That is, wrap the header include with extern "C", set the generated file to
build using C++ and away you go. I have tried this and it works, but I have
not changed the template as I only started using ANTLR today. Of course, it
would be nice if you could specify the generated file to have a .cpp
extension (or .cxx or .C).
Could this make it into a build soon? It is a trivial change and yet would
allow us to use C++ code in actions and predicates for parser and trees
which would be great for those of us that are writing C++ systems.
Regards,
Christian.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080406/96b753ae/attachment-0001.html
More information about the antlr-interest
mailing list