[antlr-interest] Simple C++ Support
Jim Idle
jimi at temporal-wave.com
Sun Apr 6 13:30:27 PDT 2008
Christian.
#.1b is already C++ compatible and the headers already support these constructs, just compiler the .c files as C++ (or reanme them).
Jim
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Christian Schladetsch
Sent: Sunday, April 06, 2008 2:45 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Simple C++ Support
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/1514fc84/attachment.html
More information about the antlr-interest
mailing list