fix: better error when a supertype rule is invalid

This commit is contained in:
Amaan Qureshi 2024-06-03 12:26:10 +02:00
parent e553578696
commit a73191bf0e

View file

@ -394,7 +394,12 @@ function grammar(baseGrammar, options) {
throw new Error("Grammar's supertypes must be an array of rules.");
}
supertypes = supertypeRules.map(symbol => symbol.name);
supertypes = supertypeRules.map(symbol => {
if (symbol.name === 'ReferenceError') {
throw new Error(`Supertype rule \`${symbol.symbol.name}\` is not defined.`);
}
return symbol.name;
});
}
let precedences = baseGrammar.precedences;