Fix |braced| rule in the PEG.js grammar

This fix does not change the behavior, it just makes the
|nonBraceCharacters| rule un-dead (as originally intended).
redux
David Majda 13 years ago
parent 23e04bb4f4
commit 7900b66c70

@ -321,10 +321,10 @@ describe("PEG.js grammar parser", function() {
/* Canonical braced is "{ code }". */
it("parses braced", function() {
expect('start = "abcd" {}' ).toParseAs(actionGrammar(""));
expect('start = "abcd" {a}' ).toParseAs(actionGrammar("a"));
expect('start = "abcd" {{a}}').toParseAs(actionGrammar("{a}"));
expect('start = "abcd" {aaa}').toParseAs(actionGrammar("aaa"));
expect('start = "abcd" {}' ).toParseAs(actionGrammar(""));
expect('start = "abcd" {{a}}' ).toParseAs(actionGrammar("{a}"));
expect('start = "abcd" {abcd}' ).toParseAs(actionGrammar("abcd"));
expect('start = "abcd" {{a}{b}{c}}').toParseAs(actionGrammar("{a}{b}{c}"));
});
/* Trivial character rules are not tested. */

@ -835,13 +835,13 @@ PEG.parser = (function(){
result1 = [];
result2 = parse_braced();
if (result2 === null) {
result2 = parse_nonBraceCharacter();
result2 = parse_nonBraceCharacters();
}
while (result2 !== null) {
result1.push(result2);
result2 = parse_braced();
if (result2 === null) {
result2 = parse_nonBraceCharacter();
result2 = parse_nonBraceCharacters();
}
}
if (result1 !== null) {

@ -144,7 +144,7 @@ action "action"
= braced:braced __ { return braced.substr(1, braced.length - 2); }
braced
= "{" parts:(braced / nonBraceCharacter)* "}" {
= "{" parts:(braced / nonBraceCharacters)* "}" {
return "{" + parts.join("") + "}";
}

Loading…
Cancel
Save