Fixed PEG.buildParser's documentation and added a test.
This commit is contained in:
parent
48da65d08e
commit
3f5cb8850c
|
@ -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";
|
||||
|
|
|
@ -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"'); },
|
||||
|
|
Loading…
Reference in a new issue