Closed mingodad closed 8 months ago
I tried:
parsertl::rules rules;
parsertl::state_machine sm;
parsertl::generator::build(rules, sm);
Which threw an exception saying "No productions are defined."
The segfault happens when trying to dump the state machine of a user grammar in playground.cpp
that is a variant of gram_grep
:
The problem can be seem when adding the code shown bellow here https://github.com/BenHanson/gram_grep/blob/23d06f813ba0c58735a1278c5af0a7aed416f573/main.cpp#L431:
if(true /*gs.dump_grammar_gsm*/)
{
parsertl::dfa dfa_;
parsertl::generator::build_dfa(gs.user_parser.grules, dfa_); //!!!! segfaults inside build_dfa
parsertl::debug::dump(gs.user_parser.grules, dfa_, std::cout);
return false;
}
Done
When there is no rules in the grammar (lexer declarations only) and we try to dump the grammar state machine we get a segfault. This https://github.com/mingodad/parsertl-playground/commit/96890dfd4af6b80f9f64ac118ac6c0194450bcf2 seems to fix it.