mirror of
https://github.com/janet-lang/janet
synced 2024-11-28 19:19:53 +00:00
Improve peg error on unknown rule.
This helps a lot when debugging large, failing grammars.
This commit is contained in:
parent
f780df0aa6
commit
f9d57103f4
@ -887,8 +887,10 @@ static uint32_t peg_compile1(Builder *b, Janet peg) {
|
||||
JanetTable *grammar = old_grammar;
|
||||
for (; i > 0 && janet_checktype(peg, JANET_KEYWORD); --i) {
|
||||
peg = janet_table_get_ex(grammar, peg, &grammar);
|
||||
if (!grammar)
|
||||
peg_panic(b, "unknown rule");
|
||||
if (!grammar || janet_checktype(peg, JANET_NIL)) {
|
||||
builder_cleanup(b);
|
||||
janet_panicf("grammar error in %p, unknown rule", b->form);
|
||||
}
|
||||
b->form = peg;
|
||||
b->grammar = grammar;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user