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

Jim Idle jimi at temporal-wave.com
Fri Feb 6 08:05:25 PST 2009


Gavin Lambert wrote:
> 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.
All my experience tells me that I will be answering "How do I make this 
go faster forever though". It is better require a request for debug 
'style' information/instrumentation, in the way the C compilers do.
>
> 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; 
No, neither do I. For instance there could possibly be a 'robust' mode 
in all targets, though exactly what it meant to each target will be 
different.
> 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
> }
#define ANTLR3_SANITY_CHECK

But otherwise that would do it assuming that I wanted to add lots of 
#ifdefs. It is however easy to extend the debug option, assuming that 
Ter believes the idea is a worthwhile one.

Jim
> and use macros in the generated code that compile to nothing if that 
> is defined.
>



More information about the antlr-interest mailing list