Handle the case where the language definition references a non-existant rule, and ensure it fails with 'Unknown Parser'

This commit is contained in:
Sean Usher
2016-11-07 19:28:52 -08:00
parent 37c12b1d43
commit 71af0741db

2
mpc.c
View File

@@ -3264,7 +3264,7 @@ static mpc_parser_t *mpca_grammar_find_parser(char *x, mpca_grammar_st_t *st) {
st->parsers = realloc(st->parsers, sizeof(mpc_parser_t*) * st->parsers_num);
st->parsers[st->parsers_num-1] = p;
if (p == NULL) { return mpc_failf("Unknown Parser '%s'!", x); }
if (p == NULL || p->name == NULL) { return mpc_failf("Unknown Parser '%s'!", x); }
if (p->name && strcmp(p->name, x) == 0) { return p; }
}