chore(generate): dedup and warn about duplicate or invalid rules
This commit is contained in:
parent
78ccc39ca9
commit
ce5f5fffc1
1 changed files with 11 additions and 1 deletions
|
|
@ -351,7 +351,17 @@ function grammar(baseGrammar, options) {
|
|||
throw new Error("Grammar's inline must be an array of rules.");
|
||||
}
|
||||
|
||||
inline = inlineRules.map(symbol => symbol.name);
|
||||
inline = inlineRules.filter((symbol, index, self) => {
|
||||
if (self.findIndex(s => s.name === symbol.name) !== index) {
|
||||
console.log(`Warning: duplicate inline rule '${symbol.name}'`);
|
||||
return false;
|
||||
}
|
||||
if (symbol.name === 'ReferenceError') {
|
||||
console.log(`Warning: inline rule '${symbol.symbol.name}' is not defined.`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}).map(symbol => symbol.name);
|
||||
}
|
||||
|
||||
let supertypes = baseGrammar.supertypes;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue