[antlr-interest] Visual Studio 2008 C++ and ANTLR 3
Jim Idle
jimi at temporal-wave.com
Wed Mar 4 12:24:11 PST 2009
Robert Soule wrote:
> Antlr 3.1.2 won't generate c++, but I have had no problems linking with
> c++ code. If you want your antlr grammar to output c++, such as in:
>
> myrule : a { cout << "a"; } b ;
>
> Then you will need to throw in some hacks to get the #includes right. I used:
>
> @header{
> #ifndef _MyLangauge_H
> #include <iostream>
> #include <string>
> using namespace std;
> #endif
> }
>
> where "_MyLangauge_H" is the include guard generated by the antlr tool.
>
> -Robert
>
Please read the API docs:
http://antlr.org/api/C/index.html
Look for the section about Using @sections. @header is not the palce to
put these, you probably want one of @include @preincludes or
@postinclude (probably the latter).
Jim
More information about the antlr-interest
mailing list