PEG.js grammar: Inline trivial character rules

redux
David Majda 10 years ago
parent ae89f5e469
commit a5a0609505

@ -42,13 +42,17 @@ module.exports = (function() {
rules: extractList(rules, 0)
};
},
peg$c4 = function(code) {
peg$c4 = ";",
peg$c5 = { type: "literal", value: ";", description: "\";\"" },
peg$c6 = function(code) {
return {
type: "initializer",
code: code
};
},
peg$c5 = function(name, displayName, expression) {
peg$c7 = "=",
peg$c8 = { type: "literal", value: "=", description: "\"=\"" },
peg$c9 = function(name, displayName, expression) {
return {
type: "rule",
name: name,
@ -61,12 +65,14 @@ module.exports = (function() {
: expression
};
},
peg$c6 = function(first, rest) {
peg$c10 = "/",
peg$c11 = { type: "literal", value: "/", description: "\"/\"" },
peg$c12 = function(first, rest) {
return rest.length > 0
? { type: "choice", alternatives: buildList(first, rest, 3) }
: first;
},
peg$c7 = function(first, rest, code) {
peg$c13 = function(first, rest, code) {
var expression = rest.length > 0
? { type: "sequence", elements: buildList(first, rest, 1) }
: first;
@ -76,109 +82,103 @@ module.exports = (function() {
code: code
};
},
peg$c8 = function(first, rest) {
peg$c14 = function(first, rest) {
return rest.length > 0
? { type: "sequence", elements: buildList(first, rest, 1) }
: first;
},
peg$c9 = function(label, expression) {
peg$c15 = ":",
peg$c16 = { type: "literal", value: ":", description: "\":\"" },
peg$c17 = function(label, expression) {
return {
type: "labeled",
label: label,
expression: expression
};
},
peg$c10 = function(expression) {
peg$c18 = "$",
peg$c19 = { type: "literal", value: "$", description: "\"$\"" },
peg$c20 = function(expression) {
return {
type: "text",
expression: expression
};
},
peg$c11 = function(code) {
peg$c21 = "&",
peg$c22 = { type: "literal", value: "&", description: "\"&\"" },
peg$c23 = function(code) {
return {
type: "semantic_and",
code: code
};
},
peg$c12 = function(expression) {
peg$c24 = function(expression) {
return {
type: "simple_and",
expression: expression
};
},
peg$c13 = function(code) {
peg$c25 = "!",
peg$c26 = { type: "literal", value: "!", description: "\"!\"" },
peg$c27 = function(code) {
return {
type: "semantic_not",
code: code
};
},
peg$c14 = function(expression) {
peg$c28 = function(expression) {
return {
type: "simple_not",
expression: expression
};
},
peg$c15 = function(expression) {
peg$c29 = "?",
peg$c30 = { type: "literal", value: "?", description: "\"?\"" },
peg$c31 = function(expression) {
return {
type: "optional",
expression: expression
};
},
peg$c16 = function(expression) {
peg$c32 = "*",
peg$c33 = { type: "literal", value: "*", description: "\"*\"" },
peg$c34 = function(expression) {
return {
type: "zero_or_more",
expression: expression
};
},
peg$c17 = function(expression) {
peg$c35 = "+",
peg$c36 = { type: "literal", value: "+", description: "\"+\"" },
peg$c37 = function(expression) {
return {
type: "one_or_more",
expression: expression
};
},
peg$c18 = void 0,
peg$c19 = function(name) {
peg$c38 = void 0,
peg$c39 = function(name) {
return {
type: "rule_ref",
name: name
};
},
peg$c20 = function() { return { type: "any" }; },
peg$c21 = function(expression) { return expression; },
peg$c22 = { type: "other", description: "action" },
peg$c23 = function(braced) { return braced.substr(1, braced.length - 2); },
peg$c24 = "{",
peg$c25 = { type: "literal", value: "{", description: "\"{\"" },
peg$c26 = "}",
peg$c27 = { type: "literal", value: "}", description: "\"}\"" },
peg$c28 = /^[^{}]/,
peg$c29 = { type: "class", value: "[^{}]", description: "[^{}]" },
peg$c30 = "=",
peg$c31 = { type: "literal", value: "=", description: "\"=\"" },
peg$c32 = ":",
peg$c33 = { type: "literal", value: ":", description: "\":\"" },
peg$c34 = ";",
peg$c35 = { type: "literal", value: ";", description: "\";\"" },
peg$c36 = "/",
peg$c37 = { type: "literal", value: "/", description: "\"/\"" },
peg$c38 = "&",
peg$c39 = { type: "literal", value: "&", description: "\"&\"" },
peg$c40 = "!",
peg$c41 = { type: "literal", value: "!", description: "\"!\"" },
peg$c42 = "$",
peg$c43 = { type: "literal", value: "$", description: "\"$\"" },
peg$c44 = "?",
peg$c45 = { type: "literal", value: "?", description: "\"?\"" },
peg$c46 = "*",
peg$c47 = { type: "literal", value: "*", description: "\"*\"" },
peg$c48 = "+",
peg$c49 = { type: "literal", value: "+", description: "\"+\"" },
peg$c50 = "(",
peg$c51 = { type: "literal", value: "(", description: "\"(\"" },
peg$c52 = ")",
peg$c53 = { type: "literal", value: ")", description: "\")\"" },
peg$c54 = ".",
peg$c55 = { type: "literal", value: ".", description: "\".\"" },
peg$c40 = ".",
peg$c41 = { type: "literal", value: ".", description: "\".\"" },
peg$c42 = function() { return { type: "any" }; },
peg$c43 = "(",
peg$c44 = { type: "literal", value: "(", description: "\"(\"" },
peg$c45 = ")",
peg$c46 = { type: "literal", value: ")", description: "\")\"" },
peg$c47 = function(expression) { return expression; },
peg$c48 = { type: "other", description: "action" },
peg$c49 = function(braced) { return braced.substr(1, braced.length - 2); },
peg$c50 = "{",
peg$c51 = { type: "literal", value: "{", description: "\"{\"" },
peg$c52 = "}",
peg$c53 = { type: "literal", value: "}", description: "\"}\"" },
peg$c54 = /^[^{}]/,
peg$c55 = { type: "class", value: "[^{}]", description: "[^{}]" },
peg$c56 = { type: "other", description: "identifier" },
peg$c57 = "_",
peg$c58 = { type: "literal", value: "_", description: "\"_\"" },
@ -542,7 +542,13 @@ module.exports = (function() {
s2 = peg$currPos;
s3 = peg$parse__();
if (s3 !== peg$FAILED) {
s4 = peg$parseSemicolon();
if (input.charCodeAt(peg$currPos) === 59) {
s4 = peg$c4;
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
}
if (s4 !== peg$FAILED) {
s3 = [s3, s4];
s2 = s3;
@ -559,7 +565,7 @@ module.exports = (function() {
}
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c4(s1);
s1 = peg$c6(s1);
s0 = s1;
} else {
peg$currPos = s0;
@ -600,7 +606,13 @@ module.exports = (function() {
s3 = peg$c1;
}
if (s3 !== peg$FAILED) {
s4 = peg$parseEquals();
if (input.charCodeAt(peg$currPos) === 61) {
s4 = peg$c7;
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c8); }
}
if (s4 !== peg$FAILED) {
s5 = peg$parse__();
if (s5 !== peg$FAILED) {
@ -609,7 +621,13 @@ module.exports = (function() {
s7 = peg$currPos;
s8 = peg$parse__();
if (s8 !== peg$FAILED) {
s9 = peg$parseSemicolon();
if (input.charCodeAt(peg$currPos) === 59) {
s9 = peg$c4;
peg$currPos++;
} else {
s9 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
}
if (s9 !== peg$FAILED) {
s8 = [s8, s9];
s7 = s8;
@ -626,7 +644,7 @@ module.exports = (function() {
}
if (s7 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c5(s1, s3, s6);
s1 = peg$c9(s1, s3, s6);
s0 = s1;
} else {
peg$currPos = s0;
@ -670,7 +688,13 @@ module.exports = (function() {
s3 = peg$currPos;
s4 = peg$parse__();
if (s4 !== peg$FAILED) {
s5 = peg$parseSlash();
if (input.charCodeAt(peg$currPos) === 47) {
s5 = peg$c10;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}
if (s5 !== peg$FAILED) {
s6 = peg$parse__();
if (s6 !== peg$FAILED) {
@ -699,7 +723,13 @@ module.exports = (function() {
s3 = peg$currPos;
s4 = peg$parse__();
if (s4 !== peg$FAILED) {
s5 = peg$parseSlash();
if (input.charCodeAt(peg$currPos) === 47) {
s5 = peg$c10;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}
if (s5 !== peg$FAILED) {
s6 = peg$parse__();
if (s6 !== peg$FAILED) {
@ -726,7 +756,7 @@ module.exports = (function() {
}
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c6(s1, s2);
s1 = peg$c12(s1, s2);
s0 = s1;
} else {
peg$currPos = s0;
@ -786,7 +816,7 @@ module.exports = (function() {
s4 = peg$parseAction();
if (s4 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c7(s1, s2, s4);
s1 = peg$c13(s1, s2, s4);
s0 = s1;
} else {
peg$currPos = s0;
@ -844,7 +874,7 @@ module.exports = (function() {
}
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c8(s1, s2);
s1 = peg$c14(s1, s2);
s0 = s1;
} else {
peg$currPos = s0;
@ -867,14 +897,20 @@ module.exports = (function() {
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$parseColon();
if (input.charCodeAt(peg$currPos) === 58) {
s3 = peg$c15;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c16); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parse__();
if (s4 !== peg$FAILED) {
s5 = peg$parsePrefixed();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c9(s1, s5);
s1 = peg$c17(s1, s5);
s0 = s1;
} else {
peg$currPos = s0;
@ -907,14 +943,20 @@ module.exports = (function() {
var s0, s1, s2, s3;
s0 = peg$currPos;
s1 = peg$parseDollar();
if (input.charCodeAt(peg$currPos) === 36) {
s1 = peg$c18;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c19); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$parseSuffixed();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c10(s3);
s1 = peg$c20(s3);
s0 = s1;
} else {
peg$currPos = s0;
@ -930,14 +972,20 @@ module.exports = (function() {
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseAnd();
if (input.charCodeAt(peg$currPos) === 38) {
s1 = peg$c21;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c22); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$parseAction();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c11(s3);
s1 = peg$c23(s3);
s0 = s1;
} else {
peg$currPos = s0;
@ -953,14 +1001,20 @@ module.exports = (function() {
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseAnd();
if (input.charCodeAt(peg$currPos) === 38) {
s1 = peg$c21;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c22); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$parseSuffixed();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c12(s3);
s1 = peg$c24(s3);
s0 = s1;
} else {
peg$currPos = s0;
@ -976,14 +1030,20 @@ module.exports = (function() {
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseNot();
if (input.charCodeAt(peg$currPos) === 33) {
s1 = peg$c25;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c26); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$parseAction();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c13(s3);
s1 = peg$c27(s3);
s0 = s1;
} else {
peg$currPos = s0;
@ -999,14 +1059,20 @@ module.exports = (function() {
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseNot();
if (input.charCodeAt(peg$currPos) === 33) {
s1 = peg$c25;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c26); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$parseSuffixed();
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c14(s3);
s1 = peg$c28(s3);
s0 = s1;
} else {
peg$currPos = s0;
@ -1039,10 +1105,16 @@ module.exports = (function() {
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$parseQuestion();
if (input.charCodeAt(peg$currPos) === 63) {
s3 = peg$c29;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c30); }
}
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c15(s1);
s1 = peg$c31(s1);
s0 = s1;
} else {
peg$currPos = s0;
@ -1062,10 +1134,16 @@ module.exports = (function() {
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$parseStar();
if (input.charCodeAt(peg$currPos) === 42) {
s3 = peg$c32;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c33); }
}
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c16(s1);
s1 = peg$c34(s1);
s0 = s1;
} else {
peg$currPos = s0;
@ -1085,10 +1163,16 @@ module.exports = (function() {
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$parsePlus();
if (input.charCodeAt(peg$currPos) === 43) {
s3 = peg$c35;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c36); }
}
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c17(s1);
s1 = peg$c37(s1);
s0 = s1;
} else {
peg$currPos = s0;
@ -1141,7 +1225,13 @@ module.exports = (function() {
s5 = peg$c1;
}
if (s5 !== peg$FAILED) {
s6 = peg$parseEquals();
if (input.charCodeAt(peg$currPos) === 61) {
s6 = peg$c7;
peg$currPos++;
} else {
s6 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c8); }
}
if (s6 !== peg$FAILED) {
s4 = [s4, s5, s6];
s3 = s4;
@ -1159,14 +1249,14 @@ module.exports = (function() {
}
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = peg$c18;
s2 = peg$c38;
} else {
peg$currPos = s2;
s2 = peg$c0;
}
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c19(s1);
s1 = peg$c39(s1);
s0 = s1;
} else {
peg$currPos = s0;
@ -1182,15 +1272,27 @@ module.exports = (function() {
s0 = peg$parseClass();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseDot();
if (input.charCodeAt(peg$currPos) === 46) {
s1 = peg$c40;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c41); }
}
if (s1 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c20();
s1 = peg$c42();
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseLparen();
if (input.charCodeAt(peg$currPos) === 40) {
s1 = peg$c43;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c44); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
@ -1198,10 +1300,16 @@ module.exports = (function() {
if (s3 !== peg$FAILED) {
s4 = peg$parse__();
if (s4 !== peg$FAILED) {
s5 = peg$parseRparen();
if (input.charCodeAt(peg$currPos) === 41) {
s5 = peg$c45;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c46); }
}
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c21(s3);
s1 = peg$c47(s3);
s0 = s1;
} else {
peg$currPos = s0;
@ -1241,7 +1349,7 @@ module.exports = (function() {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c23(s1);
s1 = peg$c49(s1);
s0 = s1;
} else {
peg$currPos = s0;
@ -1254,7 +1362,7 @@ module.exports = (function() {
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c22); }
if (peg$silentFails === 0) { peg$fail(peg$c48); }
}
return s0;
@ -1266,11 +1374,11 @@ module.exports = (function() {
s0 = peg$currPos;
s1 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 123) {
s2 = peg$c24;
s2 = peg$c50;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c25); }
if (peg$silentFails === 0) { peg$fail(peg$c51); }
}
if (s2 !== peg$FAILED) {
s3 = [];
@ -1287,11 +1395,11 @@ module.exports = (function() {
}
if (s3 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 125) {
s4 = peg$c26;
s4 = peg$c52;
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c27); }
if (peg$silentFails === 0) { peg$fail(peg$c53); }
}
if (s4 !== peg$FAILED) {
s2 = [s2, s3, s4];
@ -1336,191 +1444,9 @@ module.exports = (function() {
function peg$parseNonBraceCharacter() {
var s0;
if (peg$c28.test(input.charAt(peg$currPos))) {
if (peg$c54.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c29); }
}
return s0;
}
function peg$parseEquals() {
var s0;
if (input.charCodeAt(peg$currPos) === 61) {
s0 = peg$c30;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c31); }
}
return s0;
}
function peg$parseColon() {
var s0;
if (input.charCodeAt(peg$currPos) === 58) {
s0 = peg$c32;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c33); }
}
return s0;
}
function peg$parseSemicolon() {
var s0;
if (input.charCodeAt(peg$currPos) === 59) {
s0 = peg$c34;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c35); }
}
return s0;
}
function peg$parseSlash() {
var s0;
if (input.charCodeAt(peg$currPos) === 47) {
s0 = peg$c36;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c37); }
}
return s0;
}
function peg$parseAnd() {
var s0;
if (input.charCodeAt(peg$currPos) === 38) {
s0 = peg$c38;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c39); }
}
return s0;
}
function peg$parseNot() {
var s0;
if (input.charCodeAt(peg$currPos) === 33) {
s0 = peg$c40;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c41); }
}
return s0;
}
function peg$parseDollar() {
var s0;
if (input.charCodeAt(peg$currPos) === 36) {
s0 = peg$c42;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c43); }
}
return s0;
}
function peg$parseQuestion() {
var s0;
if (input.charCodeAt(peg$currPos) === 63) {
s0 = peg$c44;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
}
return s0;
}
function peg$parseStar() {
var s0;
if (input.charCodeAt(peg$currPos) === 42) {
s0 = peg$c46;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c47); }
}
return s0;
}
function peg$parsePlus() {
var s0;
if (input.charCodeAt(peg$currPos) === 43) {
s0 = peg$c48;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c49); }
}
return s0;
}
function peg$parseLparen() {
var s0;
if (input.charCodeAt(peg$currPos) === 40) {
s0 = peg$c50;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c51); }
}
return s0;
}
function peg$parseRparen() {
var s0;
if (input.charCodeAt(peg$currPos) === 41) {
s0 = peg$c52;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c53); }
}
return s0;
}
function peg$parseDot() {
var s0;
if (input.charCodeAt(peg$currPos) === 46) {
s0 = peg$c54;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c55); }
@ -1760,7 +1686,7 @@ module.exports = (function() {
}
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = peg$c18;
s1 = peg$c38;
} else {
peg$currPos = s1;
s1 = peg$c0;
@ -1885,7 +1811,7 @@ module.exports = (function() {
}
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = peg$c18;
s1 = peg$c38;
} else {
peg$currPos = s1;
s1 = peg$c0;
@ -2087,7 +2013,7 @@ module.exports = (function() {
}
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = peg$c18;
s1 = peg$c38;
} else {
peg$currPos = s1;
s1 = peg$c0;
@ -2154,7 +2080,7 @@ module.exports = (function() {
}
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = peg$c18;
s2 = peg$c38;
} else {
peg$currPos = s2;
s2 = peg$c0;
@ -2204,7 +2130,7 @@ module.exports = (function() {
s3 = peg$parseDigit();
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = peg$c18;
s2 = peg$c38;
} else {
peg$currPos = s2;
s2 = peg$c0;
@ -2490,7 +2416,7 @@ module.exports = (function() {
s5 = peg$parseEOLChar();
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = peg$c18;
s4 = peg$c38;
} else {
peg$currPos = s4;
s4 = peg$c0;
@ -2522,7 +2448,7 @@ module.exports = (function() {
s5 = peg$parseEOLChar();
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = peg$c18;
s4 = peg$c38;
} else {
peg$currPos = s4;
s4 = peg$c0;
@ -2587,7 +2513,7 @@ module.exports = (function() {
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = peg$c18;
s4 = peg$c38;
} else {
peg$currPos = s4;
s4 = peg$c0;
@ -2625,7 +2551,7 @@ module.exports = (function() {
}
peg$silentFails--;
if (s5 === peg$FAILED) {
s4 = peg$c18;
s4 = peg$c38;
} else {
peg$currPos = s4;
s4 = peg$c0;

@ -366,8 +366,6 @@ describe("PEG.js grammar parser", function() {
expect('start = "abcd" {}}').toFailToParse();
});
/* Trivial character rules are not tested. */
/* Canonical Identifier is "a". */
it("parses Identifier", function() {
expect('start = a' ).toParseAs(ruleRefGrammar("a"));

@ -28,7 +28,7 @@ Grammar
}
Initializer
= code:Action (__ Semicolon)? {
= code:Action (__ ";")? {
return {
type: "initializer",
code: code
@ -38,8 +38,8 @@ Initializer
Rule
= name:Identifier __
displayName:(String __)?
Equals __
expression:Expression (__ Semicolon)? {
"=" __
expression:Expression (__ ";")? {
return {
type: "rule",
name: name,
@ -57,7 +57,7 @@ Expression
= Choice
Choice
= first:Sequence rest:(__ Slash __ Sequence)* {
= first:Sequence rest:(__ "/" __ Sequence)* {
return rest.length > 0
? { type: "choice", alternatives: buildList(first, rest, 3) }
: first;
@ -81,7 +81,7 @@ Sequence
}
Labeled
= label:Identifier __ Colon __ expression:Prefixed {
= label:Identifier __ ":" __ expression:Prefixed {
return {
type: "labeled",
label: label,
@ -91,31 +91,31 @@ Labeled
/ Prefixed
Prefixed
= Dollar __ expression:Suffixed {
= "$" __ expression:Suffixed {
return {
type: "text",
expression: expression
};
}
/ And __ code:Action {
/ "&" __ code:Action {
return {
type: "semantic_and",
code: code
};
}
/ And __ expression:Suffixed {
/ "&" __ expression:Suffixed {
return {
type: "simple_and",
expression: expression
};
}
/ Not __ code:Action {
/ "!" __ code:Action {
return {
type: "semantic_not",
code: code
};
}
/ Not __ expression:Suffixed {
/ "!" __ expression:Suffixed {
return {
type: "simple_not",
expression: expression
@ -124,19 +124,19 @@ Prefixed
/ Suffixed
Suffixed
= expression:Primary __ Question {
= expression:Primary __ "?" {
return {
type: "optional",
expression: expression
};
}
/ expression:Primary __ Star {
/ expression:Primary __ "*" {
return {
type: "zero_or_more",
expression: expression
};
}
/ expression:Primary __ Plus {
/ expression:Primary __ "+" {
return {
type: "one_or_more",
expression: expression
@ -145,7 +145,7 @@ Suffixed
/ Primary
Primary
= name:Identifier !(__ (String __)? Equals) {
= name:Identifier !(__ (String __)? "=") {
return {
type: "rule_ref",
name: name
@ -153,8 +153,8 @@ Primary
}
/ Literal
/ Class
/ Dot { return { type: "any" }; }
/ Lparen __ expression:Expression __ Rparen { return expression; }
/ "." { return { type: "any" }; }
/ "(" __ expression:Expression __ ")" { return expression; }
/* "Lexical" elements */
@ -170,20 +170,6 @@ NonBraceCharacters
NonBraceCharacter
= [^{}]
Equals = "="
Colon = ":"
Semicolon = ";"
Slash = "/"
And = "&"
Not = "!"
Dollar = "$"
Question = "?"
Star = "*"
Plus = "+"
Lparen = "("
Rparen = ")"
Dot = "."
/*
* Modeled after ECMA-262, 5th ed., 7.6, but much simplified:
*

Loading…
Cancel
Save