[antlr-interest] C-Runtime in C++ prog
Oliver Kowalke
oliver.kowalke at gmx.de
Sat Feb 16 11:15:23 PST 2008
Am Samstag, 16. Februar 2008 17:10:35 schrieb Jim Idle:
> In the next release (coming soon) you will be able to embed C++ code in
> your C grammar as the output will be compilable as C++. However, you
> should not really need to put C++ code of any importance in the grammar,
> just make it call an external API that has extern "C" linkage.
I refered to actions - as I can remeber correctly ANTLR ignores the content of
actions. It seams I was wrong.
> You
> should keep the code in your grammar files to an absolute minimum, just
> for maintenance reasons really.
I'm sorry I don't understand this. If I implement an interpreter I have to put
in code inside the actions - right?
> Not sure what you mean by errors as return values. When a syntax error
> occurs, it fires a series of function calls that culminate in a call to
> displayRecognitionError. However, you can override these functions
> (usually you only need to override the displayRecognitionError) and make
> them do whatever you like.
I mean in C++ you throw exceptions (2.x version of ANTLR) in the case of
errors. But exceptions are not part of C.
> The next release is coming shortly and this has lots more documentation.
> I will talk to Ter about putting the new doxygen API stuff up there now
> as while some of it wont work until 3.1, there is lots of good
> background information in there.
that would be greate
> So, as far as C++ is concerned:
>
> 3.0
>
> Compile runtime as C, compile generated code as C, use C in actions,
> call external "C" API, link with C runtime library
>
> 3.1
>
> Compile runtime as C, compile generated code as C++ (if you need to),
> use C+ in actions, call C++ stuff, link with C runtime API.
OK
> My feeling is that other than some wrapper classes for tokens and so on,
> that might be all that C++ people really need, but we will see how it
> pans out.
best regards,
Oliver
More information about the antlr-interest
mailing list