[antlr-interest] C-Runtime in C++ prog

Jim Idle jimi at temporal-wave.com
Sat Feb 16 08:10:35 PST 2008


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. You 
should keep the code in your grammar files to an absolute minimum, just 
for maintenance reasons really.

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.

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.

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.

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.

Jim




> -----Original Message-----
> From: Oliver Kowalke [mailto:oliver.kowalke at gmx.de]
> Sent: Friday, February 15, 2008 11:36 PM
> To: antlr-interest
> Subject: [antlr-interest] C-Runtime in C++ prog
> 
> Hello,
> because the C++-runtime (antlr-v3) is not available yet - could I use
> the
> C-runtime in my C++ application and embedd C++ code in the grammar
> rules?
> 
> Does the C-Runtime report errors as return values (I didn't found an
> example
> in the documentation)?
> 
> best regards,
> Oliver




More information about the antlr-interest mailing list