diff --git a/lib/compiler.js b/lib/compiler.js index 9dab87c..cf07c89 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -15,9 +15,10 @@ function nop() {} * metagrammar.pegjs file. The start rule may be unspecified, in which case * "start" is used. * - * Throws |PEG.Grammar.GrammarError| if the grammar contains an error. Note that - * not all errors are detected during the generation and some may protrude to - * the generated parser and cause its malfunction. + * Throws |PEG.grammarParser.SyntaxError| if the grammar contains a syntax error + * or |PEG.Grammar.GrammarError| if it contains a semantic error. Note that not + * all errors are detected during the generation and some may protrude to the + * generated parser and cause its malfunction. */ PEG.buildParser = function(grammar, startRule) { startRule = startRule || "start"; diff --git a/test/compiler-test.js b/test/compiler-test.js index b481a79..dc7d488 100644 --- a/test/compiler-test.js +++ b/test/compiler-test.js @@ -169,6 +169,13 @@ test("generateUniqueIdentifier", function() { module("PEG"); +test("buildParser reports syntax errors in the grammar", function() { + throws( + function() { PEG.buildParser(''); }, + PEG.grammarParser.SyntaxError + ); +}); + test("buildParser reports missing start rule", function() { throws( function() { PEG.buildParser('notStart: "abcd"'); },