[antlr-interest] How to use antlr V3 with C++

Johannes Luber jaluber at gmx.de
Mon Aug 18 10:01:41 PDT 2008


miles mccoo schrieb:
> Thank you, Jim, for the reply.
> 
> The existence of the c library told me that there's a way to generate .c
> output and not just Java and your mail confirms this. The thing is, I
> haven't managed to get anltworks to generate anything other than java code.
> 
> I looked in the file->preferences popup and didn't see anything about
> targetting other languages. when I run generate->generate code, I get
> java code.
> 
> so perhaps the real question is: what option do I need to set to
> generate non-java (C, in my case, but I don't see any others either) code?
> 
> Miles

Use

options {
language=C;
}

in your grammar. Please also read the "5 minute introduction" on the
wiki, as beginner questions tend to have been answered there.

Johannes
> 
> 
> On Mon, Aug 18, 2008 at 9:34 AM, Jim Idle <jimi at temporal-wave.com
> <mailto:jimi at temporal-wave.com>> wrote:
> 
>     On Mon, 2008-08-18 at 07:30 -0700, miles mccoo wrote:
>>
>>
>>     I used the original antlr  ages ago and now I need to use it
>>     again. From the description Antlr3 is what I want to use, but I
>>     haven't been able to find any information on how to use it in c++.
>>
>>     Is there a wiki, tutorial, example, or msg thread on how to
>>     generate a parser that I can compile into my c++ application?
>>     Everything I've found assumes I'm a java programmer, which I'm
>>     not. Is see the page with the target libs, but no info on how to
>>     use them.
>>
>     Use the C target, but compile the resulting .c files as c++ code and
>     it will all work. Use the C examples in the examples download for
>     more guidance (specifically the C parser examples).
> 
>     The C API is documented by following the API Documentation link from
>     the main ANTLR home page.
> 
>     Jim
> 
> 



More information about the antlr-interest mailing list