[antlr-interest] C generator is not generating @after actions

Gavin Lambert antlr at mirality.co.nz
Thu Feb 5 23:28:37 PST 2009


At 12:43 6/02/2009, Jim Idle wrote:
 >Yes, I think that that is a sensible option, however with the C
 >target that implies that you need to link with the socket
 >library and it isn't available everywhere. Maybe a good thing
 >would be to have a -mode=xxxxx option and the xxx options would
 >be just passed into the string templates for the target. Then
 >the target code generation templates could all support target
 >specific things, even if there were some things that made
 >sense to all targets. or perhaps expand -debug to optionally
 >allow -debug=xxxx, yyyy

My point though is that without doing anything extra (no extra 
command line options, nothing altered in existing grammars) it 
ought to default to the "robust" mode, that does extra sanity 
checking (which could compromise performance a bit) -- that way 
the people who need the benefit the most (those starting out with 
a new grammar) will get it immediately.

Then, once people are confident that their grammars are correct, 
they set the option to strip out the sanity checks, thereby 
improving the performance.  Something in the options {} block 
seems like the best idea for those using ANTLRworks to compile, 
though a command-line option would be more convenient for those 
using a build system (then they could compile with sanity checks 
for their unit test suite and without for the final release).

I don't think it's necessarily target-specific; while the specific 
tests might be, I'm sure that there are still sanity checks that 
could be done even in the other targets.

But for now possibly the "cheapest" option (requiring no changes 
to ANTLR itself) would be to use something like:
@headers {
#define ANTLR_PERFORMANCE
}
and use macros in the generated code that compile to nothing if 
that is defined.



More information about the antlr-interest mailing list