Jens Hi Jonathan, thanks for the quick reply. I think I have found all helpful pages for JavaCC and CongoCC. Currently the biggest problem is to sort all sources in chronological order, because you develop to much to fast 😄
Are you, by any chance, going over the latest FreeMarker code?
If so, that is actually a pretty good thing to do, since the FreeMarker grammar there may well be the best example available of CongoCC usage for a fairly complex language. I think that if you went over that grammar and came to understand it, you'd be in a pretty good position in terms of understanding CongoCC overall. Well, that's true of the Java grammar or the C# or Python grammars too, but the FreeMarker grammar was basically written over the summer so it tends to really utilize the latest CongoCC feature set.
I have one question at the moment. It is possible to ignore INJECT statements from included grammar files?
Well, at the moment, there is no disposition for that. I guess what one could do in some cases is use the preprocessor.
You could have, in the included grammar something like:
#if !exclude_certain_injections // exclude_certain_injections is false by default
INJECT ....
INJECT ....
#endif
And then in the including grammar, you could have:
#define exclude_certain_injections
INCLUDE "included_grammar.ccc"
And the INJECT statements in the included grammar would be ignored.
Of course, maybe that doesn't address the problem so well, since the idea is that we have certain standard grammars right in the jarfile that can be INCLUDE
d, so you can write:
INCLUDE JAVA
And it just fishes the Java.ccc grammar out of the congocc.jar and includes it at that point. And in that case you don't have any chance to add any preprocessor snippet to the included grammar.
That said, I'm not sure how often there is such a strong need to turn off an INJECT. I mean, okay, if you're not going to use any of the injected code yourself, it's injected anyway, which is a bit inefficient space-wise. But it is probably not of very much practical importance nowadays.
There are a whole bunch of injected methods in the FreeMarker grammar, typically used when the rendering machinery walks the tree, and if you were going to INCLUDE the FreeMarker grammar for some other purposes, then a lot of those injected methods (and injected fields they use) are maybe unneeded. But really, that they're there occupying extra space does not seem like a big problem typically. Nowadays anyway.
And, of course, you can add your own injections in the including grammar...
Or maybe you have some other reason to want to suppress code injections. I don't know your use case.
So I guess the short answer is that there is no general ay to disable injections in the included grammar from the including grammar. But if you have an included grammar and you anticipate the need to turn off the injections, you can add a bit of preprocessor code as above.
I hope that answers your question.