[antlr-interest] Visual Studio 2008 C++ and ANTLR 3

Robert Soule robert.soule at gmail.com
Wed Mar 4 11:53:26 PST 2009


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


On Wed, Mar 4, 2009 at 2:38 PM, Guillaume Bataille
<guillaume.bataille at gmail.com> wrote:
> antlr 2.7.7 is running fine with visual studio 8, but the C code
> generated by antlr3 under visual studio 2008, targetting integration
> in windows mobile systems fails to link for me as soon as i invoke
> parsing functions and constructors. but most probably this is due to
> the fact that i didnt regen antlr3 libs for windows embedded systems,
> my fault i guess. anyhow i sorted myself today with antlr2, i regened
> antlr2 libs and wrote my grammar and had it integered it in my current
> project, its done :)
> ill try to regen antlr3 C libs later on on visual studio 2008 for
> windows embedded.
> still that would be a C version, antlr3 documents dont say antlr3.1.2
> can generate c++ code but say the work is in progress.
> but if you tell me antlr3.1.2 can generate cpp code by setting the
> right option ill try it when ill have the time.
>
>
>
>
> On Wed, Mar 4, 2009 at 4:32 PM, Jim Idle <jimi at temporal-wave.com> wrote:
>> Guillaume Bataille wrote:
>>> I am wondering if we will have any soon a C++ support from ANTLR 3,
>> At some point is best guess right now.
>>>  I
>>> tried to integer C generated code to some C++ project but it fails to
>>> link.
>>>
>> Errrr, well I can't help you with that kind of information - it works
>> for everyone else.- did you set the generated code to be C++? What
>> version are you using? etc.
>>
>> Jim
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list