diff --git a/README.md b/README.md index 1549129..6d15897 100644 --- a/README.md +++ b/README.md @@ -291,7 +291,7 @@ expression as many times as possible. #### *expression* ? Try to match the expression. If the match succeeds, return its match result, -otherwise return an empty string. +otherwise return `null`. #### & *expression* diff --git a/examples/css.pegjs b/examples/css.pegjs index 7dc6c25..940d2ed 100644 --- a/examples/css.pegjs +++ b/examples/css.pegjs @@ -33,7 +33,7 @@ stylesheet return { type: "stylesheet", - charset: charset !== "" ? charset[1] : null, + charset: charset !== null ? charset[1] : null, imports: importsConverted, rules: rulesConverted }; @@ -44,7 +44,7 @@ import return { type: "import_rule", href: href, - media: media !== "" ? media : [] + media: media !== null ? media : [] }; } @@ -75,16 +75,16 @@ page declarationsHead:declaration? declarationsTail:(";" S* declaration?)* "}" S* { - var declarations = declarationsHead !== "" ? [declarationsHead] : []; + var declarations = declarationsHead !== null ? [declarationsHead] : []; for (var i = 0; i < declarationsTail.length; i++) { - if (declarationsTail[i][2] !== "") { + if (declarationsTail[i][2] !== null) { declarations.push(declarationsTail[i][2]); } } return { type: "page_rule", - qualifier: qualifier !== "" ? qualifier : null, + qualifier: qualifier, declarations: declarations }; } @@ -119,9 +119,9 @@ ruleset selectors.push(selectorsTail[i][2]); } - var declarations = declarationsHead !== "" ? [declarationsHead] : []; + var declarations = declarationsHead !== null ? [declarationsHead] : []; for (i = 0; i < declarationsTail.length; i++) { - if (declarationsTail[i][2] !== "") { + if (declarationsTail[i][2] !== null) { declarations.push(declarationsTail[i][2]); } } @@ -196,8 +196,8 @@ attrib return { type: "attribute_selector", attribute: attribute, - operator: operatorAndValue !== "" ? operatorAndValue[0] : null, - value: operatorAndValue !== "" ? operatorAndValue[2] : null + operator: operatorAndValue !== null ? operatorAndValue[0] : null, + value: operatorAndValue !== null ? operatorAndValue[2] : null }; } @@ -208,7 +208,7 @@ pseudo return { type: "function", name: name, - params: params !== "" ? [params[0]] : [] + params: params !== null ? [params[0]] : [] }; } / IDENT @@ -230,7 +230,7 @@ declaration type: "declaration", property: property, expression: expression, - important: important !== "" ? true : false + important: important !== null ? true : false }; } @@ -262,7 +262,12 @@ term / FREQ S* / PERCENTAGE S* / NUMBER S* - ) { return { type: "value", value: operator + value[0] }; } + ) { + return { + type: "value", + value: (operator !== null ? operator : "") + value[0] + }; + } / value:URI S* { return { type: "uri", value: value }; } / function / hexcolor @@ -331,7 +336,7 @@ comment ident = dash:"-"? nmstart:nmstart nmchars:nmchar* { - return dash + nmstart + nmchars.join(""); + return (dash !== null ? dash : "") + nmstart + nmchars.join(""); } name diff --git a/examples/javascript.pegjs b/examples/javascript.pegjs index 370ee25..13206ad 100644 --- a/examples/javascript.pegjs +++ b/examples/javascript.pegjs @@ -478,25 +478,25 @@ ArrayLiteral = "[" __ elision:(Elision __)? "]" { return { type: "ArrayLiteral", - elements: elision !== "" ? elision[0] : [] + elements: elision !== null ? elision[0] : [] }; } / "[" __ elements:ElementList __ elision:("," __ (Elision __)?)? "]" { return { type: "ArrayLiteral", - elements: elements.concat(elision !== "" && elision[2] !== "" ? elision[2][0] : []) + elements: elements.concat(elision !== null && elision[2] !== null ? elision[2][0] : []) }; } ElementList = head:( elision:(Elision __)? element:AssignmentExpression { - return (elision !== "" ? elision[0] : []).concat(element); + return (elision !== null ? elision[0] : []).concat(element); } ) tail:( __ "," __ elision:(Elision __)? element:AssignmentExpression { - return (elision !== "" ? elision[0] : []).concat(element); + return (elision !== null ? elision[0] : []).concat(element); } )* { var result = head; @@ -519,7 +519,7 @@ ObjectLiteral = "{" __ properties:(PropertyNameAndValueList __ ("," __)?)? "}" { return { type: "ObjectLiteral", - properties: properties !== "" ? properties[0] : [] + properties: properties !== null ? properties[0] : [] }; } @@ -663,7 +663,7 @@ CallExpression Arguments = "(" __ args:ArgumentList? __ ")" { - return args !== "" ? args : []; + return args !== null ? args : []; } ArgumentList @@ -1143,7 +1143,7 @@ Block = "{" __ statements:(StatementList __)? "}" { return { type: "Block", - statements: statements !== "" ? statements[0] : [] + statements: statements !== null ? statements[0] : [] }; } @@ -1187,7 +1187,7 @@ VariableDeclaration return { type: "VariableDeclaration", name: name, - value: value !== "" ? value[1] : null + value: value !== null ? value[1] : null }; } @@ -1196,7 +1196,7 @@ VariableDeclarationNoIn return { type: "VariableDeclaration", name: name, - value: value !== "" ? value[1] : null + value: value !== null ? value[1] : null }; } @@ -1221,7 +1221,7 @@ IfStatement type: "IfStatement", condition: condition, ifStatement: ifStatement, - elseStatement: elseStatement !== "" ? elseStatement[3] : null + elseStatement: elseStatement !== null ? elseStatement[3] : null }; } @@ -1272,9 +1272,9 @@ ForStatement { return { type: "ForStatement", - initializer: initializer !== "" ? initializer : null, - test: test !== "" ? test : null, - counter: counter !== "" ? counter : null, + initializer: initializer, + test: test, + counter: counter, statement: statement }; } @@ -1358,10 +1358,10 @@ CaseBlock before:CaseClauses? defaultAndAfter:(__ DefaultClause __ CaseClauses?)? __ "}" { - var before = before !== "" ? before : []; - if (defaultAndAfter !== "") { + var before = before !== null ? before : []; + if (defaultAndAfter !== null) { var defaultClause = defaultAndAfter[1]; - var clausesAfter = defaultAndAfter[3] !== "" + var clausesAfter = defaultAndAfter[3] !== null ? defaultAndAfter[3] : []; } else { @@ -1386,7 +1386,7 @@ CaseClause return { type: "CaseClause", selector: selector, - statements: statements !== "" ? statements[1] : [] + statements: statements !== null ? statements[1] : [] }; } @@ -1394,7 +1394,7 @@ DefaultClause = DefaultToken __ ":" statements:(__ StatementList)? { return { type: "DefaultClause", - statements: statements !== "" ? statements[1] : [] + statements: statements !== null ? statements[1] : [] }; } @@ -1470,7 +1470,7 @@ FunctionDeclaration return { type: "Function", name: name, - params: params !== "" ? params : [], + params: params !== null ? params : [], elements: elements }; } @@ -1481,8 +1481,8 @@ FunctionExpression "{" __ elements:FunctionBody __ "}" { return { type: "Function", - name: name !== "" ? name : null, - params: params !== "" ? params : [], + name: name, + params: params !== null ? params : [], elements: elements }; } @@ -1497,13 +1497,13 @@ FormalParameterList } FunctionBody - = elements:SourceElements? { return elements !== "" ? elements : []; } + = elements:SourceElements? { return elements !== null ? elements : []; } Program = elements:SourceElements? { return { type: "Program", - elements: elements !== "" ? elements : [] + elements: elements !== null ? elements : [] }; } diff --git a/lib/compiler/passes/generate-bytecode.js b/lib/compiler/passes/generate-bytecode.js index e9d95cd..9709f9e 100644 --- a/lib/compiler/passes/generate-bytecode.js +++ b/lib/compiler/passes/generate-bytecode.js @@ -466,7 +466,7 @@ module.exports = function(ast, options) { }, optional: function(node, context) { - var emptyStringIndex = addConst('""'); + var nullIndex = addConst('null'); return buildSequence( generate(node.expression, { @@ -476,7 +476,7 @@ module.exports = function(ast, options) { }), buildCondition( [op.IF_ERROR], - buildSequence([op.POP], [op.PUSH, emptyStringIndex]), + buildSequence([op.POP], [op.PUSH, nullIndex]), [] ) ); diff --git a/lib/parser.js b/lib/parser.js index ded3551..e10921e 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -79,12 +79,12 @@ module.exports = (function() { peg$startRuleFunction = peg$parsegrammar, peg$c0 = peg$FAILED, - peg$c1 = "", + peg$c1 = null, peg$c2 = [], peg$c3 = function(initializer, rules) { return { type: "grammar", - initializer: initializer !== "" ? initializer : null, + initializer: initializer, rules: rules }; }, @@ -98,7 +98,7 @@ module.exports = (function() { return { type: "rule", name: name, - expression: displayName !== "" + expression: displayName !== null ? { type: "named", name: displayName, @@ -197,100 +197,101 @@ module.exports = (function() { expression: expression }; }, - peg$c18 = function(name) { + peg$c18 = "", + peg$c19 = function(name) { return { type: "rule_ref", name: name }; }, - peg$c19 = function() { return { type: "any" }; }, - peg$c20 = function(expression) { return expression; }, - peg$c21 = { type: "other", description: "action" }, - peg$c22 = function(braced) { return braced.substr(1, braced.length - 2); }, - peg$c23 = "{", - peg$c24 = { type: "literal", value: "{", description: "\"{\"" }, - peg$c25 = "}", - peg$c26 = { type: "literal", value: "}", description: "\"}\"" }, - peg$c27 = /^[^{}]/, - peg$c28 = { type: "class", value: "[^{}]", description: "[^{}]" }, - peg$c29 = "=", - peg$c30 = { type: "literal", value: "=", description: "\"=\"" }, - peg$c31 = function() { return "="; }, - peg$c32 = ":", - peg$c33 = { type: "literal", value: ":", description: "\":\"" }, - peg$c34 = function() { return ":"; }, - peg$c35 = ";", - peg$c36 = { type: "literal", value: ";", description: "\";\"" }, - peg$c37 = function() { return ";"; }, - peg$c38 = "/", - peg$c39 = { type: "literal", value: "/", description: "\"/\"" }, - peg$c40 = function() { return "/"; }, - peg$c41 = "&", - peg$c42 = { type: "literal", value: "&", description: "\"&\"" }, - peg$c43 = function() { return "&"; }, - peg$c44 = "!", - peg$c45 = { type: "literal", value: "!", description: "\"!\"" }, - peg$c46 = function() { return "!"; }, - peg$c47 = "$", - peg$c48 = { type: "literal", value: "$", description: "\"$\"" }, - peg$c49 = function() { return "$"; }, - peg$c50 = "?", - peg$c51 = { type: "literal", value: "?", description: "\"?\"" }, - peg$c52 = function() { return "?"; }, - peg$c53 = "*", - peg$c54 = { type: "literal", value: "*", description: "\"*\"" }, - peg$c55 = function() { return "*"; }, - peg$c56 = "+", - peg$c57 = { type: "literal", value: "+", description: "\"+\"" }, - peg$c58 = function() { return "+"; }, - peg$c59 = "(", - peg$c60 = { type: "literal", value: "(", description: "\"(\"" }, - peg$c61 = function() { return "("; }, - peg$c62 = ")", - peg$c63 = { type: "literal", value: ")", description: "\")\"" }, - peg$c64 = function() { return ")"; }, - peg$c65 = ".", - peg$c66 = { type: "literal", value: ".", description: "\".\"" }, - peg$c67 = function() { return "."; }, - peg$c68 = { type: "other", description: "identifier" }, - peg$c69 = "_", - peg$c70 = { type: "literal", value: "_", description: "\"_\"" }, - peg$c71 = function(chars) { return chars; }, - peg$c72 = { type: "other", description: "literal" }, - peg$c73 = "i", - peg$c74 = { type: "literal", value: "i", description: "\"i\"" }, - peg$c75 = function(value, flags) { + 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 = function() { return "="; }, + peg$c33 = ":", + peg$c34 = { type: "literal", value: ":", description: "\":\"" }, + peg$c35 = function() { return ":"; }, + peg$c36 = ";", + peg$c37 = { type: "literal", value: ";", description: "\";\"" }, + peg$c38 = function() { return ";"; }, + peg$c39 = "/", + peg$c40 = { type: "literal", value: "/", description: "\"/\"" }, + peg$c41 = function() { return "/"; }, + peg$c42 = "&", + peg$c43 = { type: "literal", value: "&", description: "\"&\"" }, + peg$c44 = function() { return "&"; }, + peg$c45 = "!", + peg$c46 = { type: "literal", value: "!", description: "\"!\"" }, + peg$c47 = function() { return "!"; }, + peg$c48 = "$", + peg$c49 = { type: "literal", value: "$", description: "\"$\"" }, + peg$c50 = function() { return "$"; }, + peg$c51 = "?", + peg$c52 = { type: "literal", value: "?", description: "\"?\"" }, + peg$c53 = function() { return "?"; }, + peg$c54 = "*", + peg$c55 = { type: "literal", value: "*", description: "\"*\"" }, + peg$c56 = function() { return "*"; }, + peg$c57 = "+", + peg$c58 = { type: "literal", value: "+", description: "\"+\"" }, + peg$c59 = function() { return "+"; }, + peg$c60 = "(", + peg$c61 = { type: "literal", value: "(", description: "\"(\"" }, + peg$c62 = function() { return "("; }, + peg$c63 = ")", + peg$c64 = { type: "literal", value: ")", description: "\")\"" }, + peg$c65 = function() { return ")"; }, + peg$c66 = ".", + peg$c67 = { type: "literal", value: ".", description: "\".\"" }, + peg$c68 = function() { return "."; }, + peg$c69 = { type: "other", description: "identifier" }, + peg$c70 = "_", + peg$c71 = { type: "literal", value: "_", description: "\"_\"" }, + peg$c72 = function(chars) { return chars; }, + peg$c73 = { type: "other", description: "literal" }, + peg$c74 = "i", + peg$c75 = { type: "literal", value: "i", description: "\"i\"" }, + peg$c76 = function(value, flags) { return { type: "literal", value: value, ignoreCase: flags === "i" }; }, - peg$c76 = { type: "other", description: "string" }, - peg$c77 = function(string) { return string; }, - peg$c78 = "\"", - peg$c79 = { type: "literal", value: "\"", description: "\"\\\"\"" }, - peg$c80 = function(chars) { return chars.join(""); }, - peg$c81 = "\\", - peg$c82 = { type: "literal", value: "\\", description: "\"\\\\\"" }, - peg$c83 = { type: "any", description: "any character" }, - peg$c84 = function(char_) { return char_; }, - peg$c85 = "'", - peg$c86 = { type: "literal", value: "'", description: "\"'\"" }, - peg$c87 = { type: "other", description: "character class" }, - peg$c88 = "[", - peg$c89 = { type: "literal", value: "[", description: "\"[\"" }, - peg$c90 = "^", - peg$c91 = { type: "literal", value: "^", description: "\"^\"" }, - peg$c92 = "]", - peg$c93 = { type: "literal", value: "]", description: "\"]\"" }, - peg$c94 = function(inverted, parts, flags) { + peg$c77 = { type: "other", description: "string" }, + peg$c78 = function(string) { return string; }, + peg$c79 = "\"", + peg$c80 = { type: "literal", value: "\"", description: "\"\\\"\"" }, + peg$c81 = function(chars) { return chars.join(""); }, + peg$c82 = "\\", + peg$c83 = { type: "literal", value: "\\", description: "\"\\\\\"" }, + peg$c84 = { type: "any", description: "any character" }, + peg$c85 = function(char_) { return char_; }, + peg$c86 = "'", + peg$c87 = { type: "literal", value: "'", description: "\"'\"" }, + peg$c88 = { type: "other", description: "character class" }, + peg$c89 = "[", + peg$c90 = { type: "literal", value: "[", description: "\"[\"" }, + peg$c91 = "^", + peg$c92 = { type: "literal", value: "^", description: "\"^\"" }, + peg$c93 = "]", + peg$c94 = { type: "literal", value: "]", description: "\"]\"" }, + peg$c95 = function(inverted, parts, flags) { var partsConverted = utils.map(parts, function(part) { return part.data; }); var rawText = "[" - + inverted + + (inverted !== null ? inverted : "") + utils.map(parts, function(part) { return part.rawText; }).join("") + "]" - + flags; + + (flags !== null ? flags : ""); return { type: "class", @@ -301,9 +302,9 @@ module.exports = (function() { ignoreCase: flags === "i" }; }, - peg$c95 = "-", - peg$c96 = { type: "literal", value: "-", description: "\"-\"" }, - peg$c97 = function(begin, end) { + peg$c96 = "-", + peg$c97 = { type: "literal", value: "-", description: "\"-\"" }, + peg$c98 = function(begin, end) { if (begin.data.charCodeAt(0) > end.data.charCodeAt(0)) { throw new this.SyntaxError( "Invalid character range: " + begin.rawText + "-" + end.rawText + "." @@ -316,18 +317,18 @@ module.exports = (function() { rawText: begin.rawText + "-" + end.rawText }; }, - peg$c98 = function(char_) { + peg$c99 = function(char_) { return { data: char_, // FIXME: Get the raw text from the input directly. rawText: utils.quoteForRegexpClass(char_) }; }, - peg$c99 = "x", - peg$c100 = { type: "literal", value: "x", description: "\"x\"" }, - peg$c101 = "u", - peg$c102 = { type: "literal", value: "u", description: "\"u\"" }, - peg$c103 = function(char_) { + peg$c100 = "x", + peg$c101 = { type: "literal", value: "x", description: "\"x\"" }, + peg$c102 = "u", + peg$c103 = { type: "literal", value: "u", description: "\"u\"" }, + peg$c104 = function(char_) { return char_ .replace("b", "\b") .replace("f", "\f") @@ -336,48 +337,48 @@ module.exports = (function() { .replace("t", "\t") .replace("v", "\x0B"); // IE does not recognize "\v". }, - peg$c104 = "\\0", - peg$c105 = { type: "literal", value: "\\0", description: "\"\\\\0\"" }, - peg$c106 = function() { return "\x00"; }, - peg$c107 = "\\x", - peg$c108 = { type: "literal", value: "\\x", description: "\"\\\\x\"" }, - peg$c109 = function(digits) { + peg$c105 = "\\0", + peg$c106 = { type: "literal", value: "\\0", description: "\"\\\\0\"" }, + peg$c107 = function() { return "\x00"; }, + peg$c108 = "\\x", + peg$c109 = { type: "literal", value: "\\x", description: "\"\\\\x\"" }, + peg$c110 = function(digits) { return String.fromCharCode(parseInt(digits, 16)); }, - peg$c110 = "\\u", - peg$c111 = { type: "literal", value: "\\u", description: "\"\\\\u\"" }, - peg$c112 = function(eol) { return eol; }, - peg$c113 = /^[0-9]/, - peg$c114 = { type: "class", value: "[0-9]", description: "[0-9]" }, - peg$c115 = /^[0-9a-fA-F]/, - peg$c116 = { type: "class", value: "[0-9a-fA-F]", description: "[0-9a-fA-F]" }, - peg$c117 = /^[a-z]/, - peg$c118 = { type: "class", value: "[a-z]", description: "[a-z]" }, - peg$c119 = /^[A-Z]/, - peg$c120 = { type: "class", value: "[A-Z]", description: "[A-Z]" }, - peg$c121 = { type: "other", description: "comment" }, - peg$c122 = "//", - peg$c123 = { type: "literal", value: "//", description: "\"//\"" }, - peg$c124 = "/*", - peg$c125 = { type: "literal", value: "/*", description: "\"/*\"" }, - peg$c126 = "*/", - peg$c127 = { type: "literal", value: "*/", description: "\"*/\"" }, - peg$c128 = { type: "other", description: "end of line" }, - peg$c129 = "\n", - peg$c130 = { type: "literal", value: "\n", description: "\"\\n\"" }, - peg$c131 = "\r\n", - peg$c132 = { type: "literal", value: "\r\n", description: "\"\\r\\n\"" }, - peg$c133 = "\r", - peg$c134 = { type: "literal", value: "\r", description: "\"\\r\"" }, - peg$c135 = "\u2028", - peg$c136 = { type: "literal", value: "\u2028", description: "\"\\u2028\"" }, - peg$c137 = "\u2029", - peg$c138 = { type: "literal", value: "\u2029", description: "\"\\u2029\"" }, - peg$c139 = /^[\n\r\u2028\u2029]/, - peg$c140 = { type: "class", value: "[\\n\\r\\u2028\\u2029]", description: "[\\n\\r\\u2028\\u2029]" }, - peg$c141 = { type: "other", description: "whitespace" }, - peg$c142 = /^[ \t\x0B\f\xA0\uFEFF\u1680\u180E\u2000-\u200A\u202F\u205F\u3000]/, - peg$c143 = { type: "class", value: "[ \\t\\x0B\\f\\xA0\\uFEFF\\u1680\\u180E\\u2000-\\u200A\\u202F\\u205F\\u3000]", description: "[ \\t\\x0B\\f\\xA0\\uFEFF\\u1680\\u180E\\u2000-\\u200A\\u202F\\u205F\\u3000]" }, + peg$c111 = "\\u", + peg$c112 = { type: "literal", value: "\\u", description: "\"\\\\u\"" }, + peg$c113 = function(eol) { return eol; }, + peg$c114 = /^[0-9]/, + peg$c115 = { type: "class", value: "[0-9]", description: "[0-9]" }, + peg$c116 = /^[0-9a-fA-F]/, + peg$c117 = { type: "class", value: "[0-9a-fA-F]", description: "[0-9a-fA-F]" }, + peg$c118 = /^[a-z]/, + peg$c119 = { type: "class", value: "[a-z]", description: "[a-z]" }, + peg$c120 = /^[A-Z]/, + peg$c121 = { type: "class", value: "[A-Z]", description: "[A-Z]" }, + peg$c122 = { type: "other", description: "comment" }, + peg$c123 = "//", + peg$c124 = { type: "literal", value: "//", description: "\"//\"" }, + peg$c125 = "/*", + peg$c126 = { type: "literal", value: "/*", description: "\"/*\"" }, + peg$c127 = "*/", + peg$c128 = { type: "literal", value: "*/", description: "\"*/\"" }, + peg$c129 = { type: "other", description: "end of line" }, + peg$c130 = "\n", + peg$c131 = { type: "literal", value: "\n", description: "\"\\n\"" }, + peg$c132 = "\r\n", + peg$c133 = { type: "literal", value: "\r\n", description: "\"\\r\\n\"" }, + peg$c134 = "\r", + peg$c135 = { type: "literal", value: "\r", description: "\"\\r\"" }, + peg$c136 = "\u2028", + peg$c137 = { type: "literal", value: "\u2028", description: "\"\\u2028\"" }, + peg$c138 = "\u2029", + peg$c139 = { type: "literal", value: "\u2029", description: "\"\\u2029\"" }, + peg$c140 = /^[\n\r\u2028\u2029]/, + peg$c141 = { type: "class", value: "[\\n\\r\\u2028\\u2029]", description: "[\\n\\r\\u2028\\u2029]" }, + peg$c142 = { type: "other", description: "whitespace" }, + peg$c143 = /^[ \t\x0B\f\xA0\uFEFF\u1680\u180E\u2000-\u200A\u202F\u205F\u3000]/, + peg$c144 = { type: "class", value: "[ \\t\\x0B\\f\\xA0\\uFEFF\\u1680\\u180E\\u2000-\\u200A\\u202F\\u205F\\u3000]", description: "[ \\t\\x0B\\f\\xA0\\uFEFF\\u1680\\u180E\\u2000-\\u200A\\u202F\\u205F\\u3000]" }, peg$currPos = 0, peg$reportedPos = 0, @@ -986,14 +987,14 @@ module.exports = (function() { } peg$silentFails--; if (s3 === peg$FAILED) { - s2 = peg$c1; + s2 = peg$c18; } else { peg$currPos = s2; s2 = peg$c0; } if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c18(s1); + s1 = peg$c19(s1); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1017,7 +1018,7 @@ module.exports = (function() { s1 = peg$parsedot(); if (s1 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c19(); + s1 = peg$c20(); } if (s1 === peg$FAILED) { peg$currPos = s0; @@ -1034,7 +1035,7 @@ module.exports = (function() { s3 = peg$parserparen(); if (s3 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c20(s2); + s1 = peg$c21(s2); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1071,7 +1072,7 @@ module.exports = (function() { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c22(s1); + s1 = peg$c23(s1); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1089,7 +1090,7 @@ module.exports = (function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c21); } + if (peg$silentFails === 0) { peg$fail(peg$c22); } } return s0; @@ -1101,11 +1102,11 @@ module.exports = (function() { s0 = peg$currPos; s1 = peg$currPos; if (input.charCodeAt(peg$currPos) === 123) { - s2 = peg$c23; + s2 = peg$c24; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c24); } + if (peg$silentFails === 0) { peg$fail(peg$c25); } } if (s2 !== peg$FAILED) { s3 = []; @@ -1122,11 +1123,11 @@ module.exports = (function() { } if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { - s4 = peg$c25; + s4 = peg$c26; peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c26); } + if (peg$silentFails === 0) { peg$fail(peg$c27); } } if (s4 !== peg$FAILED) { s2 = [s2, s3, s4]; @@ -1171,12 +1172,12 @@ module.exports = (function() { function peg$parsenonBraceCharacter() { var s0; - if (peg$c27.test(input.charAt(peg$currPos))) { + if (peg$c28.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c28); } + if (peg$silentFails === 0) { peg$fail(peg$c29); } } return s0; @@ -1187,17 +1188,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 61) { - s1 = peg$c29; + s1 = peg$c30; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c30); } + if (peg$silentFails === 0) { peg$fail(peg$c31); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c31(); + s1 = peg$c32(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1221,17 +1222,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 58) { - s1 = peg$c32; + s1 = peg$c33; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c33); } + if (peg$silentFails === 0) { peg$fail(peg$c34); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c34(); + s1 = peg$c35(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1255,17 +1256,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 59) { - s1 = peg$c35; + s1 = peg$c36; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c36); } + if (peg$silentFails === 0) { peg$fail(peg$c37); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c37(); + s1 = peg$c38(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1289,17 +1290,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 47) { - s1 = peg$c38; + s1 = peg$c39; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c39); } + if (peg$silentFails === 0) { peg$fail(peg$c40); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c40(); + s1 = peg$c41(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1323,17 +1324,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 38) { - s1 = peg$c41; + s1 = peg$c42; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c42); } + if (peg$silentFails === 0) { peg$fail(peg$c43); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c43(); + s1 = peg$c44(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1357,17 +1358,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 33) { - s1 = peg$c44; + s1 = peg$c45; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c45); } + if (peg$silentFails === 0) { peg$fail(peg$c46); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c46(); + s1 = peg$c47(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1391,17 +1392,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 36) { - s1 = peg$c47; + s1 = peg$c48; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c48); } + if (peg$silentFails === 0) { peg$fail(peg$c49); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c49(); + s1 = peg$c50(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1425,17 +1426,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 63) { - s1 = peg$c50; + s1 = peg$c51; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c51); } + if (peg$silentFails === 0) { peg$fail(peg$c52); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c52(); + s1 = peg$c53(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1459,17 +1460,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 42) { - s1 = peg$c53; + s1 = peg$c54; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c54); } + if (peg$silentFails === 0) { peg$fail(peg$c55); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c55(); + s1 = peg$c56(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1493,17 +1494,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 43) { - s1 = peg$c56; + s1 = peg$c57; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c57); } + if (peg$silentFails === 0) { peg$fail(peg$c58); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c58(); + s1 = peg$c59(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1527,17 +1528,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 40) { - s1 = peg$c59; + s1 = peg$c60; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c60); } + if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c61(); + s1 = peg$c62(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1561,17 +1562,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 41) { - s1 = peg$c62; + s1 = peg$c63; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c63); } + if (peg$silentFails === 0) { peg$fail(peg$c64); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c64(); + s1 = peg$c65(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1595,17 +1596,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 46) { - s1 = peg$c65; + s1 = peg$c66; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c66); } + if (peg$silentFails === 0) { peg$fail(peg$c67); } } if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c67(); + s1 = peg$c68(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1634,11 +1635,11 @@ module.exports = (function() { s3 = peg$parseletter(); if (s3 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 95) { - s3 = peg$c69; + s3 = peg$c70; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c70); } + if (peg$silentFails === 0) { peg$fail(peg$c71); } } } if (s3 !== peg$FAILED) { @@ -1648,11 +1649,11 @@ module.exports = (function() { s5 = peg$parsedigit(); if (s5 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 95) { - s5 = peg$c69; + s5 = peg$c70; peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c70); } + if (peg$silentFails === 0) { peg$fail(peg$c71); } } } } @@ -1663,11 +1664,11 @@ module.exports = (function() { s5 = peg$parsedigit(); if (s5 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 95) { - s5 = peg$c69; + s5 = peg$c70; peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c70); } + if (peg$silentFails === 0) { peg$fail(peg$c71); } } } } @@ -1691,7 +1692,7 @@ module.exports = (function() { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c71(s1); + s1 = peg$c72(s1); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1709,7 +1710,7 @@ module.exports = (function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c68); } + if (peg$silentFails === 0) { peg$fail(peg$c69); } } return s0; @@ -1726,11 +1727,11 @@ module.exports = (function() { } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 105) { - s2 = peg$c73; + s2 = peg$c74; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c74); } + if (peg$silentFails === 0) { peg$fail(peg$c75); } } if (s2 === peg$FAILED) { s2 = peg$c1; @@ -1739,7 +1740,7 @@ module.exports = (function() { s3 = peg$parse__(); if (s3 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c75(s1, s2); + s1 = peg$c76(s1, s2); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1761,7 +1762,7 @@ module.exports = (function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c72); } + if (peg$silentFails === 0) { peg$fail(peg$c73); } } return s0; @@ -1780,7 +1781,7 @@ module.exports = (function() { s2 = peg$parse__(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c77(s1); + s1 = peg$c78(s1); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1798,7 +1799,7 @@ module.exports = (function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c76); } + if (peg$silentFails === 0) { peg$fail(peg$c77); } } return s0; @@ -1809,11 +1810,11 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c78; + s1 = peg$c79; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c79); } + if (peg$silentFails === 0) { peg$fail(peg$c80); } } if (s1 !== peg$FAILED) { s2 = []; @@ -1824,15 +1825,15 @@ module.exports = (function() { } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c78; + s3 = peg$c79; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c79); } + if (peg$silentFails === 0) { peg$fail(peg$c80); } } if (s3 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c80(s2); + s1 = peg$c81(s2); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1885,19 +1886,19 @@ module.exports = (function() { s1 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 34) { - s2 = peg$c78; + s2 = peg$c79; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c79); } + if (peg$silentFails === 0) { peg$fail(peg$c80); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { - s2 = peg$c81; + s2 = peg$c82; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c82); } + if (peg$silentFails === 0) { peg$fail(peg$c83); } } if (s2 === peg$FAILED) { s2 = peg$parseeolChar(); @@ -1905,7 +1906,7 @@ module.exports = (function() { } peg$silentFails--; if (s2 === peg$FAILED) { - s1 = peg$c1; + s1 = peg$c18; } else { peg$currPos = s1; s1 = peg$c0; @@ -1916,11 +1917,11 @@ module.exports = (function() { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c83); } + if (peg$silentFails === 0) { peg$fail(peg$c84); } } if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c84(s2); + s1 = peg$c85(s2); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -1944,11 +1945,11 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 39) { - s1 = peg$c85; + s1 = peg$c86; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c86); } + if (peg$silentFails === 0) { peg$fail(peg$c87); } } if (s1 !== peg$FAILED) { s2 = []; @@ -1959,15 +1960,15 @@ module.exports = (function() { } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 39) { - s3 = peg$c85; + s3 = peg$c86; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c86); } + if (peg$silentFails === 0) { peg$fail(peg$c87); } } if (s3 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c80(s2); + s1 = peg$c81(s2); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -2020,19 +2021,19 @@ module.exports = (function() { s1 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 39) { - s2 = peg$c85; + s2 = peg$c86; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c86); } + if (peg$silentFails === 0) { peg$fail(peg$c87); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { - s2 = peg$c81; + s2 = peg$c82; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c82); } + if (peg$silentFails === 0) { peg$fail(peg$c83); } } if (s2 === peg$FAILED) { s2 = peg$parseeolChar(); @@ -2040,7 +2041,7 @@ module.exports = (function() { } peg$silentFails--; if (s2 === peg$FAILED) { - s1 = peg$c1; + s1 = peg$c18; } else { peg$currPos = s1; s1 = peg$c0; @@ -2051,11 +2052,11 @@ module.exports = (function() { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c83); } + if (peg$silentFails === 0) { peg$fail(peg$c84); } } if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c84(s2); + s1 = peg$c85(s2); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -2080,19 +2081,19 @@ module.exports = (function() { peg$silentFails++; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 91) { - s1 = peg$c88; + s1 = peg$c89; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c89); } + if (peg$silentFails === 0) { peg$fail(peg$c90); } } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 94) { - s2 = peg$c90; + s2 = peg$c91; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c91); } + if (peg$silentFails === 0) { peg$fail(peg$c92); } } if (s2 === peg$FAILED) { s2 = peg$c1; @@ -2112,19 +2113,19 @@ module.exports = (function() { } if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 93) { - s4 = peg$c92; + s4 = peg$c93; peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c93); } + if (peg$silentFails === 0) { peg$fail(peg$c94); } } if (s4 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 105) { - s5 = peg$c73; + s5 = peg$c74; peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c74); } + if (peg$silentFails === 0) { peg$fail(peg$c75); } } if (s5 === peg$FAILED) { s5 = peg$c1; @@ -2133,7 +2134,7 @@ module.exports = (function() { s6 = peg$parse__(); if (s6 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c94(s2, s3, s5); + s1 = peg$c95(s2, s3, s5); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -2167,7 +2168,7 @@ module.exports = (function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c87); } + if (peg$silentFails === 0) { peg$fail(peg$c88); } } return s0; @@ -2180,17 +2181,17 @@ module.exports = (function() { s1 = peg$parseclassCharacter(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 45) { - s2 = peg$c95; + s2 = peg$c96; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c96); } + if (peg$silentFails === 0) { peg$fail(peg$c97); } } if (s2 !== peg$FAILED) { s3 = peg$parseclassCharacter(); if (s3 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c97(s1, s3); + s1 = peg$c98(s1, s3); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -2220,7 +2221,7 @@ module.exports = (function() { s1 = peg$parsebracketDelimitedCharacter(); if (s1 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c98(s1); + s1 = peg$c99(s1); } if (s1 === peg$FAILED) { peg$currPos = s0; @@ -2262,19 +2263,19 @@ module.exports = (function() { s1 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 93) { - s2 = peg$c92; + s2 = peg$c93; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c93); } + if (peg$silentFails === 0) { peg$fail(peg$c94); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { - s2 = peg$c81; + s2 = peg$c82; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c82); } + if (peg$silentFails === 0) { peg$fail(peg$c83); } } if (s2 === peg$FAILED) { s2 = peg$parseeolChar(); @@ -2282,7 +2283,7 @@ module.exports = (function() { } peg$silentFails--; if (s2 === peg$FAILED) { - s1 = peg$c1; + s1 = peg$c18; } else { peg$currPos = s1; s1 = peg$c0; @@ -2293,11 +2294,11 @@ module.exports = (function() { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c83); } + if (peg$silentFails === 0) { peg$fail(peg$c84); } } if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c84(s2); + s1 = peg$c85(s2); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -2321,11 +2322,11 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c81; + s1 = peg$c82; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c82); } + if (peg$silentFails === 0) { peg$fail(peg$c83); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -2333,19 +2334,19 @@ module.exports = (function() { s3 = peg$parsedigit(); if (s3 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 120) { - s3 = peg$c99; + s3 = peg$c100; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c100); } + if (peg$silentFails === 0) { peg$fail(peg$c101); } } if (s3 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 117) { - s3 = peg$c101; + s3 = peg$c102; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c102); } + if (peg$silentFails === 0) { peg$fail(peg$c103); } } if (s3 === peg$FAILED) { s3 = peg$parseeolChar(); @@ -2354,7 +2355,7 @@ module.exports = (function() { } peg$silentFails--; if (s3 === peg$FAILED) { - s2 = peg$c1; + s2 = peg$c18; } else { peg$currPos = s2; s2 = peg$c0; @@ -2365,11 +2366,11 @@ module.exports = (function() { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c83); } + if (peg$silentFails === 0) { peg$fail(peg$c84); } } if (s3 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c103(s3); + s1 = peg$c104(s3); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -2396,12 +2397,12 @@ module.exports = (function() { var s0, s1, s2, s3; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c104) { - s1 = peg$c104; + if (input.substr(peg$currPos, 2) === peg$c105) { + s1 = peg$c105; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c105); } + if (peg$silentFails === 0) { peg$fail(peg$c106); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -2409,14 +2410,14 @@ module.exports = (function() { s3 = peg$parsedigit(); peg$silentFails--; if (s3 === peg$FAILED) { - s2 = peg$c1; + s2 = peg$c18; } else { peg$currPos = s2; s2 = peg$c0; } if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c106(); + s1 = peg$c107(); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -2439,12 +2440,12 @@ module.exports = (function() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c107) { - s1 = peg$c107; + if (input.substr(peg$currPos, 2) === peg$c108) { + s1 = peg$c108; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c108); } + if (peg$silentFails === 0) { peg$fail(peg$c109); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -2469,7 +2470,7 @@ module.exports = (function() { s2 = s3; if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c109(s2); + s1 = peg$c110(s2); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -2492,12 +2493,12 @@ module.exports = (function() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c110) { - s1 = peg$c110; + if (input.substr(peg$currPos, 2) === peg$c111) { + s1 = peg$c111; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c111); } + if (peg$silentFails === 0) { peg$fail(peg$c112); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -2534,7 +2535,7 @@ module.exports = (function() { s2 = s3; if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c109(s2); + s1 = peg$c110(s2); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -2558,17 +2559,17 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c81; + s1 = peg$c82; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c82); } + if (peg$silentFails === 0) { peg$fail(peg$c83); } } if (s1 !== peg$FAILED) { s2 = peg$parseeol(); if (s2 !== peg$FAILED) { peg$reportedPos = s0; - s1 = peg$c112(s2); + s1 = peg$c113(s2); if (s1 === peg$FAILED) { peg$currPos = s0; s0 = s1; @@ -2590,12 +2591,12 @@ module.exports = (function() { function peg$parsedigit() { var s0; - if (peg$c113.test(input.charAt(peg$currPos))) { + if (peg$c114.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c114); } + if (peg$silentFails === 0) { peg$fail(peg$c115); } } return s0; @@ -2604,12 +2605,12 @@ module.exports = (function() { function peg$parsehexDigit() { var s0; - if (peg$c115.test(input.charAt(peg$currPos))) { + if (peg$c116.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c116); } + if (peg$silentFails === 0) { peg$fail(peg$c117); } } return s0; @@ -2629,12 +2630,12 @@ module.exports = (function() { function peg$parselowerCaseLetter() { var s0; - if (peg$c117.test(input.charAt(peg$currPos))) { + if (peg$c118.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c118); } + if (peg$silentFails === 0) { peg$fail(peg$c119); } } return s0; @@ -2643,12 +2644,12 @@ module.exports = (function() { function peg$parseupperCaseLetter() { var s0; - if (peg$c119.test(input.charAt(peg$currPos))) { + if (peg$c120.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c120); } + if (peg$silentFails === 0) { peg$fail(peg$c121); } } return s0; @@ -2690,7 +2691,7 @@ module.exports = (function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c121); } + if (peg$silentFails === 0) { peg$fail(peg$c122); } } return s0; @@ -2700,12 +2701,12 @@ module.exports = (function() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c122) { - s1 = peg$c122; + if (input.substr(peg$currPos, 2) === peg$c123) { + s1 = peg$c123; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c123); } + if (peg$silentFails === 0) { peg$fail(peg$c124); } } if (s1 !== peg$FAILED) { s2 = []; @@ -2715,7 +2716,7 @@ module.exports = (function() { s5 = peg$parseeolChar(); peg$silentFails--; if (s5 === peg$FAILED) { - s4 = peg$c1; + s4 = peg$c18; } else { peg$currPos = s4; s4 = peg$c0; @@ -2726,7 +2727,7 @@ module.exports = (function() { peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c83); } + if (peg$silentFails === 0) { peg$fail(peg$c84); } } if (s5 !== peg$FAILED) { s4 = [s4, s5]; @@ -2747,7 +2748,7 @@ module.exports = (function() { s5 = peg$parseeolChar(); peg$silentFails--; if (s5 === peg$FAILED) { - s4 = peg$c1; + s4 = peg$c18; } else { peg$currPos = s4; s4 = peg$c0; @@ -2758,7 +2759,7 @@ module.exports = (function() { peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c83); } + if (peg$silentFails === 0) { peg$fail(peg$c84); } } if (s5 !== peg$FAILED) { s4 = [s4, s5]; @@ -2791,28 +2792,28 @@ module.exports = (function() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c124) { - s1 = peg$c124; + if (input.substr(peg$currPos, 2) === peg$c125) { + s1 = peg$c125; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c125); } + if (peg$silentFails === 0) { peg$fail(peg$c126); } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$currPos; s4 = peg$currPos; peg$silentFails++; - if (input.substr(peg$currPos, 2) === peg$c126) { - s5 = peg$c126; + if (input.substr(peg$currPos, 2) === peg$c127) { + s5 = peg$c127; peg$currPos += 2; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c127); } + if (peg$silentFails === 0) { peg$fail(peg$c128); } } peg$silentFails--; if (s5 === peg$FAILED) { - s4 = peg$c1; + s4 = peg$c18; } else { peg$currPos = s4; s4 = peg$c0; @@ -2823,7 +2824,7 @@ module.exports = (function() { peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c83); } + if (peg$silentFails === 0) { peg$fail(peg$c84); } } if (s5 !== peg$FAILED) { s4 = [s4, s5]; @@ -2841,16 +2842,16 @@ module.exports = (function() { s3 = peg$currPos; s4 = peg$currPos; peg$silentFails++; - if (input.substr(peg$currPos, 2) === peg$c126) { - s5 = peg$c126; + if (input.substr(peg$currPos, 2) === peg$c127) { + s5 = peg$c127; peg$currPos += 2; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c127); } + if (peg$silentFails === 0) { peg$fail(peg$c128); } } peg$silentFails--; if (s5 === peg$FAILED) { - s4 = peg$c1; + s4 = peg$c18; } else { peg$currPos = s4; s4 = peg$c0; @@ -2861,7 +2862,7 @@ module.exports = (function() { peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c83); } + if (peg$silentFails === 0) { peg$fail(peg$c84); } } if (s5 !== peg$FAILED) { s4 = [s4, s5]; @@ -2876,12 +2877,12 @@ module.exports = (function() { } } if (s2 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c126) { - s3 = peg$c126; + if (input.substr(peg$currPos, 2) === peg$c127) { + s3 = peg$c127; peg$currPos += 2; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c127); } + if (peg$silentFails === 0) { peg$fail(peg$c128); } } if (s3 !== peg$FAILED) { s1 = [s1, s2, s3]; @@ -2907,43 +2908,43 @@ module.exports = (function() { peg$silentFails++; if (input.charCodeAt(peg$currPos) === 10) { - s0 = peg$c129; + s0 = peg$c130; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c130); } + if (peg$silentFails === 0) { peg$fail(peg$c131); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c131) { - s0 = peg$c131; + if (input.substr(peg$currPos, 2) === peg$c132) { + s0 = peg$c132; peg$currPos += 2; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c132); } + if (peg$silentFails === 0) { peg$fail(peg$c133); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 13) { - s0 = peg$c133; + s0 = peg$c134; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c134); } + if (peg$silentFails === 0) { peg$fail(peg$c135); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8232) { - s0 = peg$c135; + s0 = peg$c136; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c136); } + if (peg$silentFails === 0) { peg$fail(peg$c137); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8233) { - s0 = peg$c137; + s0 = peg$c138; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c138); } + if (peg$silentFails === 0) { peg$fail(peg$c139); } } } } @@ -2952,7 +2953,7 @@ module.exports = (function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c128); } + if (peg$silentFails === 0) { peg$fail(peg$c129); } } return s0; @@ -2961,12 +2962,12 @@ module.exports = (function() { function peg$parseeolChar() { var s0; - if (peg$c139.test(input.charAt(peg$currPos))) { + if (peg$c140.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c140); } + if (peg$silentFails === 0) { peg$fail(peg$c141); } } return s0; @@ -2976,17 +2977,17 @@ module.exports = (function() { var s0, s1; peg$silentFails++; - if (peg$c142.test(input.charAt(peg$currPos))) { + if (peg$c143.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c143); } + if (peg$silentFails === 0) { peg$fail(peg$c144); } } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c141); } + if (peg$silentFails === 0) { peg$fail(peg$c142); } } return s0; diff --git a/spec/compiler/passes/generate-bytecode.spec.js b/spec/compiler/passes/generate-bytecode.spec.js index 829b78b..d9a1e4e 100644 --- a/spec/compiler/passes/generate-bytecode.spec.js +++ b/spec/compiler/passes/generate-bytecode.spec.js @@ -477,7 +477,7 @@ describe("compiler pass |generateBytecode|", function() { it("defines correct constants", function() { expect(pass).toChangeAST(grammar, constsDetails([ - '""', + 'null', '"a"', '{ type: "literal", value: "a", description: "\\"a\\"" }' ])); diff --git a/spec/generated-parser.spec.js b/spec/generated-parser.spec.js index f1912d4..c0fcff1 100644 --- a/spec/generated-parser.spec.js +++ b/spec/generated-parser.spec.js @@ -621,7 +621,7 @@ describe("generated parser", function() { it("matches correctly", function() { var parser = PEG.buildParser('start = "a"?', options); - expect(parser).toParse("", ""); + expect(parser).toParse("", null); expect(parser).toParse("a", "a"); }); }); @@ -1112,8 +1112,8 @@ describe("generated parser", function() { */ var parser = PEG.buildParser([ 'S = &(A "c") a:"a"+ B:B !("a" / "b" / "c") { return a.join("") + B; }', - 'A = a:"a" A:A? b:"b" { return a + A + b; }', - 'B = b:"b" B:B? c:"c" { return b + B + c; }' + 'A = a:"a" A:A? b:"b" { return [a, A, b].join(""); }', + 'B = b:"b" B:B? c:"c" { return [b, B, c].join(""); }' ].join("\n"), options); expect(parser).toParse("abc", "abc"); diff --git a/src/parser.pegjs b/src/parser.pegjs index dba4f37..e5d20e1 100644 --- a/src/parser.pegjs +++ b/src/parser.pegjs @@ -6,7 +6,7 @@ grammar = __ initializer:initializer? rules:rule+ { return { type: "grammar", - initializer: initializer !== "" ? initializer : null, + initializer: initializer, rules: rules }; } @@ -24,7 +24,7 @@ rule return { type: "rule", name: name, - expression: displayName !== "" + expression: displayName !== null ? { type: "named", name: displayName, @@ -249,10 +249,10 @@ class "character class" = "[" inverted:"^"? parts:(classCharacterRange / classCharacter)* "]" flags:"i"? __ { var partsConverted = utils.map(parts, function(part) { return part.data; }); var rawText = "[" - + inverted + + (inverted !== null ? inverted : "") + utils.map(parts, function(part) { return part.rawText; }).join("") + "]" - + flags; + + (flags !== null ? flags : ""); return { type: "class",