I have a very huge (20kLOC) ANTLR4 grammar (converted by a script from Coco/R) which generates fine[1] & the C++ builds without warning, but whatever I feed the parser (even an empty file) I get:> terminate called after throwing an instance of 'std::out_of_range'
> what(): bitset::set: __position (which is 1051)1047) >= _Nb (which is 1024)
with a backtrace deep in antlr4::atn::LL1Analyzer::_LOOK()
> terminate called after throwing an instance of 'std::out_of_range'
> what(): bitset::set: __position (which is 1051)1047) >= _Nb (which is 1024)This message obviously points to an allocation problem. A look in the BitSet.h file shows:class ANTLR4CPP_PUBLIC BitSet : public std::bitset<1024> {
This message obviously points to an allocation problem. A look in the BitSet.h file shows:class ANTLR4CPP_PUBLIC BitSet : public std::bitset<1024> {
thank you for spotting that, I'm not familiar with the antlr internals.
Seems like that limitation is not easily parameterized (i.e. the generator tracking the maximum number of limitations in any given state, and setting the template parameter accordingly)?
In what place would it best be documented?
Just build the runtime yourself and increase this value (is 4096 too much/enough?), to see if that helps.
Once it is confirmed we can create a PR for ANTLR to get that change in.
And there’s not much effort to change that, just do it once in the Bitset class declaration and you are done. Would be good if you could just do it to see if that solves your problem.