diff --git a/lib/parser.js b/lib/parser.js index a5f23c1..f87d11c 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -29,8 +29,8 @@ module.exports = (function() { peg$FAILED = {}, - peg$startRuleFunctions = { grammar: peg$parsegrammar }, - peg$startRuleFunction = peg$parsegrammar, + peg$startRuleFunctions = { Grammar: peg$parseGrammar }, + peg$startRuleFunction = peg$parseGrammar, peg$c0 = peg$FAILED, peg$c1 = null, @@ -480,23 +480,23 @@ module.exports = (function() { ); } - function peg$parsegrammar() { + function peg$parseGrammar() { var s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$parse__(); if (s1 !== peg$FAILED) { - s2 = peg$parseinitializer(); + s2 = peg$parseInitializer(); if (s2 === peg$FAILED) { s2 = peg$c1; } if (s2 !== peg$FAILED) { s3 = []; - s4 = peg$parserule(); + s4 = peg$parseRule(); if (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) { s3.push(s4); - s4 = peg$parserule(); + s4 = peg$parseRule(); } } else { s3 = peg$c0; @@ -521,13 +521,13 @@ module.exports = (function() { return s0; } - function peg$parseinitializer() { + function peg$parseInitializer() { var s0, s1, s2; s0 = peg$currPos; - s1 = peg$parseaction(); + s1 = peg$parseAction(); if (s1 !== peg$FAILED) { - s2 = peg$parsesemicolon(); + s2 = peg$parseSemicolon(); if (s2 === peg$FAILED) { s2 = peg$c1; } @@ -547,22 +547,22 @@ module.exports = (function() { return s0; } - function peg$parserule() { + function peg$parseRule() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; - s1 = peg$parseidentifier(); + s1 = peg$parseIdentifier(); if (s1 !== peg$FAILED) { - s2 = peg$parsestring(); + s2 = peg$parseString(); if (s2 === peg$FAILED) { s2 = peg$c1; } if (s2 !== peg$FAILED) { - s3 = peg$parseequals(); + s3 = peg$parseEquals(); if (s3 !== peg$FAILED) { - s4 = peg$parsechoice(); + s4 = peg$parseChoice(); if (s4 !== peg$FAILED) { - s5 = peg$parsesemicolon(); + s5 = peg$parseSemicolon(); if (s5 === peg$FAILED) { s5 = peg$c1; } @@ -594,17 +594,17 @@ module.exports = (function() { return s0; } - function peg$parsechoice() { + function peg$parseChoice() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; - s1 = peg$parsesequence(); + s1 = peg$parseSequence(); if (s1 !== peg$FAILED) { s2 = []; s3 = peg$currPos; - s4 = peg$parseslash(); + s4 = peg$parseSlash(); if (s4 !== peg$FAILED) { - s5 = peg$parsesequence(); + s5 = peg$parseSequence(); if (s5 !== peg$FAILED) { s4 = [s4, s5]; s3 = s4; @@ -619,9 +619,9 @@ module.exports = (function() { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$currPos; - s4 = peg$parseslash(); + s4 = peg$parseSlash(); if (s4 !== peg$FAILED) { - s5 = peg$parsesequence(); + s5 = peg$parseSequence(); if (s5 !== peg$FAILED) { s4 = [s4, s5]; s3 = s4; @@ -650,22 +650,22 @@ module.exports = (function() { return s0; } - function peg$parsesequence() { + function peg$parseSequence() { var s0, s1, s2; s0 = peg$currPos; s1 = []; - s2 = peg$parselabeled(); + s2 = peg$parseLabeled(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); - s2 = peg$parselabeled(); + s2 = peg$parseLabeled(); } } else { s1 = peg$c0; } if (s1 !== peg$FAILED) { - s2 = peg$parseaction(); + s2 = peg$parseAction(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c7(s1, s2); @@ -681,11 +681,11 @@ module.exports = (function() { if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = []; - s2 = peg$parselabeled(); + s2 = peg$parseLabeled(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); - s2 = peg$parselabeled(); + s2 = peg$parseLabeled(); } } else { s1 = peg$c0; @@ -700,15 +700,15 @@ module.exports = (function() { return s0; } - function peg$parselabeled() { + function peg$parseLabeled() { var s0, s1, s2, s3; s0 = peg$currPos; - s1 = peg$parseidentifier(); + s1 = peg$parseIdentifier(); if (s1 !== peg$FAILED) { - s2 = peg$parsecolon(); + s2 = peg$parseColon(); if (s2 !== peg$FAILED) { - s3 = peg$parseprefixed(); + s3 = peg$parsePrefixed(); if (s3 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c9(s1, s3); @@ -726,19 +726,19 @@ module.exports = (function() { s0 = peg$c0; } if (s0 === peg$FAILED) { - s0 = peg$parseprefixed(); + s0 = peg$parsePrefixed(); } return s0; } - function peg$parseprefixed() { + function peg$parsePrefixed() { var s0, s1, s2; s0 = peg$currPos; - s1 = peg$parsedollar(); + s1 = peg$parseDollar(); if (s1 !== peg$FAILED) { - s2 = peg$parsesuffixed(); + s2 = peg$parseSuffixed(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c10(s2); @@ -753,9 +753,9 @@ module.exports = (function() { } if (s0 === peg$FAILED) { s0 = peg$currPos; - s1 = peg$parseand(); + s1 = peg$parseAnd(); if (s1 !== peg$FAILED) { - s2 = peg$parseaction(); + s2 = peg$parseAction(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c11(s2); @@ -770,9 +770,9 @@ module.exports = (function() { } if (s0 === peg$FAILED) { s0 = peg$currPos; - s1 = peg$parseand(); + s1 = peg$parseAnd(); if (s1 !== peg$FAILED) { - s2 = peg$parsesuffixed(); + s2 = peg$parseSuffixed(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c12(s2); @@ -787,9 +787,9 @@ module.exports = (function() { } if (s0 === peg$FAILED) { s0 = peg$currPos; - s1 = peg$parsenot(); + s1 = peg$parseNot(); if (s1 !== peg$FAILED) { - s2 = peg$parseaction(); + s2 = peg$parseAction(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c13(s2); @@ -804,9 +804,9 @@ module.exports = (function() { } if (s0 === peg$FAILED) { s0 = peg$currPos; - s1 = peg$parsenot(); + s1 = peg$parseNot(); if (s1 !== peg$FAILED) { - s2 = peg$parsesuffixed(); + s2 = peg$parseSuffixed(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c14(s2); @@ -820,7 +820,7 @@ module.exports = (function() { s0 = peg$c0; } if (s0 === peg$FAILED) { - s0 = peg$parsesuffixed(); + s0 = peg$parseSuffixed(); } } } @@ -830,13 +830,13 @@ module.exports = (function() { return s0; } - function peg$parsesuffixed() { + function peg$parseSuffixed() { var s0, s1, s2; s0 = peg$currPos; - s1 = peg$parseprimary(); + s1 = peg$parsePrimary(); if (s1 !== peg$FAILED) { - s2 = peg$parsequestion(); + s2 = peg$parseQuestion(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c15(s1); @@ -851,9 +851,9 @@ module.exports = (function() { } if (s0 === peg$FAILED) { s0 = peg$currPos; - s1 = peg$parseprimary(); + s1 = peg$parsePrimary(); if (s1 !== peg$FAILED) { - s2 = peg$parsestar(); + s2 = peg$parseStar(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c16(s1); @@ -868,9 +868,9 @@ module.exports = (function() { } if (s0 === peg$FAILED) { s0 = peg$currPos; - s1 = peg$parseprimary(); + s1 = peg$parsePrimary(); if (s1 !== peg$FAILED) { - s2 = peg$parseplus(); + s2 = peg$parsePlus(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c17(s1); @@ -884,7 +884,7 @@ module.exports = (function() { s0 = peg$c0; } if (s0 === peg$FAILED) { - s0 = peg$parseprimary(); + s0 = peg$parsePrimary(); } } } @@ -892,21 +892,21 @@ module.exports = (function() { return s0; } - function peg$parseprimary() { + function peg$parsePrimary() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; - s1 = peg$parseidentifier(); + s1 = peg$parseIdentifier(); if (s1 !== peg$FAILED) { s2 = peg$currPos; peg$silentFails++; s3 = peg$currPos; - s4 = peg$parsestring(); + s4 = peg$parseString(); if (s4 === peg$FAILED) { s4 = peg$c1; } if (s4 !== peg$FAILED) { - s5 = peg$parseequals(); + s5 = peg$parseEquals(); if (s5 !== peg$FAILED) { s4 = [s4, s5]; s3 = s4; @@ -938,12 +938,12 @@ module.exports = (function() { s0 = peg$c0; } if (s0 === peg$FAILED) { - s0 = peg$parseliteral(); + s0 = peg$parseLiteral(); if (s0 === peg$FAILED) { - s0 = peg$parseclass(); + s0 = peg$parseClass(); if (s0 === peg$FAILED) { s0 = peg$currPos; - s1 = peg$parsedot(); + s1 = peg$parseDot(); if (s1 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c20(); @@ -951,11 +951,11 @@ module.exports = (function() { s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - s1 = peg$parselparen(); + s1 = peg$parseLparen(); if (s1 !== peg$FAILED) { - s2 = peg$parsechoice(); + s2 = peg$parseChoice(); if (s2 !== peg$FAILED) { - s3 = peg$parserparen(); + s3 = peg$parseRparen(); if (s3 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c21(s2); @@ -980,12 +980,12 @@ module.exports = (function() { return s0; } - function peg$parseaction() { + function peg$parseAction() { var s0, s1, s2; peg$silentFails++; s0 = peg$currPos; - s1 = peg$parsebraced(); + s1 = peg$parseBraced(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { @@ -1009,7 +1009,7 @@ module.exports = (function() { return s0; } - function peg$parsebraced() { + function peg$parseBraced() { var s0, s1, s2, s3, s4; s0 = peg$currPos; @@ -1023,15 +1023,15 @@ module.exports = (function() { } if (s2 !== peg$FAILED) { s3 = []; - s4 = peg$parsebraced(); + s4 = peg$parseBraced(); if (s4 === peg$FAILED) { - s4 = peg$parsenonBraceCharacters(); + s4 = peg$parseNonBraceCharacters(); } while (s4 !== peg$FAILED) { s3.push(s4); - s4 = peg$parsebraced(); + s4 = peg$parseBraced(); if (s4 === peg$FAILED) { - s4 = peg$parsenonBraceCharacters(); + s4 = peg$parseNonBraceCharacters(); } } if (s3 !== peg$FAILED) { @@ -1065,15 +1065,15 @@ module.exports = (function() { return s0; } - function peg$parsenonBraceCharacters() { + function peg$parseNonBraceCharacters() { var s0, s1; s0 = []; - s1 = peg$parsenonBraceCharacter(); + s1 = peg$parseNonBraceCharacter(); if (s1 !== peg$FAILED) { while (s1 !== peg$FAILED) { s0.push(s1); - s1 = peg$parsenonBraceCharacter(); + s1 = peg$parseNonBraceCharacter(); } } else { s0 = peg$c0; @@ -1082,7 +1082,7 @@ module.exports = (function() { return s0; } - function peg$parsenonBraceCharacter() { + function peg$parseNonBraceCharacter() { var s0; if (peg$c28.test(input.charAt(peg$currPos))) { @@ -1096,7 +1096,7 @@ module.exports = (function() { return s0; } - function peg$parseequals() { + function peg$parseEquals() { var s0, s1, s2; s0 = peg$currPos; @@ -1125,7 +1125,7 @@ module.exports = (function() { return s0; } - function peg$parsecolon() { + function peg$parseColon() { var s0, s1, s2; s0 = peg$currPos; @@ -1154,7 +1154,7 @@ module.exports = (function() { return s0; } - function peg$parsesemicolon() { + function peg$parseSemicolon() { var s0, s1, s2; s0 = peg$currPos; @@ -1183,7 +1183,7 @@ module.exports = (function() { return s0; } - function peg$parseslash() { + function peg$parseSlash() { var s0, s1, s2; s0 = peg$currPos; @@ -1212,7 +1212,7 @@ module.exports = (function() { return s0; } - function peg$parseand() { + function peg$parseAnd() { var s0, s1, s2; s0 = peg$currPos; @@ -1241,7 +1241,7 @@ module.exports = (function() { return s0; } - function peg$parsenot() { + function peg$parseNot() { var s0, s1, s2; s0 = peg$currPos; @@ -1270,7 +1270,7 @@ module.exports = (function() { return s0; } - function peg$parsedollar() { + function peg$parseDollar() { var s0, s1, s2; s0 = peg$currPos; @@ -1299,7 +1299,7 @@ module.exports = (function() { return s0; } - function peg$parsequestion() { + function peg$parseQuestion() { var s0, s1, s2; s0 = peg$currPos; @@ -1328,7 +1328,7 @@ module.exports = (function() { return s0; } - function peg$parsestar() { + function peg$parseStar() { var s0, s1, s2; s0 = peg$currPos; @@ -1357,7 +1357,7 @@ module.exports = (function() { return s0; } - function peg$parseplus() { + function peg$parsePlus() { var s0, s1, s2; s0 = peg$currPos; @@ -1386,7 +1386,7 @@ module.exports = (function() { return s0; } - function peg$parselparen() { + function peg$parseLparen() { var s0, s1, s2; s0 = peg$currPos; @@ -1415,7 +1415,7 @@ module.exports = (function() { return s0; } - function peg$parserparen() { + function peg$parseRparen() { var s0, s1, s2; s0 = peg$currPos; @@ -1444,7 +1444,7 @@ module.exports = (function() { return s0; } - function peg$parsedot() { + function peg$parseDot() { var s0, s1, s2; s0 = peg$currPos; @@ -1473,14 +1473,14 @@ module.exports = (function() { return s0; } - function peg$parseidentifier() { + function peg$parseIdentifier() { var s0, s1, s2, s3, s4, s5; peg$silentFails++; s0 = peg$currPos; s1 = peg$currPos; s2 = peg$currPos; - s3 = peg$parseletter(); + s3 = peg$parseLetter(); if (s3 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 95) { s3 = peg$c70; @@ -1492,9 +1492,9 @@ module.exports = (function() { } if (s3 !== peg$FAILED) { s4 = []; - s5 = peg$parseletter(); + s5 = peg$parseLetter(); if (s5 === peg$FAILED) { - s5 = peg$parsedigit(); + s5 = peg$parseDigit(); if (s5 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 95) { s5 = peg$c70; @@ -1507,9 +1507,9 @@ module.exports = (function() { } while (s5 !== peg$FAILED) { s4.push(s5); - s5 = peg$parseletter(); + s5 = peg$parseLetter(); if (s5 === peg$FAILED) { - s5 = peg$parsedigit(); + s5 = peg$parseDigit(); if (s5 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 95) { s5 = peg$c70; @@ -1559,14 +1559,14 @@ module.exports = (function() { return s0; } - function peg$parseliteral() { + function peg$parseLiteral() { var s0, s1, s2, s3; peg$silentFails++; s0 = peg$currPos; - s1 = peg$parsedoubleQuotedString(); + s1 = peg$parseDoubleQuotedString(); if (s1 === peg$FAILED) { - s1 = peg$parsesingleQuotedString(); + s1 = peg$parseSingleQuotedString(); } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 105) { @@ -1606,14 +1606,14 @@ module.exports = (function() { return s0; } - function peg$parsestring() { + function peg$parseString() { var s0, s1, s2; peg$silentFails++; s0 = peg$currPos; - s1 = peg$parsedoubleQuotedString(); + s1 = peg$parseDoubleQuotedString(); if (s1 === peg$FAILED) { - s1 = peg$parsesingleQuotedString(); + s1 = peg$parseSingleQuotedString(); } if (s1 !== peg$FAILED) { s2 = peg$parse__(); @@ -1638,7 +1638,7 @@ module.exports = (function() { return s0; } - function peg$parsedoubleQuotedString() { + function peg$parseDoubleQuotedString() { var s0, s1, s2, s3; s0 = peg$currPos; @@ -1651,10 +1651,10 @@ module.exports = (function() { } if (s1 !== peg$FAILED) { s2 = []; - s3 = peg$parsedoubleQuotedCharacter(); + s3 = peg$parseDoubleQuotedCharacter(); while (s3 !== peg$FAILED) { s2.push(s3); - s3 = peg$parsedoubleQuotedCharacter(); + s3 = peg$parseDoubleQuotedCharacter(); } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { @@ -1684,20 +1684,20 @@ module.exports = (function() { return s0; } - function peg$parsedoubleQuotedCharacter() { + function peg$parseDoubleQuotedCharacter() { var s0; - s0 = peg$parsesimpleDoubleQuotedCharacter(); + s0 = peg$parseSimpleDoubleQuotedCharacter(); if (s0 === peg$FAILED) { - s0 = peg$parsesimpleEscapeSequence(); + s0 = peg$parseSimpleEscapeSequence(); if (s0 === peg$FAILED) { - s0 = peg$parsezeroEscapeSequence(); + s0 = peg$parseZeroEscapeSequence(); if (s0 === peg$FAILED) { - s0 = peg$parsehexEscapeSequence(); + s0 = peg$parseHexEscapeSequence(); if (s0 === peg$FAILED) { - s0 = peg$parseunicodeEscapeSequence(); + s0 = peg$parseUnicodeEscapeSequence(); if (s0 === peg$FAILED) { - s0 = peg$parseeolEscapeSequence(); + s0 = peg$parseEOLEscapeSequence(); } } } @@ -1707,7 +1707,7 @@ module.exports = (function() { return s0; } - function peg$parsesimpleDoubleQuotedCharacter() { + function peg$parseSimpleDoubleQuotedCharacter() { var s0, s1, s2; s0 = peg$currPos; @@ -1729,7 +1729,7 @@ module.exports = (function() { if (peg$silentFails === 0) { peg$fail(peg$c83); } } if (s2 === peg$FAILED) { - s2 = peg$parseeolChar(); + s2 = peg$parseEOLChar(); } } peg$silentFails--; @@ -1763,7 +1763,7 @@ module.exports = (function() { return s0; } - function peg$parsesingleQuotedString() { + function peg$parseSingleQuotedString() { var s0, s1, s2, s3; s0 = peg$currPos; @@ -1776,10 +1776,10 @@ module.exports = (function() { } if (s1 !== peg$FAILED) { s2 = []; - s3 = peg$parsesingleQuotedCharacter(); + s3 = peg$parseSingleQuotedCharacter(); while (s3 !== peg$FAILED) { s2.push(s3); - s3 = peg$parsesingleQuotedCharacter(); + s3 = peg$parseSingleQuotedCharacter(); } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 39) { @@ -1809,20 +1809,20 @@ module.exports = (function() { return s0; } - function peg$parsesingleQuotedCharacter() { + function peg$parseSingleQuotedCharacter() { var s0; - s0 = peg$parsesimpleSingleQuotedCharacter(); + s0 = peg$parseSimpleSingleQuotedCharacter(); if (s0 === peg$FAILED) { - s0 = peg$parsesimpleEscapeSequence(); + s0 = peg$parseSimpleEscapeSequence(); if (s0 === peg$FAILED) { - s0 = peg$parsezeroEscapeSequence(); + s0 = peg$parseZeroEscapeSequence(); if (s0 === peg$FAILED) { - s0 = peg$parsehexEscapeSequence(); + s0 = peg$parseHexEscapeSequence(); if (s0 === peg$FAILED) { - s0 = peg$parseunicodeEscapeSequence(); + s0 = peg$parseUnicodeEscapeSequence(); if (s0 === peg$FAILED) { - s0 = peg$parseeolEscapeSequence(); + s0 = peg$parseEOLEscapeSequence(); } } } @@ -1832,7 +1832,7 @@ module.exports = (function() { return s0; } - function peg$parsesimpleSingleQuotedCharacter() { + function peg$parseSimpleSingleQuotedCharacter() { var s0, s1, s2; s0 = peg$currPos; @@ -1854,7 +1854,7 @@ module.exports = (function() { if (peg$silentFails === 0) { peg$fail(peg$c83); } } if (s2 === peg$FAILED) { - s2 = peg$parseeolChar(); + s2 = peg$parseEOLChar(); } } peg$silentFails--; @@ -1888,7 +1888,7 @@ module.exports = (function() { return s0; } - function peg$parseclass() { + function peg$parseClass() { var s0, s1, s2, s3, s4, s5, s6; peg$silentFails++; @@ -1914,15 +1914,15 @@ module.exports = (function() { } if (s3 !== peg$FAILED) { s4 = []; - s5 = peg$parseclassCharacterRange(); + s5 = peg$parseClassCharacterRange(); if (s5 === peg$FAILED) { - s5 = peg$parsebracketDelimitedCharacter(); + s5 = peg$parseBracketDelimitedCharacter(); } while (s5 !== peg$FAILED) { s4.push(s5); - s5 = peg$parseclassCharacterRange(); + s5 = peg$parseClassCharacterRange(); if (s5 === peg$FAILED) { - s5 = peg$parsebracketDelimitedCharacter(); + s5 = peg$parseBracketDelimitedCharacter(); } } if (s4 !== peg$FAILED) { @@ -1991,11 +1991,11 @@ module.exports = (function() { return s0; } - function peg$parseclassCharacterRange() { + function peg$parseClassCharacterRange() { var s0, s1, s2, s3; s0 = peg$currPos; - s1 = peg$parsebracketDelimitedCharacter(); + s1 = peg$parseBracketDelimitedCharacter(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 45) { s2 = peg$c97; @@ -2005,7 +2005,7 @@ module.exports = (function() { if (peg$silentFails === 0) { peg$fail(peg$c98); } } if (s2 !== peg$FAILED) { - s3 = peg$parsebracketDelimitedCharacter(); + s3 = peg$parseBracketDelimitedCharacter(); if (s3 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c99(s1, s3); @@ -2026,20 +2026,20 @@ module.exports = (function() { return s0; } - function peg$parsebracketDelimitedCharacter() { + function peg$parseBracketDelimitedCharacter() { var s0; - s0 = peg$parsesimpleBracketDelimitedCharacter(); + s0 = peg$parseSimpleBracketDelimitedCharacter(); if (s0 === peg$FAILED) { - s0 = peg$parsesimpleEscapeSequence(); + s0 = peg$parseSimpleEscapeSequence(); if (s0 === peg$FAILED) { - s0 = peg$parsezeroEscapeSequence(); + s0 = peg$parseZeroEscapeSequence(); if (s0 === peg$FAILED) { - s0 = peg$parsehexEscapeSequence(); + s0 = peg$parseHexEscapeSequence(); if (s0 === peg$FAILED) { - s0 = peg$parseunicodeEscapeSequence(); + s0 = peg$parseUnicodeEscapeSequence(); if (s0 === peg$FAILED) { - s0 = peg$parseeolEscapeSequence(); + s0 = peg$parseEOLEscapeSequence(); } } } @@ -2049,7 +2049,7 @@ module.exports = (function() { return s0; } - function peg$parsesimpleBracketDelimitedCharacter() { + function peg$parseSimpleBracketDelimitedCharacter() { var s0, s1, s2; s0 = peg$currPos; @@ -2071,7 +2071,7 @@ module.exports = (function() { if (peg$silentFails === 0) { peg$fail(peg$c83); } } if (s2 === peg$FAILED) { - s2 = peg$parseeolChar(); + s2 = peg$parseEOLChar(); } } peg$silentFails--; @@ -2105,7 +2105,7 @@ module.exports = (function() { return s0; } - function peg$parsesimpleEscapeSequence() { + function peg$parseSimpleEscapeSequence() { var s0, s1, s2, s3; s0 = peg$currPos; @@ -2119,7 +2119,7 @@ module.exports = (function() { if (s1 !== peg$FAILED) { s2 = peg$currPos; peg$silentFails++; - s3 = peg$parsedigit(); + s3 = peg$parseDigit(); if (s3 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 120) { s3 = peg$c100; @@ -2137,7 +2137,7 @@ module.exports = (function() { if (peg$silentFails === 0) { peg$fail(peg$c103); } } if (s3 === peg$FAILED) { - s3 = peg$parseeolChar(); + s3 = peg$parseEOLChar(); } } } @@ -2176,7 +2176,7 @@ module.exports = (function() { return s0; } - function peg$parsezeroEscapeSequence() { + function peg$parseZeroEscapeSequence() { var s0, s1, s2, s3; s0 = peg$currPos; @@ -2190,7 +2190,7 @@ module.exports = (function() { if (s1 !== peg$FAILED) { s2 = peg$currPos; peg$silentFails++; - s3 = peg$parsedigit(); + s3 = peg$parseDigit(); peg$silentFails--; if (s3 === peg$FAILED) { s2 = peg$c18; @@ -2214,7 +2214,7 @@ module.exports = (function() { return s0; } - function peg$parsehexEscapeSequence() { + function peg$parseHexEscapeSequence() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; @@ -2228,9 +2228,9 @@ module.exports = (function() { if (s1 !== peg$FAILED) { s2 = peg$currPos; s3 = peg$currPos; - s4 = peg$parsehexDigit(); + s4 = peg$parseHexDigit(); if (s4 !== peg$FAILED) { - s5 = peg$parsehexDigit(); + s5 = peg$parseHexDigit(); if (s5 !== peg$FAILED) { s4 = [s4, s5]; s3 = s4; @@ -2262,7 +2262,7 @@ module.exports = (function() { return s0; } - function peg$parseunicodeEscapeSequence() { + function peg$parseUnicodeEscapeSequence() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; @@ -2276,13 +2276,13 @@ module.exports = (function() { if (s1 !== peg$FAILED) { s2 = peg$currPos; s3 = peg$currPos; - s4 = peg$parsehexDigit(); + s4 = peg$parseHexDigit(); if (s4 !== peg$FAILED) { - s5 = peg$parsehexDigit(); + s5 = peg$parseHexDigit(); if (s5 !== peg$FAILED) { - s6 = peg$parsehexDigit(); + s6 = peg$parseHexDigit(); if (s6 !== peg$FAILED) { - s7 = peg$parsehexDigit(); + s7 = peg$parseHexDigit(); if (s7 !== peg$FAILED) { s4 = [s4, s5, s6, s7]; s3 = s4; @@ -2322,7 +2322,7 @@ module.exports = (function() { return s0; } - function peg$parseeolEscapeSequence() { + function peg$parseEOLEscapeSequence() { var s0, s1, s2; s0 = peg$currPos; @@ -2334,7 +2334,7 @@ module.exports = (function() { if (peg$silentFails === 0) { peg$fail(peg$c83); } } if (s1 !== peg$FAILED) { - s2 = peg$parseeol(); + s2 = peg$parseEOL(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; s1 = peg$c113(s2); @@ -2351,7 +2351,7 @@ module.exports = (function() { return s0; } - function peg$parsedigit() { + function peg$parseDigit() { var s0; if (peg$c114.test(input.charAt(peg$currPos))) { @@ -2365,7 +2365,7 @@ module.exports = (function() { return s0; } - function peg$parsehexDigit() { + function peg$parseHexDigit() { var s0; if (peg$c116.test(input.charAt(peg$currPos))) { @@ -2379,18 +2379,18 @@ module.exports = (function() { return s0; } - function peg$parseletter() { + function peg$parseLetter() { var s0; - s0 = peg$parselowerCaseLetter(); + s0 = peg$parseLowerCaseLetter(); if (s0 === peg$FAILED) { - s0 = peg$parseupperCaseLetter(); + s0 = peg$parseUpperCaseLetter(); } return s0; } - function peg$parselowerCaseLetter() { + function peg$parseLowerCaseLetter() { var s0; if (peg$c118.test(input.charAt(peg$currPos))) { @@ -2404,7 +2404,7 @@ module.exports = (function() { return s0; } - function peg$parseupperCaseLetter() { + function peg$parseUpperCaseLetter() { var s0; if (peg$c120.test(input.charAt(peg$currPos))) { @@ -2422,20 +2422,20 @@ module.exports = (function() { var s0, s1; s0 = []; - s1 = peg$parsewhitespace(); + s1 = peg$parseWhitespace(); if (s1 === peg$FAILED) { - s1 = peg$parseeol(); + s1 = peg$parseEOL(); if (s1 === peg$FAILED) { - s1 = peg$parsecomment(); + s1 = peg$parseComment(); } } while (s1 !== peg$FAILED) { s0.push(s1); - s1 = peg$parsewhitespace(); + s1 = peg$parseWhitespace(); if (s1 === peg$FAILED) { - s1 = peg$parseeol(); + s1 = peg$parseEOL(); if (s1 === peg$FAILED) { - s1 = peg$parsecomment(); + s1 = peg$parseComment(); } } } @@ -2443,13 +2443,13 @@ module.exports = (function() { return s0; } - function peg$parsecomment() { + function peg$parseComment() { var s0, s1; peg$silentFails++; - s0 = peg$parsesingleLineComment(); + s0 = peg$parseSingleLineComment(); if (s0 === peg$FAILED) { - s0 = peg$parsemultiLineComment(); + s0 = peg$parseMultiLineComment(); } peg$silentFails--; if (s0 === peg$FAILED) { @@ -2460,7 +2460,7 @@ module.exports = (function() { return s0; } - function peg$parsesingleLineComment() { + function peg$parseSingleLineComment() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; @@ -2476,7 +2476,7 @@ module.exports = (function() { s3 = peg$currPos; s4 = peg$currPos; peg$silentFails++; - s5 = peg$parseeolChar(); + s5 = peg$parseEOLChar(); peg$silentFails--; if (s5 === peg$FAILED) { s4 = peg$c18; @@ -2508,7 +2508,7 @@ module.exports = (function() { s3 = peg$currPos; s4 = peg$currPos; peg$silentFails++; - s5 = peg$parseeolChar(); + s5 = peg$parseEOLChar(); peg$silentFails--; if (s5 === peg$FAILED) { s4 = peg$c18; @@ -2551,7 +2551,7 @@ module.exports = (function() { return s0; } - function peg$parsemultiLineComment() { + function peg$parseMultiLineComment() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; @@ -2666,7 +2666,7 @@ module.exports = (function() { return s0; } - function peg$parseeol() { + function peg$parseEOL() { var s0, s1; peg$silentFails++; @@ -2722,7 +2722,7 @@ module.exports = (function() { return s0; } - function peg$parseeolChar() { + function peg$parseEOLChar() { var s0; if (peg$c140.test(input.charAt(peg$currPos))) { @@ -2736,7 +2736,7 @@ module.exports = (function() { return s0; } - function peg$parsewhitespace() { + function peg$parseWhitespace() { var s0, s1; peg$silentFails++; diff --git a/spec/parser.spec.js b/spec/parser.spec.js index f5f651b..7424ccf 100644 --- a/spec/parser.spec.js +++ b/spec/parser.spec.js @@ -161,8 +161,8 @@ describe("PEG.js grammar parser", function() { }); }); - /* Canonical grammar is "a = \"abcd\"; b = \"efgh\"; c = \"ijkl\";". */ - it("parses grammar", function() { + /* Canonical Grammar is "a = \"abcd\"; b = \"efgh\"; c = \"ijkl\";". */ + it("parses Grammar", function() { var ruleA = { type: "rule", name: "a", expression: literalAbcd }, ruleB = { type: "rule", name: "b", expression: literalEfgh }, ruleC = { type: "rule", name: "c", expression: literalIjkl }; @@ -184,8 +184,8 @@ describe("PEG.js grammar parser", function() { }); }); - /* Canonical initializer is "{ code }". */ - it("parses initializer", function() { + /* Canonical Initializer is "{ code }". */ + it("parses Initializer", function() { var grammar = oneRuleGrammar(literalAbcd, { type: "initializer", code: " code " @@ -195,8 +195,8 @@ describe("PEG.js grammar parser", function() { expect('{ code }; start = "abcd"').toParseAs(grammar); }); - /* Canonical rule is "a: \"abcd\"". */ - it("parses rule", function() { + /* Canonical Rule is "a: \"abcd\"". */ + it("parses Rule", function() { expect('start = "abcd" / "efgh" / "ijkl"').toParseAs( oneRuleGrammar(choiceOfLiterals) ); @@ -212,15 +212,15 @@ describe("PEG.js grammar parser", function() { ); }); - /* Canonical expression is "\"abcd\" / \"efgh\" / \"ijkl\"". */ - it("parses expression", function() { + /* Canonical Expression is "\"abcd\" / \"efgh\" / \"ijkl\"". */ + it("parses Expression", function() { expect('start = "abcd" / "efgh" / "ijkl"').toParseAs( oneRuleGrammar(choiceOfLiterals) ); }); - /* Canonical choice is "\"abcd\" / \"efgh\" / \"ijkl\"". */ - it("parses choice", function() { + /* Canonical Choice is "\"abcd\" / \"efgh\" / \"ijkl\"". */ + it("parses Choice", function() { expect('start = "abcd" "efgh" "ijkl"').toParseAs( oneRuleGrammar(sequenceOfLiterals) ); @@ -232,8 +232,8 @@ describe("PEG.js grammar parser", function() { })); }); - /* Canonical sequence is "\"abcd\" \"efgh\" \"ijkl\"". */ - it("parses sequence", function() { + /* Canonical Sequence is "\"abcd\" \"efgh\" \"ijkl\"". */ + it("parses Sequence", function() { expect('start = a:"abcd" { code }').toParseAs( oneRuleGrammar({ type: "action", expression: labeledAbcd, code: " code " }) ); @@ -253,8 +253,8 @@ describe("PEG.js grammar parser", function() { ); }); - /* Canonical labeled is "label:\"abcd\"". */ - it("parses labeled", function() { + /* Canonical Labeled is "label:\"abcd\"". */ + it("parses Labeled", function() { expect('start = label:!"abcd"').toParseAs(oneRuleGrammar({ type: "labeled", label: "label", @@ -263,8 +263,8 @@ describe("PEG.js grammar parser", function() { expect('start = !"abcd"' ).toParseAs(oneRuleGrammar(simpleNotLiteral)); }); - /* Canonical prefixed is "!\"abcd\"". */ - it("parses prefixed", function() { + /* Canonical Prefixed is "!\"abcd\"". */ + it("parses Prefixed", function() { expect('start = $"abcd"?' ).toParseAs(oneRuleGrammar({ type: "text", expression: optionalLiteral @@ -288,8 +288,8 @@ describe("PEG.js grammar parser", function() { expect('start = "abcd"?' ).toParseAs(oneRuleGrammar(optionalLiteral)); }); - /* Canonical suffixed is "\"abcd\"?". */ - it("parses suffixed", function() { + /* Canonical Suffixed is "\"abcd\"?". */ + it("parses Suffixed", function() { expect('start = "abcd"?').toParseAs(oneRuleGrammar(optionalLiteral)); expect('start = "abcd"*').toParseAs(oneRuleGrammar({ type: "zero_or_more", @@ -302,8 +302,8 @@ describe("PEG.js grammar parser", function() { expect('start = "abcd"' ).toParseAs(literalGrammar("abcd")); }); - /* Canonical primary is "\"abcd\"". */ - it("parses primary", function() { + /* Canonical Primary is "\"abcd\"". */ + it("parses Primary", function() { expect('start = a' ).toParseAs(ruleRefGrammar("a")); expect('start = "abcd"' ).toParseAs(literalGrammar("abcd")); expect('start = [a-d]' ).toParseAs(classGrammar([["a", "d"]], "[a-d]")); @@ -311,29 +311,29 @@ describe("PEG.js grammar parser", function() { expect('start = ("abcd")').toParseAs(literalGrammar("abcd")); }); - /* Canonical action is "{ code }". */ - it("parses action", function() { + /* Canonical Action is "{ code }". */ + it("parses Action", function() { expect('start = "abcd" { code }').toParseAs(actionGrammar(" code ")); expect('start = "abcd" { code }\n').toParseAs(actionGrammar(" code ")); }); - /* Canonical braced is "{ code }". */ - it("parses braced", function() { + /* Canonical Braced is "{ code }". */ + it("parses Braced", function() { 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}")); }); - /* Canonical nonBraceCharacters is "abcd". */ - it("parses nonBraceCharacters", function() { + /* Canonical NonBraceCharacters is "abcd". */ + it("parses NonBraceCharacters", function() { expect('start = "abcd" {a}' ).toParseAs(actionGrammar("a")); expect('start = "abcd" {abc}').toParseAs(actionGrammar("abc")); }); - /* Canonical nonBraceCharacter is "a". */ - it("parses nonBraceCharacter", function() { + /* Canonical NonBraceCharacter is "a". */ + it("parses NonBraceCharacter", function() { expect('start = "abcd" {a}').toParseAs(actionGrammar("a")); expect('start = "abcd" {{}').toFailToParse(); @@ -342,8 +342,8 @@ describe("PEG.js grammar parser", function() { /* Trivial character rules are not tested. */ - /* Canonical identifier is "a". */ - it("parses identifier", function() { + /* Canonical Identifier is "a". */ + it("parses Identifier", function() { expect('start = a' ).toParseAs(ruleRefGrammar("a")); expect('start = _' ).toParseAs(ruleRefGrammar("_")); expect('start = aa' ).toParseAs(ruleRefGrammar("aa")); @@ -354,8 +354,8 @@ describe("PEG.js grammar parser", function() { expect('start = a\n').toParseAs(ruleRefGrammar("a")); }); - /* Canonical literal is "\"abcd\"". */ - it("parses literal", function() { + /* Canonical Literal is "\"abcd\"". */ + it("parses Literal", function() { expect('start = "abcd"' ).toParseAs(literalGrammar("abcd")); expect("start = 'abcd'" ).toParseAs(literalGrammar("abcd")); @@ -364,8 +364,8 @@ describe("PEG.js grammar parser", function() { expect('start = "abcd"\n').toParseAs(literalGrammar("abcd")); }); - /* Canonical string is "\"abcd\"". */ - it("parses string", function() { + /* Canonical String is "\"abcd\"". */ + it("parses String", function() { var grammar = oneRuleGrammar({ type: "named", name: "abcd", @@ -378,15 +378,15 @@ describe("PEG.js grammar parser", function() { expect('start "abcd"\n= "abcd"').toParseAs(grammar); }); - /* Canonical doubleQuotedString is "\"abcd\"". */ - it("parses doubleQuotedString", function() { + /* Canonical DoubleQuotedString is "\"abcd\"". */ + it("parses DoubleQuotedString", function() { expect('start = ""' ).toParseAs(literalGrammar("")); expect('start = "a"' ).toParseAs(literalGrammar("a")); expect('start = "abc"').toParseAs(literalGrammar("abc")); }); - /* Canonical doubleQuotedCharacter is "a". */ - it("parses doubleQuotedCharacter", function() { + /* Canonical DoubleQuotedCharacter is "a". */ + it("parses DoubleQuotedCharacter", function() { expect('start = "a"' ).toParseAs(literalGrammar("a")); expect('start = "\\n"' ).toParseAs(literalGrammar("\n")); expect('start = "\\0"' ).toParseAs(literalGrammar("\x00")); @@ -395,8 +395,8 @@ describe("PEG.js grammar parser", function() { expect('start = "\\\n"' ).toParseAs(literalGrammar("")); }); - /* Canonical simpleDoubleQuotedCharacter is "a". */ - it("parses simpleDoubleQuotedCharacter", function() { + /* Canonical SimpleDoubleQuotedCharacter is "a". */ + it("parses SimpleDoubleQuotedCharacter", function() { expect('start = "a"').toParseAs(literalGrammar("a")); expect('start = """' ).toFailToParse(); @@ -404,15 +404,15 @@ describe("PEG.js grammar parser", function() { expect('start = "\n"').toFailToParse(); }); - /* Canonical singleQuotedString is "'abcd'". */ - it("parses singleQuotedString", function() { + /* Canonical SingleQuotedString is "'abcd'". */ + it("parses SingleQuotedString", function() { expect("start = ''" ).toParseAs(literalGrammar("")); expect("start = 'a'" ).toParseAs(literalGrammar("a")); expect("start = 'abc'").toParseAs(literalGrammar("abc")); }); - /* Canonical singleQuotedCharacter is "a". */ - it("parses singleQuotedCharacter", function() { + /* Canonical SingleQuotedCharacter is "a". */ + it("parses SingleQuotedCharacter", function() { expect("start = 'a'" ).toParseAs(literalGrammar("a")); expect("start = '\\n'" ).toParseAs(literalGrammar("\n")); expect("start = '\\0'" ).toParseAs(literalGrammar("\x00")); @@ -421,8 +421,8 @@ describe("PEG.js grammar parser", function() { expect("start = '\\\n'" ).toParseAs(literalGrammar("")); }); - /* Canonical simpleSingleQuotedCharacter is "a". */ - it("parses simpleSingleQuotedCharacter", function() { + /* Canonical SimpleSingleQuotedCharacter is "a". */ + it("parses SimpleSingleQuotedCharacter", function() { expect("start = 'a'").toParseAs(literalGrammar("a")); expect("start = '''" ).toFailToParse(); @@ -430,8 +430,8 @@ describe("PEG.js grammar parser", function() { expect("start = '\n'").toFailToParse(); }); - /* Canonical class is "[a-d]". */ - it("parses class", function() { + /* Canonical Class is "[a-d]". */ + it("parses Class", function() { expect('start = []' ).toParseAs(classGrammar([], "[]")); expect('start = [a-d]' ).toParseAs(classGrammar([["a", "d"]], "[a-d]")); expect('start = [a]' ).toParseAs(classGrammar(["a"], "[a]")); @@ -449,8 +449,8 @@ describe("PEG.js grammar parser", function() { expect('start = [a-d]\n').toParseAs(classGrammar([["a", "d"]], "[a-d]")); }); - /* Canonical classCharacterRange is "a-d". */ - it("parses classCharacterRange", function() { + /* Canonical ClassCharacterRange is "a-d". */ + it("parses ClassCharacterRange", function() { expect('start = [a-d]').toParseAs(classGrammar([["a", "d"]], "[a-d]")); expect('start = [a-a]').toParseAs(classGrammar([["a", "a"]], "[a-a]")); @@ -459,13 +459,13 @@ describe("PEG.js grammar parser", function() { }); }); - /* Canonical classCharacter is "a". */ - it("parses classCharacter", function() { + /* Canonical ClassCharacter is "a". */ + it("parses ClassCharacter", function() { expect('start = [a]').toParseAs(classGrammar(["a"], "[a]")); }); - /* Canonical bracketDelimitedCharacter is "a". */ - it("parses bracketDelimitedCharacter", function() { + /* Canonical BracketDelimitedCharacter is "a". */ + it("parses BracketDelimitedCharacter", function() { expect('start = [a]' ).toParseAs(classGrammar(["a"], "[a]")); expect('start = [\\n]' ).toParseAs(classGrammar(["\n"], "[\\n]")); expect('start = [\\0]' ).toParseAs(classGrammar(["\x00"], "[\\0]")); @@ -474,8 +474,8 @@ describe("PEG.js grammar parser", function() { expect('start = [\\\n]' ).toParseAs(classGrammar([""], "[\\\n]")); }); - /* Canonical simpleBracketDelimiedCharacter is "a". */ - it("parses simpleBracketDelimitedCharacter", function() { + /* Canonical SimpleBracketDelimiedCharacter is "a". */ + it("parses SimpleBracketDelimitedCharacter", function() { expect('start = [a]').toParseAs(classGrammar(["a"], "[a]")); expect('start = []]' ).toFailToParse(); @@ -483,8 +483,8 @@ describe("PEG.js grammar parser", function() { expect('start = [\n]').toFailToParse(); }); - /* Canonical simpleEscapeSequence is "\\n". */ - it("parses simpleEscapeSequence", function() { + /* Canonical SimpleEscapeSequence is "\\n". */ + it("parses SimpleEscapeSequence", function() { expect('start = "\\b"').toParseAs(literalGrammar("\b")); expect('start = "\\f"').toParseAs(literalGrammar("\f")); expect('start = "\\n"').toParseAs(literalGrammar("\n")); @@ -498,26 +498,26 @@ describe("PEG.js grammar parser", function() { expect('start = "\\u"').toFailToParse(); }); - /* Canonical zeroEscapeSequence is "\\0". */ - it("parses zeroEscapeSequence", function() { + /* Canonical ZeroEscapeSequence is "\\0". */ + it("parses ZeroEscapeSequence", function() { expect('start = "\\0"').toParseAs(literalGrammar("\x00")); expect('start = "\\00"').toFailToParse(); expect('start = "\\09"').toFailToParse(); }); - /* Canonical hexEscapeSequence is "\\xFF". */ - it("parses hexEscapeSequence", function() { + /* Canonical HexEscapeSequence is "\\xFF". */ + it("parses HexEscapeSequence", function() { expect('start = "\\xFF"').toParseAs(literalGrammar("\xFF")); }); - /* Canonical unicodeEscapeSequence is "\\uFFFF". */ - it("parses unicodeEscapeSequence", function() { + /* Canonical UnicodeEscapeSequence is "\\uFFFF". */ + it("parses UnicodeEscapeSequence", function() { expect('start = "\\uFFFF"').toParseAs(literalGrammar("\uFFFF")); }); - /* Canonical eolEscapeSequence is "\\\n". */ - it("parses eolEscapeSequence", function() { + /* Canonical EOLEscapeSequence is "\\\n". */ + it("parses EOLEscapeSequence", function() { expect('start = "\\\n"' ).toParseAs(literalGrammar("")); }); @@ -532,21 +532,21 @@ describe("PEG.js grammar parser", function() { expect('start = "abcd"' ).toParseAs(trivialGrammar); }); - // Canonical comment is "/* comment */". - it("parses comment", function() { + // Canonical Comment is "/* comment */". + it("parses Comment", function() { expect('start =// comment\n"abcd"' ).toParseAs(trivialGrammar); expect('start =/* comment */"abcd"').toParseAs(trivialGrammar); }); - /* Canonical singleLineComment is "// comment". */ - it("parses singleLineComment", function() { + /* Canonical SingleLineComment is "// comment". */ + it("parses SingleLineComment", function() { expect('start =//\n"abcd"' ).toParseAs(trivialGrammar); expect('start =//a\n"abcd"' ).toParseAs(trivialGrammar); expect('start =//aaa\n"abcd"').toParseAs(trivialGrammar); }); - // Canonical multiLineComment is "/* comment */". - it("parses multiLineComment", function() { + // Canonical MultiLineComment is "/* comment */". + it("parses MultiLineComment", function() { expect('start =/**/"abcd"' ).toParseAs(trivialGrammar); expect('start =/*a*/"abcd"' ).toParseAs(trivialGrammar); expect('start =/*aaa*/"abcd"').toParseAs(trivialGrammar); @@ -555,8 +555,8 @@ describe("PEG.js grammar parser", function() { expect('start =/**/*/"abcd"').toFailToParse(); }); - /* Canonical eol is "\n". */ - it("parses eol", function() { + /* Canonical EOL is "\n". */ + it("parses EOL", function() { expect('start =\n"abcd"' ).toParseAs(trivialGrammar); expect('start =\r\n"abcd"' ).toParseAs(trivialGrammar); expect('start =\r"abcd"' ).toParseAs(trivialGrammar); @@ -564,16 +564,16 @@ describe("PEG.js grammar parser", function() { expect('start =\u2029"abcd"').toParseAs(trivialGrammar); }); - /* Canonical eolChar is "\n". */ - it("parses eolChar", function() { + /* Canonical EOLChar is "\n". */ + it("parses EOLChar", function() { expect('start =\n"abcd"' ).toParseAs(trivialGrammar); expect('start =\r"abcd"' ).toParseAs(trivialGrammar); expect('start =\u2028"abcd"').toParseAs(trivialGrammar); expect('start =\u2029"abcd"').toParseAs(trivialGrammar); }); - /* Canonical whitespace is " ". */ - it("parses whitespace", function() { + /* Canonical Whitespace is " ". */ + it("parses Whitespace", function() { expect('start =\t"abcd"' ).toParseAs(trivialGrammar); expect('start =\x0B"abcd"' ).toParseAs(trivialGrammar); // no "\v" in IE expect('start =\f"abcd"' ).toParseAs(trivialGrammar); diff --git a/src/parser.pegjs b/src/parser.pegjs index 2b9fc22..bddb4ae 100644 --- a/src/parser.pegjs +++ b/src/parser.pegjs @@ -2,8 +2,8 @@ var utils = require("./utils"); } -grammar - = __ initializer:initializer? rules:rule+ { +Grammar + = __ initializer:Initializer? rules:Rule+ { return { type: "grammar", initializer: initializer, @@ -11,16 +11,16 @@ grammar }; } -initializer - = code:action semicolon? { +Initializer + = code:Action Semicolon? { return { type: "initializer", code: code }; } -rule - = name:identifier displayName:string? equals expression:expression semicolon? { +Rule + = name:Identifier displayName:String? Equals expression:Expression Semicolon? { return { type: "rule", name: name, @@ -34,11 +34,11 @@ rule }; } -expression - = choice +Expression + = Choice -choice - = head:sequence tail:(slash sequence)* { +Choice + = head:Sequence tail:(Slash Sequence)* { if (tail.length > 0) { var alternatives = [head].concat(utils.map( tail, @@ -53,8 +53,8 @@ choice } } -sequence - = elements:labeled+ code:action { +Sequence + = elements:Labeled+ code:Action { var expression = elements.length !== 1 ? { type: "sequence", @@ -67,7 +67,7 @@ sequence code: code }; } - / elements:labeled+ { + / elements:Labeled+ { return elements.length !== 1 ? { type: "sequence", @@ -76,109 +76,109 @@ sequence : elements[0]; } -labeled - = label:identifier colon expression:prefixed { +Labeled + = label:Identifier Colon expression:Prefixed { return { type: "labeled", label: label, expression: expression }; } - / prefixed + / Prefixed -prefixed - = dollar expression:suffixed { +Prefixed + = Dollar expression:Suffixed { return { type: "text", expression: expression }; } - / and code:action { + / And code:Action { return { type: "semantic_and", code: code }; } - / and expression:suffixed { + / And expression:Suffixed { return { type: "simple_and", expression: expression }; } - / not code:action { + / Not code:Action { return { type: "semantic_not", code: code }; } - / not expression:suffixed { + / Not expression:Suffixed { return { type: "simple_not", expression: expression }; } - / suffixed + / Suffixed -suffixed - = expression:primary question { +Suffixed + = expression:Primary Question { return { type: "optional", expression: expression }; } - / expression:primary star { + / expression:Primary Star { return { type: "zero_or_more", expression: expression }; } - / expression:primary plus { + / expression:Primary Plus { return { type: "one_or_more", expression: expression }; } - / primary + / Primary -primary - = name:identifier !(string? equals) { +Primary + = name:Identifier !(String? Equals) { return { type: "rule_ref", name: name }; } - / literal - / class - / dot { return { type: "any" }; } - / lparen expression:expression rparen { return expression; } + / Literal + / Class + / Dot { return { type: "any" }; } + / Lparen expression:Expression Rparen { return expression; } /* "Lexical" elements */ -action "action" - = braced:braced __ { return braced.substr(1, braced.length - 2); } +Action "action" + = braced:Braced __ { return braced.substr(1, braced.length - 2); } -braced - = $("{" (braced / nonBraceCharacters)* "}") +Braced + = $("{" (Braced / NonBraceCharacters)* "}") -nonBraceCharacters - = nonBraceCharacter+ +NonBraceCharacters + = NonBraceCharacter+ -nonBraceCharacter +NonBraceCharacter = [^{}] -equals = "=" __ { return "="; } -colon = ":" __ { return ":"; } -semicolon = ";" __ { return ";"; } -slash = "/" __ { return "/"; } -and = "&" __ { return "&"; } -not = "!" __ { return "!"; } -dollar = "$" __ { return "$"; } -question = "?" __ { return "?"; } -star = "*" __ { return "*"; } -plus = "+" __ { return "+"; } -lparen = "(" __ { return "("; } -rparen = ")" __ { return ")"; } -dot = "." __ { return "."; } +Equals = "=" __ { return "="; } +Colon = ":" __ { return ":"; } +Semicolon = ";" __ { return ";"; } +Slash = "/" __ { return "/"; } +And = "&" __ { return "&"; } +Not = "!" __ { return "!"; } +Dollar = "$" __ { return "$"; } +Question = "?" __ { return "?"; } +Star = "*" __ { return "*"; } +Plus = "+" __ { return "+"; } +Lparen = "(" __ { return "("; } +Rparen = ")" __ { return ")"; } +Dot = "." __ { return "."; } /* * Modeled after ECMA-262, 5th ed., 7.6, but much simplified: @@ -198,15 +198,15 @@ dot = "." __ { return "."; } * Contrary to ECMA 262, the "$" character is not valid because it serves other * purpose in the grammar. */ -identifier "identifier" - = chars:$((letter / "_") (letter / digit / "_")*) __ { return chars; } +Identifier "identifier" + = chars:$((Letter / "_") (Letter / Digit / "_")*) __ { return chars; } /* * Modeled after ECMA-262, 5th ed., 7.8.4. (syntax & semantics, rules only * vaguely). */ -literal "literal" - = value:(doubleQuotedString / singleQuotedString) flags:"i"? __ { +Literal "literal" + = value:(DoubleQuotedString / SingleQuotedString) flags:"i"? __ { return { type: "literal", value: value, @@ -214,40 +214,40 @@ literal "literal" }; } -string "string" - = string:(doubleQuotedString / singleQuotedString) __ { return string; } +String "string" + = string:(DoubleQuotedString / SingleQuotedString) __ { return string; } -doubleQuotedString - = '"' chars:doubleQuotedCharacter* '"' { return chars.join(""); } +DoubleQuotedString + = '"' chars:DoubleQuotedCharacter* '"' { return chars.join(""); } -doubleQuotedCharacter - = simpleDoubleQuotedCharacter - / simpleEscapeSequence - / zeroEscapeSequence - / hexEscapeSequence - / unicodeEscapeSequence - / eolEscapeSequence +DoubleQuotedCharacter + = SimpleDoubleQuotedCharacter + / SimpleEscapeSequence + / ZeroEscapeSequence + / HexEscapeSequence + / UnicodeEscapeSequence + / EOLEscapeSequence -simpleDoubleQuotedCharacter - = !('"' / "\\" / eolChar) char_:. { return char_; } +SimpleDoubleQuotedCharacter + = !('"' / "\\" / EOLChar) char_:. { return char_; } -singleQuotedString - = "'" chars:singleQuotedCharacter* "'" { return chars.join(""); } +SingleQuotedString + = "'" chars:SingleQuotedCharacter* "'" { return chars.join(""); } -singleQuotedCharacter - = simpleSingleQuotedCharacter - / simpleEscapeSequence - / zeroEscapeSequence - / hexEscapeSequence - / unicodeEscapeSequence - / eolEscapeSequence +SingleQuotedCharacter + = SimpleSingleQuotedCharacter + / SimpleEscapeSequence + / ZeroEscapeSequence + / HexEscapeSequence + / UnicodeEscapeSequence + / EOLEscapeSequence -simpleSingleQuotedCharacter - = !("'" / "\\" / eolChar) char_:. { return char_; } +SimpleSingleQuotedCharacter + = !("'" / "\\" / EOLChar) char_:. { return char_; } -class "character class" +Class "character class" = class_:( - "[" inverted:"^"? parts:(classCharacterRange / classCharacter)* "]" flags:"i"? { + "[" inverted:"^"? parts:(ClassCharacterRange / ClassCharacter)* "]" flags:"i"? { return { type: "class", parts: parts, @@ -260,8 +260,8 @@ class "character class" __ { return class_; } -classCharacterRange - = begin:classCharacter "-" end:classCharacter { +ClassCharacterRange + = begin:ClassCharacter "-" end:ClassCharacter { if (begin.charCodeAt(0) > end.charCodeAt(0)) { error("Invalid character range: " + text() + "."); } @@ -269,22 +269,22 @@ classCharacterRange return [begin, end]; } -classCharacter - = bracketDelimitedCharacter +ClassCharacter + = BracketDelimitedCharacter -bracketDelimitedCharacter - = simpleBracketDelimitedCharacter - / simpleEscapeSequence - / zeroEscapeSequence - / hexEscapeSequence - / unicodeEscapeSequence - / eolEscapeSequence +BracketDelimitedCharacter + = SimpleBracketDelimitedCharacter + / SimpleEscapeSequence + / ZeroEscapeSequence + / HexEscapeSequence + / UnicodeEscapeSequence + / EOLEscapeSequence -simpleBracketDelimitedCharacter - = !("]" / "\\" / eolChar) char_:. { return char_; } +SimpleBracketDelimitedCharacter + = !("]" / "\\" / EOLChar) char_:. { return char_; } -simpleEscapeSequence - = "\\" !(digit / "x" / "u" / eolChar) char_:. { +SimpleEscapeSequence + = "\\" !(Digit / "x" / "u" / EOLChar) char_:. { return char_ .replace("b", "\b") .replace("f", "\f") @@ -294,62 +294,62 @@ simpleEscapeSequence .replace("v", "\x0B"); // IE does not recognize "\v". } -zeroEscapeSequence - = "\\0" !digit { return "\x00"; } +ZeroEscapeSequence + = "\\0" !Digit { return "\x00"; } -hexEscapeSequence - = "\\x" digits:$(hexDigit hexDigit) { +HexEscapeSequence + = "\\x" digits:$(HexDigit HexDigit) { return String.fromCharCode(parseInt(digits, 16)); } -unicodeEscapeSequence - = "\\u" digits:$(hexDigit hexDigit hexDigit hexDigit) { +UnicodeEscapeSequence + = "\\u" digits:$(HexDigit HexDigit HexDigit HexDigit) { return String.fromCharCode(parseInt(digits, 16)); } -eolEscapeSequence - = "\\" eol:eol { return ""; } +EOLEscapeSequence + = "\\" eol:EOL { return ""; } -digit +Digit = [0-9] -hexDigit +HexDigit = [0-9a-fA-F] -letter - = lowerCaseLetter - / upperCaseLetter +Letter + = LowerCaseLetter + / UpperCaseLetter -lowerCaseLetter +LowerCaseLetter = [a-z] -upperCaseLetter +UpperCaseLetter = [A-Z] -__ = (whitespace / eol / comment)* +__ = (Whitespace / EOL / Comment)* /* Modeled after ECMA-262, 5th ed., 7.4. */ -comment "comment" - = singleLineComment - / multiLineComment +Comment "comment" + = SingleLineComment + / MultiLineComment -singleLineComment - = "//" (!eolChar .)* +SingleLineComment + = "//" (!EOLChar .)* -multiLineComment +MultiLineComment = "/*" (!"*/" .)* "*/" /* Modeled after ECMA-262, 5th ed., 7.3. */ -eol "end of line" +EOL "end of line" = "\n" / "\r\n" / "\r" / "\u2028" / "\u2029" -eolChar +EOLChar = [\n\r\u2028\u2029] /* Modeled after ECMA-262, 5th ed., 7.2. */ -whitespace "whitespace" +Whitespace "whitespace" = [ \t\v\f\u00A0\uFEFF\u1680\u180E\u2000-\u200A\u202F\u205F\u3000]