diff --git a/lib/compiler.js b/lib/compiler.js index 58abb5d..708e678 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -240,17 +240,26 @@ PEG.Compiler = { _uniqueIdentifierCounters: {}, - _resetUniqueIdentifierCounters: function() { - this._uniqueIdentifierCounters = {}; - }, - - /* Generates a unique identifier with specified prefix. */ + /* + * Generates a unique identifier with specified prefix. The sequence of + * generated identifiers with given prefix is repeatable and will be the same + * within different language runtimes. + */ generateUniqueIdentifier: function(prefix) { this._uniqueIdentifierCounters[prefix] = this._uniqueIdentifierCounters[prefix] || 0; return prefix + this._uniqueIdentifierCounters[prefix]++; }, + /* + * Resets internal counters of the unique identifier generator. The sequence + * of identifiers with given prefix generated by |generateUniqueIdentifier| + * will start from the beginning. + */ + resetUniqueIdentifierCounters: function() { + this._uniqueIdentifierCounters = {}; + }, + /* * Checks made on the grammar AST before compilation. Each check is a function * that is passed the AST and start rule and does not return anything. If the @@ -457,6 +466,15 @@ PEG.Compiler = { }, rule: function(node) { + /* + * We want to reset variable names at the beginning of every function so + * that a little change in the source grammar does not change variables in + * all the generated code. This is desired especially when one has the + * generated grammar stored in a VCS (this is true e.g. for our + * metagrammar). + */ + PEG.Compiler.resetUniqueIdentifierCounters(); + var resultVar = PEG.Compiler.generateUniqueIdentifier("result"); if (node.displayName !== null) { @@ -859,12 +877,6 @@ PEG.Compiler = { * generated parser and cause its malfunction. */ compileParser: function(ast, startRule) { - /* - * This ensures that the same grammar and start rule always generate exactly - * the same parser. - */ - this._resetUniqueIdentifierCounters(); - for (var i = 0; i < this._checks.length; i++) { this._checks[i](ast, startRule); } diff --git a/lib/metagrammar.js b/lib/metagrammar.js index ecabcd7..dfc0b99 100644 --- a/lib/metagrammar.js +++ b/lib/metagrammar.js @@ -129,37 +129,37 @@ PEG.grammarParser = (function(){ } - var savedPos1 = pos; - var result9 = parse_action(context); - if (result9 !== null) { - var result11 = parse_semicolon(context); - var result10 = result11 !== null ? result11 : ''; - if (result10 !== null) { - var result8 = [result9, result10]; + var savedPos0 = pos; + var result2 = parse_action(context); + if (result2 !== null) { + var result4 = parse_semicolon(context); + var result3 = result4 !== null ? result4 : ''; + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result8 = null; - pos = savedPos1; + var result1 = null; + pos = savedPos0; } } else { - var result8 = null; - pos = savedPos1; + var result1 = null; + pos = savedPos0; } - var result7 = result8 !== null + var result0 = result1 !== null ? (function(code) { return { type: "initializer", code: code }; - })(result8[0]) + })(result1[0]) : null; cache[cacheKey] = { nextPos: pos, - result: result7 + result: result0 }; - return result7; + return result0; } function parse_rule(context) { @@ -171,58 +171,58 @@ PEG.grammarParser = (function(){ } - var savedPos2 = pos; - var result14 = parse_identifier(context); - if (result14 !== null) { - var result21 = parse_literal(context); - if (result21 !== null) { - var result15 = result21; + var savedPos0 = pos; + var result2 = parse_identifier(context); + if (result2 !== null) { + var result9 = parse_literal(context); + if (result9 !== null) { + var result3 = result9; } else { if (input.substr(pos, 0) === "") { - var result20 = ""; + var result8 = ""; pos += 0; } else { - var result20 = null; + var result8 = null; if (context.reportMatchFailures) { matchFailed(quoteString("")); } } - if (result20 !== null) { - var result15 = result20; + if (result8 !== null) { + var result3 = result8; } else { - var result15 = null;; + var result3 = null;; }; } - if (result15 !== null) { - var result16 = parse_equals(context); - if (result16 !== null) { - var result17 = parse_choice(context); - if (result17 !== null) { - var result19 = parse_semicolon(context); - var result18 = result19 !== null ? result19 : ''; - if (result18 !== null) { - var result13 = [result14, result15, result16, result17, result18]; + if (result3 !== null) { + var result4 = parse_equals(context); + if (result4 !== null) { + var result5 = parse_choice(context); + if (result5 !== null) { + var result7 = parse_semicolon(context); + var result6 = result7 !== null ? result7 : ''; + if (result6 !== null) { + var result1 = [result2, result3, result4, result5, result6]; } else { - var result13 = null; - pos = savedPos2; + var result1 = null; + pos = savedPos0; } } else { - var result13 = null; - pos = savedPos2; + var result1 = null; + pos = savedPos0; } } else { - var result13 = null; - pos = savedPos2; + var result1 = null; + pos = savedPos0; } } else { - var result13 = null; - pos = savedPos2; + var result1 = null; + pos = savedPos0; } } else { - var result13 = null; - pos = savedPos2; + var result1 = null; + pos = savedPos0; } - var result12 = result13 !== null + var result0 = result1 !== null ? (function(name, displayName, expression) { return { type: "rule", @@ -230,16 +230,16 @@ PEG.grammarParser = (function(){ displayName: displayName !== "" ? displayName : null, expression: expression }; - })(result13[0], result13[1], result13[3]) + })(result1[0], result1[1], result1[3]) : null; cache[cacheKey] = { nextPos: pos, - result: result12 + result: result0 }; - return result12; + return result0; } function parse_choice(context) { @@ -251,52 +251,52 @@ PEG.grammarParser = (function(){ } - var savedPos3 = pos; - var result24 = parse_sequence(context); - if (result24 !== null) { - var result25 = []; - var savedPos4 = pos; - var result27 = parse_slash(context); - if (result27 !== null) { - var result28 = parse_sequence(context); - if (result28 !== null) { - var result26 = [result27, result28]; + var savedPos0 = pos; + var result2 = parse_sequence(context); + if (result2 !== null) { + var result3 = []; + var savedPos1 = pos; + var result5 = parse_slash(context); + if (result5 !== null) { + var result6 = parse_sequence(context); + if (result6 !== null) { + var result4 = [result5, result6]; } else { - var result26 = null; - pos = savedPos4; + var result4 = null; + pos = savedPos1; } } else { - var result26 = null; - pos = savedPos4; + var result4 = null; + pos = savedPos1; } - while (result26 !== null) { - result25.push(result26); - var savedPos4 = pos; - var result27 = parse_slash(context); - if (result27 !== null) { - var result28 = parse_sequence(context); - if (result28 !== null) { - var result26 = [result27, result28]; + while (result4 !== null) { + result3.push(result4); + var savedPos1 = pos; + var result5 = parse_slash(context); + if (result5 !== null) { + var result6 = parse_sequence(context); + if (result6 !== null) { + var result4 = [result5, result6]; } else { - var result26 = null; - pos = savedPos4; + var result4 = null; + pos = savedPos1; } } else { - var result26 = null; - pos = savedPos4; + var result4 = null; + pos = savedPos1; } } - if (result25 !== null) { - var result23 = [result24, result25]; + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result23 = null; - pos = savedPos3; + var result1 = null; + pos = savedPos0; } } else { - var result23 = null; - pos = savedPos3; + var result1 = null; + pos = savedPos0; } - var result22 = result23 !== null + var result0 = result1 !== null ? (function(head, tail) { if (tail.length > 0) { var alternatives = [head].concat(PEG.ArrayUtils.map( @@ -310,16 +310,16 @@ PEG.grammarParser = (function(){ } else { return head; } - })(result23[0], result23[1]) + })(result1[0], result1[1]) : null; cache[cacheKey] = { nextPos: pos, - result: result22 + result: result0 }; - return result22; + return result0; } function parse_sequence(context) { @@ -331,26 +331,26 @@ PEG.grammarParser = (function(){ } - var savedPos5 = pos; - var result35 = []; - var result37 = parse_labeled(context); - while (result37 !== null) { - result35.push(result37); - var result37 = parse_labeled(context); + var savedPos0 = pos; + var result6 = []; + var result8 = parse_labeled(context); + while (result8 !== null) { + result6.push(result8); + var result8 = parse_labeled(context); } - if (result35 !== null) { - var result36 = parse_action(context); - if (result36 !== null) { - var result34 = [result35, result36]; + if (result6 !== null) { + var result7 = parse_action(context); + if (result7 !== null) { + var result5 = [result6, result7]; } else { - var result34 = null; - pos = savedPos5; + var result5 = null; + pos = savedPos0; } } else { - var result34 = null; - pos = savedPos5; + var result5 = null; + pos = savedPos0; } - var result33 = result34 !== null + var result4 = result5 !== null ? (function(elements, code) { var expression = elements.length != 1 ? { @@ -363,18 +363,18 @@ PEG.grammarParser = (function(){ expression: expression, code: code }; - })(result34[0], result34[1]) + })(result5[0], result5[1]) : null; - if (result33 !== null) { - var result29 = result33; + if (result4 !== null) { + var result0 = result4; } else { - var result31 = []; - var result32 = parse_labeled(context); - while (result32 !== null) { - result31.push(result32); - var result32 = parse_labeled(context); + var result2 = []; + var result3 = parse_labeled(context); + while (result3 !== null) { + result2.push(result3); + var result3 = parse_labeled(context); } - var result30 = result31 !== null + var result1 = result2 !== null ? (function(elements) { return elements.length != 1 ? { @@ -382,12 +382,12 @@ PEG.grammarParser = (function(){ elements: elements } : elements[0]; - })(result31) + })(result2) : null; - if (result30 !== null) { - var result29 = result30; + if (result1 !== null) { + var result0 = result1; } else { - var result29 = null;; + var result0 = null;; }; } @@ -395,9 +395,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result29 + result: result0 }; - return result29; + return result0; } function parse_labeled(context) { @@ -409,43 +409,43 @@ PEG.grammarParser = (function(){ } - var savedPos6 = pos; - var result42 = parse_identifier(context); - if (result42 !== null) { - var result43 = parse_colon(context); - if (result43 !== null) { - var result44 = parse_prefixed(context); - if (result44 !== null) { - var result41 = [result42, result43, result44]; + var savedPos0 = pos; + var result4 = parse_identifier(context); + if (result4 !== null) { + var result5 = parse_colon(context); + if (result5 !== null) { + var result6 = parse_prefixed(context); + if (result6 !== null) { + var result3 = [result4, result5, result6]; } else { - var result41 = null; - pos = savedPos6; + var result3 = null; + pos = savedPos0; } } else { - var result41 = null; - pos = savedPos6; + var result3 = null; + pos = savedPos0; } } else { - var result41 = null; - pos = savedPos6; + var result3 = null; + pos = savedPos0; } - var result40 = result41 !== null + var result2 = result3 !== null ? (function(label, expression) { return { type: "labeled", label: label, expression: expression }; - })(result41[0], result41[2]) + })(result3[0], result3[2]) : null; - if (result40 !== null) { - var result38 = result40; + if (result2 !== null) { + var result0 = result2; } else { - var result39 = parse_prefixed(context); - if (result39 !== null) { - var result38 = result39; + var result1 = parse_prefixed(context); + if (result1 !== null) { + var result0 = result1; } else { - var result38 = null;; + var result0 = null;; }; } @@ -453,9 +453,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result38 + result: result0 }; - return result38; + return result0; } function parse_prefixed(context) { @@ -467,61 +467,61 @@ PEG.grammarParser = (function(){ } - var savedPos8 = pos; - var result53 = parse_and(context); - if (result53 !== null) { - var result54 = parse_suffixed(context); - if (result54 !== null) { - var result52 = [result53, result54]; + var savedPos1 = pos; + var result8 = parse_and(context); + if (result8 !== null) { + var result9 = parse_suffixed(context); + if (result9 !== null) { + var result7 = [result8, result9]; } else { - var result52 = null; - pos = savedPos8; + var result7 = null; + pos = savedPos1; } } else { - var result52 = null; - pos = savedPos8; + var result7 = null; + pos = savedPos1; } - var result51 = result52 !== null + var result6 = result7 !== null ? (function(expression) { return { type: "and_predicate", expression: expression }; - })(result52[1]) + })(result7[1]) : null; - if (result51 !== null) { - var result45 = result51; + if (result6 !== null) { + var result0 = result6; } else { - var savedPos7 = pos; - var result49 = parse_not(context); - if (result49 !== null) { - var result50 = parse_suffixed(context); - if (result50 !== null) { - var result48 = [result49, result50]; + var savedPos0 = pos; + var result4 = parse_not(context); + if (result4 !== null) { + var result5 = parse_suffixed(context); + if (result5 !== null) { + var result3 = [result4, result5]; } else { - var result48 = null; - pos = savedPos7; + var result3 = null; + pos = savedPos0; } } else { - var result48 = null; - pos = savedPos7; + var result3 = null; + pos = savedPos0; } - var result47 = result48 !== null + var result2 = result3 !== null ? (function(expression) { return { type: "not_predicate", expression: expression }; - })(result48[1]) + })(result3[1]) : null; - if (result47 !== null) { - var result45 = result47; + if (result2 !== null) { + var result0 = result2; } else { - var result46 = parse_suffixed(context); - if (result46 !== null) { - var result45 = result46; + var result1 = parse_suffixed(context); + if (result1 !== null) { + var result0 = result1; } else { - var result45 = null;; + var result0 = null;; }; }; } @@ -530,9 +530,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result45 + result: result0 }; - return result45; + return result0; } function parse_suffixed(context) { @@ -544,86 +544,86 @@ PEG.grammarParser = (function(){ } - var savedPos11 = pos; - var result67 = parse_primary(context); - if (result67 !== null) { - var result68 = parse_question(context); - if (result68 !== null) { - var result66 = [result67, result68]; + var savedPos2 = pos; + var result12 = parse_primary(context); + if (result12 !== null) { + var result13 = parse_question(context); + if (result13 !== null) { + var result11 = [result12, result13]; } else { - var result66 = null; - pos = savedPos11; + var result11 = null; + pos = savedPos2; } } else { - var result66 = null; - pos = savedPos11; + var result11 = null; + pos = savedPos2; } - var result65 = result66 !== null + var result10 = result11 !== null ? (function(expression) { return { type: "optional", expression: expression }; - })(result66[0]) + })(result11[0]) : null; - if (result65 !== null) { - var result55 = result65; + if (result10 !== null) { + var result0 = result10; } else { - var savedPos10 = pos; - var result63 = parse_primary(context); - if (result63 !== null) { - var result64 = parse_star(context); - if (result64 !== null) { - var result62 = [result63, result64]; + var savedPos1 = pos; + var result8 = parse_primary(context); + if (result8 !== null) { + var result9 = parse_star(context); + if (result9 !== null) { + var result7 = [result8, result9]; } else { - var result62 = null; - pos = savedPos10; + var result7 = null; + pos = savedPos1; } } else { - var result62 = null; - pos = savedPos10; + var result7 = null; + pos = savedPos1; } - var result61 = result62 !== null + var result6 = result7 !== null ? (function(expression) { return { type: "zero_or_more", expression: expression }; - })(result62[0]) + })(result7[0]) : null; - if (result61 !== null) { - var result55 = result61; + if (result6 !== null) { + var result0 = result6; } else { - var savedPos9 = pos; - var result59 = parse_primary(context); - if (result59 !== null) { - var result60 = parse_plus(context); - if (result60 !== null) { - var result58 = [result59, result60]; + var savedPos0 = pos; + var result4 = parse_primary(context); + if (result4 !== null) { + var result5 = parse_plus(context); + if (result5 !== null) { + var result3 = [result4, result5]; } else { - var result58 = null; - pos = savedPos9; + var result3 = null; + pos = savedPos0; } } else { - var result58 = null; - pos = savedPos9; + var result3 = null; + pos = savedPos0; } - var result57 = result58 !== null + var result2 = result3 !== null ? (function(expression) { return { type: "one_or_more", expression: expression }; - })(result58[0]) + })(result3[0]) : null; - if (result57 !== null) { - var result55 = result57; + if (result2 !== null) { + var result0 = result2; } else { - var result56 = parse_primary(context); - if (result56 !== null) { - var result55 = result56; + var result1 = parse_primary(context); + if (result1 !== null) { + var result0 = result1; } else { - var result55 = null;; + var result0 = null;; }; }; }; @@ -633,9 +633,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result55 + result: result0 }; - return result55; + return result0; } function parse_primary(context) { @@ -647,122 +647,122 @@ PEG.grammarParser = (function(){ } - var savedPos13 = pos; - var result82 = parse_identifier(context); - if (result82 !== null) { - var savedPos14 = pos; + var savedPos1 = pos; + var result13 = parse_identifier(context); + if (result13 !== null) { + var savedPos2 = pos; var savedReportMatchFailuresVar0 = context.reportMatchFailures; context.reportMatchFailures = false; - var savedPos15 = pos; - var result88 = parse_literal(context); - if (result88 !== null) { - var result85 = result88; + var savedPos3 = pos; + var result19 = parse_literal(context); + if (result19 !== null) { + var result16 = result19; } else { if (input.substr(pos, 0) === "") { - var result87 = ""; + var result18 = ""; pos += 0; } else { - var result87 = null; + var result18 = null; if (context.reportMatchFailures) { matchFailed(quoteString("")); } } - if (result87 !== null) { - var result85 = result87; + if (result18 !== null) { + var result16 = result18; } else { - var result85 = null;; + var result16 = null;; }; } - if (result85 !== null) { - var result86 = parse_equals(context); - if (result86 !== null) { - var result84 = [result85, result86]; + if (result16 !== null) { + var result17 = parse_equals(context); + if (result17 !== null) { + var result15 = [result16, result17]; } else { - var result84 = null; - pos = savedPos15; + var result15 = null; + pos = savedPos3; } } else { - var result84 = null; - pos = savedPos15; + var result15 = null; + pos = savedPos3; } context.reportMatchFailures = savedReportMatchFailuresVar0; - if (result84 === null) { - var result83 = ''; + if (result15 === null) { + var result14 = ''; } else { - var result83 = null; - pos = savedPos14; + var result14 = null; + pos = savedPos2; } - if (result83 !== null) { - var result81 = [result82, result83]; + if (result14 !== null) { + var result12 = [result13, result14]; } else { - var result81 = null; - pos = savedPos13; + var result12 = null; + pos = savedPos1; } } else { - var result81 = null; - pos = savedPos13; + var result12 = null; + pos = savedPos1; } - var result80 = result81 !== null + var result11 = result12 !== null ? (function(name) { return { type: "rule_ref", name: name }; - })(result81[0]) + })(result12[0]) : null; - if (result80 !== null) { - var result69 = result80; + if (result11 !== null) { + var result0 = result11; } else { - var result79 = parse_literal(context); - var result78 = result79 !== null + var result10 = parse_literal(context); + var result9 = result10 !== null ? (function(value) { return { type: "literal", value: value }; - })(result79) + })(result10) : null; - if (result78 !== null) { - var result69 = result78; + if (result9 !== null) { + var result0 = result9; } else { - var result77 = parse_dot(context); - var result76 = result77 !== null + var result8 = parse_dot(context); + var result7 = result8 !== null ? (function() { return { type: "any" }; })() : null; - if (result76 !== null) { - var result69 = result76; + if (result7 !== null) { + var result0 = result7; } else { - var result75 = parse_class(context); - if (result75 !== null) { - var result69 = result75; + var result6 = parse_class(context); + if (result6 !== null) { + var result0 = result6; } else { - var savedPos12 = pos; - var result72 = parse_lparen(context); - if (result72 !== null) { - var result73 = parse_choice(context); - if (result73 !== null) { - var result74 = parse_rparen(context); - if (result74 !== null) { - var result71 = [result72, result73, result74]; + var savedPos0 = pos; + var result3 = parse_lparen(context); + if (result3 !== null) { + var result4 = parse_choice(context); + if (result4 !== null) { + var result5 = parse_rparen(context); + if (result5 !== null) { + var result2 = [result3, result4, result5]; } else { - var result71 = null; - pos = savedPos12; + var result2 = null; + pos = savedPos0; } } else { - var result71 = null; - pos = savedPos12; + var result2 = null; + pos = savedPos0; } } else { - var result71 = null; - pos = savedPos12; + var result2 = null; + pos = savedPos0; } - var result70 = result71 !== null - ? (function(expression) { return expression; })(result71[1]) + var result1 = result2 !== null + ? (function(expression) { return expression; })(result2[1]) : null; - if (result70 !== null) { - var result69 = result70; + if (result1 !== null) { + var result0 = result1; } else { - var result69 = null;; + var result0 = null;; }; }; }; @@ -773,9 +773,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result69 + result: result0 }; - return result69; + return result0; } function parse_action(context) { @@ -788,33 +788,33 @@ PEG.grammarParser = (function(){ var savedReportMatchFailures = context.reportMatchFailures; context.reportMatchFailures = false; - var savedPos16 = pos; - var result91 = parse_braced(context); - if (result91 !== null) { - var result92 = parse___(context); - if (result92 !== null) { - var result90 = [result91, result92]; + var savedPos0 = pos; + var result2 = parse_braced(context); + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result90 = null; - pos = savedPos16; + var result1 = null; + pos = savedPos0; } } else { - var result90 = null; - pos = savedPos16; + var result1 = null; + pos = savedPos0; } - var result89 = result90 !== null - ? (function(braced) { return braced.substr(1, braced.length - 2); })(result90[0]) + var result0 = result1 !== null + ? (function(braced) { return braced.substr(1, braced.length - 2); })(result1[0]) : null; context.reportMatchFailures = savedReportMatchFailures; - if (context.reportMatchFailures && result89 === null) { + if (context.reportMatchFailures && result0 === null) { matchFailed("action"); } cache[cacheKey] = { nextPos: pos, - result: result89 + result: result0 }; - return result89; + return result0; } function parse_braced(context) { @@ -826,80 +826,80 @@ PEG.grammarParser = (function(){ } - var savedPos17 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "{") { - var result95 = "{"; + var result2 = "{"; pos += 1; } else { - var result95 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("{")); } } - if (result95 !== null) { - var result96 = []; - var result100 = parse_braced(context); - if (result100 !== null) { - var result98 = result100; + if (result2 !== null) { + var result3 = []; + var result7 = parse_braced(context); + if (result7 !== null) { + var result5 = result7; } else { - var result99 = parse_nonBraceCharacter(context); - if (result99 !== null) { - var result98 = result99; + var result6 = parse_nonBraceCharacter(context); + if (result6 !== null) { + var result5 = result6; } else { - var result98 = null;; + var result5 = null;; }; } - while (result98 !== null) { - result96.push(result98); - var result100 = parse_braced(context); - if (result100 !== null) { - var result98 = result100; + while (result5 !== null) { + result3.push(result5); + var result7 = parse_braced(context); + if (result7 !== null) { + var result5 = result7; } else { - var result99 = parse_nonBraceCharacter(context); - if (result99 !== null) { - var result98 = result99; + var result6 = parse_nonBraceCharacter(context); + if (result6 !== null) { + var result5 = result6; } else { - var result98 = null;; + var result5 = null;; }; } } - if (result96 !== null) { + if (result3 !== null) { if (input.substr(pos, 1) === "}") { - var result97 = "}"; + var result4 = "}"; pos += 1; } else { - var result97 = null; + var result4 = null; if (context.reportMatchFailures) { matchFailed(quoteString("}")); } } - if (result97 !== null) { - var result94 = [result95, result96, result97]; + if (result4 !== null) { + var result1 = [result2, result3, result4]; } else { - var result94 = null; - pos = savedPos17; + var result1 = null; + pos = savedPos0; } } else { - var result94 = null; - pos = savedPos17; + var result1 = null; + pos = savedPos0; } } else { - var result94 = null; - pos = savedPos17; + var result1 = null; + pos = savedPos0; } - var result93 = result94 !== null + var result0 = result1 !== null ? (function(parts) { return "{" + parts.join("") + "}"; - })(result94[1]) + })(result1[1]) : null; cache[cacheKey] = { nextPos: pos, - result: result93 + result: result0 }; - return result93; + return result0; } function parse_nonBraceCharacters(context) { @@ -911,27 +911,27 @@ PEG.grammarParser = (function(){ } - var result103 = parse_nonBraceCharacter(context); - if (result103 !== null) { - var result102 = []; - while (result103 !== null) { - result102.push(result103); - var result103 = parse_nonBraceCharacter(context); + var result2 = parse_nonBraceCharacter(context); + if (result2 !== null) { + var result1 = []; + while (result2 !== null) { + result1.push(result2); + var result2 = parse_nonBraceCharacter(context); } } else { - var result102 = null; + var result1 = null; } - var result101 = result102 !== null - ? (function(chars) { return chars.join(""); })(result102) + var result0 = result1 !== null + ? (function(chars) { return chars.join(""); })(result1) : null; cache[cacheKey] = { nextPos: pos, - result: result101 + result: result0 }; - return result101; + return result0; } function parse_nonBraceCharacter(context) { @@ -944,10 +944,10 @@ PEG.grammarParser = (function(){ if (input.substr(pos).match(/^[^{}]/) !== null) { - var result104 = input.charAt(pos); + var result0 = input.charAt(pos); pos++; } else { - var result104 = null; + var result0 = null; if (context.reportMatchFailures) { matchFailed("[^{}]"); } @@ -957,9 +957,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result104 + result: result0 }; - return result104; + return result0; } function parse_equals(context) { @@ -971,29 +971,29 @@ PEG.grammarParser = (function(){ } - var savedPos18 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "=") { - var result107 = "="; + var result2 = "="; pos += 1; } else { - var result107 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("=")); } } - if (result107 !== null) { - var result108 = parse___(context); - if (result108 !== null) { - var result106 = [result107, result108]; + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result106 = null; - pos = savedPos18; + var result1 = null; + pos = savedPos0; } } else { - var result106 = null; - pos = savedPos18; + var result1 = null; + pos = savedPos0; } - var result105 = result106 !== null + var result0 = result1 !== null ? (function() { return "="; })() : null; @@ -1001,9 +1001,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result105 + result: result0 }; - return result105; + return result0; } function parse_colon(context) { @@ -1015,29 +1015,29 @@ PEG.grammarParser = (function(){ } - var savedPos19 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === ":") { - var result111 = ":"; + var result2 = ":"; pos += 1; } else { - var result111 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString(":")); } } - if (result111 !== null) { - var result112 = parse___(context); - if (result112 !== null) { - var result110 = [result111, result112]; + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result110 = null; - pos = savedPos19; + var result1 = null; + pos = savedPos0; } } else { - var result110 = null; - pos = savedPos19; + var result1 = null; + pos = savedPos0; } - var result109 = result110 !== null + var result0 = result1 !== null ? (function() { return ":"; })() : null; @@ -1045,9 +1045,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result109 + result: result0 }; - return result109; + return result0; } function parse_semicolon(context) { @@ -1059,29 +1059,29 @@ PEG.grammarParser = (function(){ } - var savedPos20 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === ";") { - var result115 = ";"; + var result2 = ";"; pos += 1; } else { - var result115 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString(";")); } } - if (result115 !== null) { - var result116 = parse___(context); - if (result116 !== null) { - var result114 = [result115, result116]; + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result114 = null; - pos = savedPos20; + var result1 = null; + pos = savedPos0; } } else { - var result114 = null; - pos = savedPos20; + var result1 = null; + pos = savedPos0; } - var result113 = result114 !== null + var result0 = result1 !== null ? (function() { return ";"; })() : null; @@ -1089,9 +1089,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result113 + result: result0 }; - return result113; + return result0; } function parse_slash(context) { @@ -1103,29 +1103,29 @@ PEG.grammarParser = (function(){ } - var savedPos21 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "/") { - var result119 = "/"; + var result2 = "/"; pos += 1; } else { - var result119 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("/")); } } - if (result119 !== null) { - var result120 = parse___(context); - if (result120 !== null) { - var result118 = [result119, result120]; + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result118 = null; - pos = savedPos21; + var result1 = null; + pos = savedPos0; } } else { - var result118 = null; - pos = savedPos21; + var result1 = null; + pos = savedPos0; } - var result117 = result118 !== null + var result0 = result1 !== null ? (function() { return "/"; })() : null; @@ -1133,9 +1133,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result117 + result: result0 }; - return result117; + return result0; } function parse_and(context) { @@ -1147,29 +1147,29 @@ PEG.grammarParser = (function(){ } - var savedPos22 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "&") { - var result123 = "&"; + var result2 = "&"; pos += 1; } else { - var result123 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("&")); } } - if (result123 !== null) { - var result124 = parse___(context); - if (result124 !== null) { - var result122 = [result123, result124]; + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result122 = null; - pos = savedPos22; + var result1 = null; + pos = savedPos0; } } else { - var result122 = null; - pos = savedPos22; + var result1 = null; + pos = savedPos0; } - var result121 = result122 !== null + var result0 = result1 !== null ? (function() { return "&"; })() : null; @@ -1177,9 +1177,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result121 + result: result0 }; - return result121; + return result0; } function parse_not(context) { @@ -1191,29 +1191,29 @@ PEG.grammarParser = (function(){ } - var savedPos23 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "!") { - var result127 = "!"; + var result2 = "!"; pos += 1; } else { - var result127 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("!")); } } - if (result127 !== null) { - var result128 = parse___(context); - if (result128 !== null) { - var result126 = [result127, result128]; + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result126 = null; - pos = savedPos23; + var result1 = null; + pos = savedPos0; } } else { - var result126 = null; - pos = savedPos23; + var result1 = null; + pos = savedPos0; } - var result125 = result126 !== null + var result0 = result1 !== null ? (function() { return "!"; })() : null; @@ -1221,9 +1221,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result125 + result: result0 }; - return result125; + return result0; } function parse_question(context) { @@ -1235,29 +1235,29 @@ PEG.grammarParser = (function(){ } - var savedPos24 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "?") { - var result131 = "?"; + var result2 = "?"; pos += 1; } else { - var result131 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("?")); } } - if (result131 !== null) { - var result132 = parse___(context); - if (result132 !== null) { - var result130 = [result131, result132]; + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result130 = null; - pos = savedPos24; + var result1 = null; + pos = savedPos0; } } else { - var result130 = null; - pos = savedPos24; + var result1 = null; + pos = savedPos0; } - var result129 = result130 !== null + var result0 = result1 !== null ? (function() { return "?"; })() : null; @@ -1265,9 +1265,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result129 + result: result0 }; - return result129; + return result0; } function parse_star(context) { @@ -1279,29 +1279,29 @@ PEG.grammarParser = (function(){ } - var savedPos25 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "*") { - var result135 = "*"; + var result2 = "*"; pos += 1; } else { - var result135 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("*")); } } - if (result135 !== null) { - var result136 = parse___(context); - if (result136 !== null) { - var result134 = [result135, result136]; + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result134 = null; - pos = savedPos25; + var result1 = null; + pos = savedPos0; } } else { - var result134 = null; - pos = savedPos25; + var result1 = null; + pos = savedPos0; } - var result133 = result134 !== null + var result0 = result1 !== null ? (function() { return "*"; })() : null; @@ -1309,9 +1309,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result133 + result: result0 }; - return result133; + return result0; } function parse_plus(context) { @@ -1323,29 +1323,29 @@ PEG.grammarParser = (function(){ } - var savedPos26 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "+") { - var result139 = "+"; + var result2 = "+"; pos += 1; } else { - var result139 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("+")); } } - if (result139 !== null) { - var result140 = parse___(context); - if (result140 !== null) { - var result138 = [result139, result140]; + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result138 = null; - pos = savedPos26; + var result1 = null; + pos = savedPos0; } } else { - var result138 = null; - pos = savedPos26; + var result1 = null; + pos = savedPos0; } - var result137 = result138 !== null + var result0 = result1 !== null ? (function() { return "+"; })() : null; @@ -1353,9 +1353,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result137 + result: result0 }; - return result137; + return result0; } function parse_lparen(context) { @@ -1367,29 +1367,29 @@ PEG.grammarParser = (function(){ } - var savedPos27 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "(") { - var result143 = "("; + var result2 = "("; pos += 1; } else { - var result143 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("(")); } } - if (result143 !== null) { - var result144 = parse___(context); - if (result144 !== null) { - var result142 = [result143, result144]; + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result142 = null; - pos = savedPos27; + var result1 = null; + pos = savedPos0; } } else { - var result142 = null; - pos = savedPos27; + var result1 = null; + pos = savedPos0; } - var result141 = result142 !== null + var result0 = result1 !== null ? (function() { return "("; })() : null; @@ -1397,9 +1397,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result141 + result: result0 }; - return result141; + return result0; } function parse_rparen(context) { @@ -1411,29 +1411,29 @@ PEG.grammarParser = (function(){ } - var savedPos28 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === ")") { - var result147 = ")"; + var result2 = ")"; pos += 1; } else { - var result147 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString(")")); } } - if (result147 !== null) { - var result148 = parse___(context); - if (result148 !== null) { - var result146 = [result147, result148]; + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result146 = null; - pos = savedPos28; + var result1 = null; + pos = savedPos0; } } else { - var result146 = null; - pos = savedPos28; + var result1 = null; + pos = savedPos0; } - var result145 = result146 !== null + var result0 = result1 !== null ? (function() { return ")"; })() : null; @@ -1441,9 +1441,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result145 + result: result0 }; - return result145; + return result0; } function parse_dot(context) { @@ -1455,29 +1455,29 @@ PEG.grammarParser = (function(){ } - var savedPos29 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === ".") { - var result151 = "."; + var result2 = "."; pos += 1; } else { - var result151 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString(".")); } } - if (result151 !== null) { - var result152 = parse___(context); - if (result152 !== null) { - var result150 = [result151, result152]; + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result150 = null; - pos = savedPos29; + var result1 = null; + pos = savedPos0; } } else { - var result150 = null; - pos = savedPos29; + var result1 = null; + pos = savedPos0; } - var result149 = result150 !== null + var result0 = result1 !== null ? (function() { return "."; })() : null; @@ -1485,9 +1485,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result149 + result: result0 }; - return result149; + return result0; } function parse_identifier(context) { @@ -1500,149 +1500,149 @@ PEG.grammarParser = (function(){ var savedReportMatchFailures = context.reportMatchFailures; context.reportMatchFailures = false; - var savedPos30 = pos; - var result165 = parse_letter(context); - if (result165 !== null) { - var result155 = result165; + var savedPos0 = pos; + var result12 = parse_letter(context); + if (result12 !== null) { + var result2 = result12; } else { if (input.substr(pos, 1) === "_") { - var result164 = "_"; + var result11 = "_"; pos += 1; } else { - var result164 = null; + var result11 = null; if (context.reportMatchFailures) { matchFailed(quoteString("_")); } } - if (result164 !== null) { - var result155 = result164; + if (result11 !== null) { + var result2 = result11; } else { if (input.substr(pos, 1) === "$") { - var result163 = "$"; + var result10 = "$"; pos += 1; } else { - var result163 = null; + var result10 = null; if (context.reportMatchFailures) { matchFailed(quoteString("$")); } } - if (result163 !== null) { - var result155 = result163; + if (result10 !== null) { + var result2 = result10; } else { - var result155 = null;; + var result2 = null;; }; }; } - if (result155 !== null) { - var result156 = []; - var result162 = parse_letter(context); - if (result162 !== null) { - var result158 = result162; + if (result2 !== null) { + var result3 = []; + var result9 = parse_letter(context); + if (result9 !== null) { + var result5 = result9; } else { - var result161 = parse_digit(context); - if (result161 !== null) { - var result158 = result161; + var result8 = parse_digit(context); + if (result8 !== null) { + var result5 = result8; } else { if (input.substr(pos, 1) === "_") { - var result160 = "_"; + var result7 = "_"; pos += 1; } else { - var result160 = null; + var result7 = null; if (context.reportMatchFailures) { matchFailed(quoteString("_")); } } - if (result160 !== null) { - var result158 = result160; + if (result7 !== null) { + var result5 = result7; } else { if (input.substr(pos, 1) === "$") { - var result159 = "$"; + var result6 = "$"; pos += 1; } else { - var result159 = null; + var result6 = null; if (context.reportMatchFailures) { matchFailed(quoteString("$")); } } - if (result159 !== null) { - var result158 = result159; + if (result6 !== null) { + var result5 = result6; } else { - var result158 = null;; + var result5 = null;; }; }; }; } - while (result158 !== null) { - result156.push(result158); - var result162 = parse_letter(context); - if (result162 !== null) { - var result158 = result162; + while (result5 !== null) { + result3.push(result5); + var result9 = parse_letter(context); + if (result9 !== null) { + var result5 = result9; } else { - var result161 = parse_digit(context); - if (result161 !== null) { - var result158 = result161; + var result8 = parse_digit(context); + if (result8 !== null) { + var result5 = result8; } else { if (input.substr(pos, 1) === "_") { - var result160 = "_"; + var result7 = "_"; pos += 1; } else { - var result160 = null; + var result7 = null; if (context.reportMatchFailures) { matchFailed(quoteString("_")); } } - if (result160 !== null) { - var result158 = result160; + if (result7 !== null) { + var result5 = result7; } else { if (input.substr(pos, 1) === "$") { - var result159 = "$"; + var result6 = "$"; pos += 1; } else { - var result159 = null; + var result6 = null; if (context.reportMatchFailures) { matchFailed(quoteString("$")); } } - if (result159 !== null) { - var result158 = result159; + if (result6 !== null) { + var result5 = result6; } else { - var result158 = null;; + var result5 = null;; }; }; }; } } - if (result156 !== null) { - var result157 = parse___(context); - if (result157 !== null) { - var result154 = [result155, result156, result157]; + if (result3 !== null) { + var result4 = parse___(context); + if (result4 !== null) { + var result1 = [result2, result3, result4]; } else { - var result154 = null; - pos = savedPos30; + var result1 = null; + pos = savedPos0; } } else { - var result154 = null; - pos = savedPos30; + var result1 = null; + pos = savedPos0; } } else { - var result154 = null; - pos = savedPos30; + var result1 = null; + pos = savedPos0; } - var result153 = result154 !== null + var result0 = result1 !== null ? (function(head, tail) { return head + tail.join(""); - })(result154[0], result154[1]) + })(result1[0], result1[1]) : null; context.reportMatchFailures = savedReportMatchFailures; - if (context.reportMatchFailures && result153 === null) { + if (context.reportMatchFailures && result0 === null) { matchFailed("identifier"); } cache[cacheKey] = { nextPos: pos, - result: result153 + result: result0 }; - return result153; + return result0; } function parse_literal(context) { @@ -1655,43 +1655,43 @@ PEG.grammarParser = (function(){ var savedReportMatchFailures = context.reportMatchFailures; context.reportMatchFailures = false; - var savedPos31 = pos; - var result171 = parse_doubleQuotedLiteral(context); - if (result171 !== null) { - var result168 = result171; + var savedPos0 = pos; + var result5 = parse_doubleQuotedLiteral(context); + if (result5 !== null) { + var result2 = result5; } else { - var result170 = parse_singleQuotedLiteral(context); - if (result170 !== null) { - var result168 = result170; + var result4 = parse_singleQuotedLiteral(context); + if (result4 !== null) { + var result2 = result4; } else { - var result168 = null;; + var result2 = null;; }; } - if (result168 !== null) { - var result169 = parse___(context); - if (result169 !== null) { - var result167 = [result168, result169]; + if (result2 !== null) { + var result3 = parse___(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result167 = null; - pos = savedPos31; + var result1 = null; + pos = savedPos0; } } else { - var result167 = null; - pos = savedPos31; + var result1 = null; + pos = savedPos0; } - var result166 = result167 !== null - ? (function(literal) { return literal; })(result167[0]) + var result0 = result1 !== null + ? (function(literal) { return literal; })(result1[0]) : null; context.reportMatchFailures = savedReportMatchFailures; - if (context.reportMatchFailures && result166 === null) { + if (context.reportMatchFailures && result0 === null) { matchFailed("literal"); } cache[cacheKey] = { nextPos: pos, - result: result166 + result: result0 }; - return result166; + return result0; } function parse_doubleQuotedLiteral(context) { @@ -1703,58 +1703,58 @@ PEG.grammarParser = (function(){ } - var savedPos32 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "\"") { - var result174 = "\""; + var result2 = "\""; pos += 1; } else { - var result174 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\"")); } } - if (result174 !== null) { - var result175 = []; - var result177 = parse_doubleQuotedCharacter(context); - while (result177 !== null) { - result175.push(result177); - var result177 = parse_doubleQuotedCharacter(context); + if (result2 !== null) { + var result3 = []; + var result5 = parse_doubleQuotedCharacter(context); + while (result5 !== null) { + result3.push(result5); + var result5 = parse_doubleQuotedCharacter(context); } - if (result175 !== null) { + if (result3 !== null) { if (input.substr(pos, 1) === "\"") { - var result176 = "\""; + var result4 = "\""; pos += 1; } else { - var result176 = null; + var result4 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\"")); } } - if (result176 !== null) { - var result173 = [result174, result175, result176]; + if (result4 !== null) { + var result1 = [result2, result3, result4]; } else { - var result173 = null; - pos = savedPos32; + var result1 = null; + pos = savedPos0; } } else { - var result173 = null; - pos = savedPos32; + var result1 = null; + pos = savedPos0; } } else { - var result173 = null; - pos = savedPos32; + var result1 = null; + pos = savedPos0; } - var result172 = result173 !== null - ? (function(chars) { return chars.join(""); })(result173[1]) + var result0 = result1 !== null + ? (function(chars) { return chars.join(""); })(result1[1]) : null; cache[cacheKey] = { nextPos: pos, - result: result172 + result: result0 }; - return result172; + return result0; } function parse_doubleQuotedCharacter(context) { @@ -1766,31 +1766,31 @@ PEG.grammarParser = (function(){ } - var result184 = parse_simpleDoubleQuotedCharacter(context); - if (result184 !== null) { - var result178 = result184; + var result6 = parse_simpleDoubleQuotedCharacter(context); + if (result6 !== null) { + var result0 = result6; } else { - var result183 = parse_simpleEscapeSequence(context); - if (result183 !== null) { - var result178 = result183; + var result5 = parse_simpleEscapeSequence(context); + if (result5 !== null) { + var result0 = result5; } else { - var result182 = parse_zeroEscapeSequence(context); - if (result182 !== null) { - var result178 = result182; + var result4 = parse_zeroEscapeSequence(context); + if (result4 !== null) { + var result0 = result4; } else { - var result181 = parse_hexEscapeSequence(context); - if (result181 !== null) { - var result178 = result181; + var result3 = parse_hexEscapeSequence(context); + if (result3 !== null) { + var result0 = result3; } else { - var result180 = parse_unicodeEscapeSequence(context); - if (result180 !== null) { - var result178 = result180; + var result2 = parse_unicodeEscapeSequence(context); + if (result2 !== null) { + var result0 = result2; } else { - var result179 = parse_eolEscapeSequence(context); - if (result179 !== null) { - var result178 = result179; + var result1 = parse_eolEscapeSequence(context); + if (result1 !== null) { + var result0 = result1; } else { - var result178 = null;; + var result0 = null;; }; }; }; @@ -1802,9 +1802,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result178 + result: result0 }; - return result178; + return result0; } function parse_simpleDoubleQuotedCharacter(context) { @@ -1816,80 +1816,80 @@ PEG.grammarParser = (function(){ } - var savedPos33 = pos; - var savedPos34 = pos; - var savedReportMatchFailuresVar1 = context.reportMatchFailures; + var savedPos0 = pos; + var savedPos1 = pos; + var savedReportMatchFailuresVar0 = context.reportMatchFailures; context.reportMatchFailures = false; if (input.substr(pos, 1) === "\"") { - var result192 = "\""; + var result7 = "\""; pos += 1; } else { - var result192 = null; + var result7 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\"")); } } - if (result192 !== null) { - var result189 = result192; + if (result7 !== null) { + var result4 = result7; } else { if (input.substr(pos, 1) === "\\") { - var result191 = "\\"; + var result6 = "\\"; pos += 1; } else { - var result191 = null; + var result6 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\\")); } } - if (result191 !== null) { - var result189 = result191; + if (result6 !== null) { + var result4 = result6; } else { - var result190 = parse_eolChar(context); - if (result190 !== null) { - var result189 = result190; + var result5 = parse_eolChar(context); + if (result5 !== null) { + var result4 = result5; } else { - var result189 = null;; + var result4 = null;; }; }; } - context.reportMatchFailures = savedReportMatchFailuresVar1; - if (result189 === null) { - var result187 = ''; + context.reportMatchFailures = savedReportMatchFailuresVar0; + if (result4 === null) { + var result2 = ''; } else { - var result187 = null; - pos = savedPos34; + var result2 = null; + pos = savedPos1; } - if (result187 !== null) { + if (result2 !== null) { if (input.length > pos) { - var result188 = input.charAt(pos); + var result3 = input.charAt(pos); pos++; } else { - var result188 = null; + var result3 = null; if (context.reportMatchFailures) { matchFailed('any character'); } } - if (result188 !== null) { - var result186 = [result187, result188]; + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result186 = null; - pos = savedPos33; + var result1 = null; + pos = savedPos0; } } else { - var result186 = null; - pos = savedPos33; + var result1 = null; + pos = savedPos0; } - var result185 = result186 !== null - ? (function(char_) { return char_; })(result186[1]) + var result0 = result1 !== null + ? (function(char_) { return char_; })(result1[1]) : null; cache[cacheKey] = { nextPos: pos, - result: result185 + result: result0 }; - return result185; + return result0; } function parse_singleQuotedLiteral(context) { @@ -1901,58 +1901,58 @@ PEG.grammarParser = (function(){ } - var savedPos35 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "'") { - var result195 = "'"; + var result2 = "'"; pos += 1; } else { - var result195 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("'")); } } - if (result195 !== null) { - var result196 = []; - var result198 = parse_singleQuotedCharacter(context); - while (result198 !== null) { - result196.push(result198); - var result198 = parse_singleQuotedCharacter(context); + if (result2 !== null) { + var result3 = []; + var result5 = parse_singleQuotedCharacter(context); + while (result5 !== null) { + result3.push(result5); + var result5 = parse_singleQuotedCharacter(context); } - if (result196 !== null) { + if (result3 !== null) { if (input.substr(pos, 1) === "'") { - var result197 = "'"; + var result4 = "'"; pos += 1; } else { - var result197 = null; + var result4 = null; if (context.reportMatchFailures) { matchFailed(quoteString("'")); } } - if (result197 !== null) { - var result194 = [result195, result196, result197]; + if (result4 !== null) { + var result1 = [result2, result3, result4]; } else { - var result194 = null; - pos = savedPos35; + var result1 = null; + pos = savedPos0; } } else { - var result194 = null; - pos = savedPos35; + var result1 = null; + pos = savedPos0; } } else { - var result194 = null; - pos = savedPos35; + var result1 = null; + pos = savedPos0; } - var result193 = result194 !== null - ? (function(chars) { return chars.join(""); })(result194[1]) + var result0 = result1 !== null + ? (function(chars) { return chars.join(""); })(result1[1]) : null; cache[cacheKey] = { nextPos: pos, - result: result193 + result: result0 }; - return result193; + return result0; } function parse_singleQuotedCharacter(context) { @@ -1964,31 +1964,31 @@ PEG.grammarParser = (function(){ } - var result205 = parse_simpleSingleQuotedCharacter(context); - if (result205 !== null) { - var result199 = result205; + var result6 = parse_simpleSingleQuotedCharacter(context); + if (result6 !== null) { + var result0 = result6; } else { - var result204 = parse_simpleEscapeSequence(context); - if (result204 !== null) { - var result199 = result204; + var result5 = parse_simpleEscapeSequence(context); + if (result5 !== null) { + var result0 = result5; } else { - var result203 = parse_zeroEscapeSequence(context); - if (result203 !== null) { - var result199 = result203; + var result4 = parse_zeroEscapeSequence(context); + if (result4 !== null) { + var result0 = result4; } else { - var result202 = parse_hexEscapeSequence(context); - if (result202 !== null) { - var result199 = result202; + var result3 = parse_hexEscapeSequence(context); + if (result3 !== null) { + var result0 = result3; } else { - var result201 = parse_unicodeEscapeSequence(context); - if (result201 !== null) { - var result199 = result201; + var result2 = parse_unicodeEscapeSequence(context); + if (result2 !== null) { + var result0 = result2; } else { - var result200 = parse_eolEscapeSequence(context); - if (result200 !== null) { - var result199 = result200; + var result1 = parse_eolEscapeSequence(context); + if (result1 !== null) { + var result0 = result1; } else { - var result199 = null;; + var result0 = null;; }; }; }; @@ -2000,9 +2000,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result199 + result: result0 }; - return result199; + return result0; } function parse_simpleSingleQuotedCharacter(context) { @@ -2014,80 +2014,80 @@ PEG.grammarParser = (function(){ } - var savedPos36 = pos; - var savedPos37 = pos; - var savedReportMatchFailuresVar2 = context.reportMatchFailures; + var savedPos0 = pos; + var savedPos1 = pos; + var savedReportMatchFailuresVar0 = context.reportMatchFailures; context.reportMatchFailures = false; if (input.substr(pos, 1) === "'") { - var result213 = "'"; + var result7 = "'"; pos += 1; } else { - var result213 = null; + var result7 = null; if (context.reportMatchFailures) { matchFailed(quoteString("'")); } } - if (result213 !== null) { - var result210 = result213; + if (result7 !== null) { + var result4 = result7; } else { if (input.substr(pos, 1) === "\\") { - var result212 = "\\"; + var result6 = "\\"; pos += 1; } else { - var result212 = null; + var result6 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\\")); } } - if (result212 !== null) { - var result210 = result212; + if (result6 !== null) { + var result4 = result6; } else { - var result211 = parse_eolChar(context); - if (result211 !== null) { - var result210 = result211; + var result5 = parse_eolChar(context); + if (result5 !== null) { + var result4 = result5; } else { - var result210 = null;; + var result4 = null;; }; }; } - context.reportMatchFailures = savedReportMatchFailuresVar2; - if (result210 === null) { - var result208 = ''; + context.reportMatchFailures = savedReportMatchFailuresVar0; + if (result4 === null) { + var result2 = ''; } else { - var result208 = null; - pos = savedPos37; + var result2 = null; + pos = savedPos1; } - if (result208 !== null) { + if (result2 !== null) { if (input.length > pos) { - var result209 = input.charAt(pos); + var result3 = input.charAt(pos); pos++; } else { - var result209 = null; + var result3 = null; if (context.reportMatchFailures) { matchFailed('any character'); } } - if (result209 !== null) { - var result207 = [result208, result209]; + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result207 = null; - pos = savedPos36; + var result1 = null; + pos = savedPos0; } } else { - var result207 = null; - pos = savedPos36; + var result1 = null; + pos = savedPos0; } - var result206 = result207 !== null - ? (function(char_) { return char_; })(result207[1]) + var result0 = result1 !== null + ? (function(char_) { return char_; })(result1[1]) : null; cache[cacheKey] = { nextPos: pos, - result: result206 + result: result0 }; - return result206; + return result0; } function parse_class(context) { @@ -2100,89 +2100,89 @@ PEG.grammarParser = (function(){ var savedReportMatchFailures = context.reportMatchFailures; context.reportMatchFailures = false; - var savedPos38 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "[") { - var result216 = "["; + var result2 = "["; pos += 1; } else { - var result216 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("[")); } } - if (result216 !== null) { + if (result2 !== null) { if (input.substr(pos, 1) === "^") { - var result224 = "^"; + var result10 = "^"; pos += 1; } else { - var result224 = null; + var result10 = null; if (context.reportMatchFailures) { matchFailed(quoteString("^")); } } - var result217 = result224 !== null ? result224 : ''; - if (result217 !== null) { - var result218 = []; - var result223 = parse_classCharacterRange(context); - if (result223 !== null) { - var result221 = result223; + var result3 = result10 !== null ? result10 : ''; + if (result3 !== null) { + var result4 = []; + var result9 = parse_classCharacterRange(context); + if (result9 !== null) { + var result7 = result9; } else { - var result222 = parse_classCharacter(context); - if (result222 !== null) { - var result221 = result222; + var result8 = parse_classCharacter(context); + if (result8 !== null) { + var result7 = result8; } else { - var result221 = null;; + var result7 = null;; }; } - while (result221 !== null) { - result218.push(result221); - var result223 = parse_classCharacterRange(context); - if (result223 !== null) { - var result221 = result223; + while (result7 !== null) { + result4.push(result7); + var result9 = parse_classCharacterRange(context); + if (result9 !== null) { + var result7 = result9; } else { - var result222 = parse_classCharacter(context); - if (result222 !== null) { - var result221 = result222; + var result8 = parse_classCharacter(context); + if (result8 !== null) { + var result7 = result8; } else { - var result221 = null;; + var result7 = null;; }; } } - if (result218 !== null) { + if (result4 !== null) { if (input.substr(pos, 1) === "]") { - var result219 = "]"; + var result5 = "]"; pos += 1; } else { - var result219 = null; + var result5 = null; if (context.reportMatchFailures) { matchFailed(quoteString("]")); } } - if (result219 !== null) { - var result220 = parse___(context); - if (result220 !== null) { - var result215 = [result216, result217, result218, result219, result220]; + if (result5 !== null) { + var result6 = parse___(context); + if (result6 !== null) { + var result1 = [result2, result3, result4, result5, result6]; } else { - var result215 = null; - pos = savedPos38; + var result1 = null; + pos = savedPos0; } } else { - var result215 = null; - pos = savedPos38; + var result1 = null; + pos = savedPos0; } } else { - var result215 = null; - pos = savedPos38; + var result1 = null; + pos = savedPos0; } } else { - var result215 = null; - pos = savedPos38; + var result1 = null; + pos = savedPos0; } } else { - var result215 = null; - pos = savedPos38; + var result1 = null; + pos = savedPos0; } - var result214 = result215 !== null + var result0 = result1 !== null ? (function(inverted, parts) { partsConverted = PEG.ArrayUtils.map(parts, function(part) { return part.data; @@ -2201,18 +2201,18 @@ PEG.grammarParser = (function(){ // FIXME: Get the raw text from the input directly. rawText: rawText }; - })(result215[1], result215[2]) + })(result1[1], result1[2]) : null; context.reportMatchFailures = savedReportMatchFailures; - if (context.reportMatchFailures && result214 === null) { + if (context.reportMatchFailures && result0 === null) { matchFailed("character class"); } cache[cacheKey] = { nextPos: pos, - result: result214 + result: result0 }; - return result214; + return result0; } function parse_classCharacterRange(context) { @@ -2224,35 +2224,35 @@ PEG.grammarParser = (function(){ } - var savedPos39 = pos; - var result227 = parse_classCharacter(context); - if (result227 !== null) { + var savedPos0 = pos; + var result2 = parse_classCharacter(context); + if (result2 !== null) { if (input.substr(pos, 1) === "-") { - var result228 = "-"; + var result3 = "-"; pos += 1; } else { - var result228 = null; + var result3 = null; if (context.reportMatchFailures) { matchFailed(quoteString("-")); } } - if (result228 !== null) { - var result229 = parse_classCharacter(context); - if (result229 !== null) { - var result226 = [result227, result228, result229]; + if (result3 !== null) { + var result4 = parse_classCharacter(context); + if (result4 !== null) { + var result1 = [result2, result3, result4]; } else { - var result226 = null; - pos = savedPos39; + var result1 = null; + pos = savedPos0; } } else { - var result226 = null; - pos = savedPos39; + var result1 = null; + pos = savedPos0; } } else { - var result226 = null; - pos = savedPos39; + var result1 = null; + pos = savedPos0; } - var result225 = result226 !== null + var result0 = result1 !== null ? (function(begin, end) { if (begin.data.charCodeAt(0) > end.data.charCodeAt(0)) { throw new this.SyntaxError( @@ -2265,16 +2265,16 @@ PEG.grammarParser = (function(){ // FIXME: Get the raw text from the input directly. rawText: begin.rawText + "-" + end.rawText } - })(result226[0], result226[2]) + })(result1[0], result1[2]) : null; cache[cacheKey] = { nextPos: pos, - result: result225 + result: result0 }; - return result225; + return result0; } function parse_classCharacter(context) { @@ -2286,24 +2286,24 @@ PEG.grammarParser = (function(){ } - var result231 = parse_bracketDelimitedCharacter(context); - var result230 = result231 !== null + var result1 = parse_bracketDelimitedCharacter(context); + var result0 = result1 !== null ? (function(char_) { return { data: char_, // FIXME: Get the raw text from the input directly. rawText: PEG.RegExpUtils.quoteForClass(char_) }; - })(result231) + })(result1) : null; cache[cacheKey] = { nextPos: pos, - result: result230 + result: result0 }; - return result230; + return result0; } function parse_bracketDelimitedCharacter(context) { @@ -2315,31 +2315,31 @@ PEG.grammarParser = (function(){ } - var result238 = parse_simpleBracketDelimitedCharacter(context); - if (result238 !== null) { - var result232 = result238; + var result6 = parse_simpleBracketDelimitedCharacter(context); + if (result6 !== null) { + var result0 = result6; } else { - var result237 = parse_simpleEscapeSequence(context); - if (result237 !== null) { - var result232 = result237; + var result5 = parse_simpleEscapeSequence(context); + if (result5 !== null) { + var result0 = result5; } else { - var result236 = parse_zeroEscapeSequence(context); - if (result236 !== null) { - var result232 = result236; + var result4 = parse_zeroEscapeSequence(context); + if (result4 !== null) { + var result0 = result4; } else { - var result235 = parse_hexEscapeSequence(context); - if (result235 !== null) { - var result232 = result235; + var result3 = parse_hexEscapeSequence(context); + if (result3 !== null) { + var result0 = result3; } else { - var result234 = parse_unicodeEscapeSequence(context); - if (result234 !== null) { - var result232 = result234; + var result2 = parse_unicodeEscapeSequence(context); + if (result2 !== null) { + var result0 = result2; } else { - var result233 = parse_eolEscapeSequence(context); - if (result233 !== null) { - var result232 = result233; + var result1 = parse_eolEscapeSequence(context); + if (result1 !== null) { + var result0 = result1; } else { - var result232 = null;; + var result0 = null;; }; }; }; @@ -2351,9 +2351,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result232 + result: result0 }; - return result232; + return result0; } function parse_simpleBracketDelimitedCharacter(context) { @@ -2365,80 +2365,80 @@ PEG.grammarParser = (function(){ } - var savedPos40 = pos; - var savedPos41 = pos; - var savedReportMatchFailuresVar3 = context.reportMatchFailures; + var savedPos0 = pos; + var savedPos1 = pos; + var savedReportMatchFailuresVar0 = context.reportMatchFailures; context.reportMatchFailures = false; if (input.substr(pos, 1) === "]") { - var result246 = "]"; + var result7 = "]"; pos += 1; } else { - var result246 = null; + var result7 = null; if (context.reportMatchFailures) { matchFailed(quoteString("]")); } } - if (result246 !== null) { - var result243 = result246; + if (result7 !== null) { + var result4 = result7; } else { if (input.substr(pos, 1) === "\\") { - var result245 = "\\"; + var result6 = "\\"; pos += 1; } else { - var result245 = null; + var result6 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\\")); } } - if (result245 !== null) { - var result243 = result245; + if (result6 !== null) { + var result4 = result6; } else { - var result244 = parse_eolChar(context); - if (result244 !== null) { - var result243 = result244; + var result5 = parse_eolChar(context); + if (result5 !== null) { + var result4 = result5; } else { - var result243 = null;; + var result4 = null;; }; }; } - context.reportMatchFailures = savedReportMatchFailuresVar3; - if (result243 === null) { - var result241 = ''; + context.reportMatchFailures = savedReportMatchFailuresVar0; + if (result4 === null) { + var result2 = ''; } else { - var result241 = null; - pos = savedPos41; + var result2 = null; + pos = savedPos1; } - if (result241 !== null) { + if (result2 !== null) { if (input.length > pos) { - var result242 = input.charAt(pos); + var result3 = input.charAt(pos); pos++; } else { - var result242 = null; + var result3 = null; if (context.reportMatchFailures) { matchFailed('any character'); } } - if (result242 !== null) { - var result240 = [result241, result242]; + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result240 = null; - pos = savedPos40; + var result1 = null; + pos = savedPos0; } } else { - var result240 = null; - pos = savedPos40; + var result1 = null; + pos = savedPos0; } - var result239 = result240 !== null - ? (function(char_) { return char_; })(result240[1]) + var result0 = result1 !== null + ? (function(char_) { return char_; })(result1[1]) : null; cache[cacheKey] = { nextPos: pos, - result: result239 + result: result0 }; - return result239; + return result0; } function parse_simpleEscapeSequence(context) { @@ -2450,89 +2450,89 @@ PEG.grammarParser = (function(){ } - var savedPos42 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "\\") { - var result249 = "\\"; + var result2 = "\\"; pos += 1; } else { - var result249 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\\")); } } - if (result249 !== null) { - var savedPos43 = pos; - var savedReportMatchFailuresVar4 = context.reportMatchFailures; + if (result2 !== null) { + var savedPos1 = pos; + var savedReportMatchFailuresVar0 = context.reportMatchFailures; context.reportMatchFailures = false; - var result256 = parse_digit(context); - if (result256 !== null) { - var result252 = result256; + var result9 = parse_digit(context); + if (result9 !== null) { + var result5 = result9; } else { if (input.substr(pos, 1) === "x") { - var result255 = "x"; + var result8 = "x"; pos += 1; } else { - var result255 = null; + var result8 = null; if (context.reportMatchFailures) { matchFailed(quoteString("x")); } } - if (result255 !== null) { - var result252 = result255; + if (result8 !== null) { + var result5 = result8; } else { if (input.substr(pos, 1) === "u") { - var result254 = "u"; + var result7 = "u"; pos += 1; } else { - var result254 = null; + var result7 = null; if (context.reportMatchFailures) { matchFailed(quoteString("u")); } } - if (result254 !== null) { - var result252 = result254; + if (result7 !== null) { + var result5 = result7; } else { - var result253 = parse_eolChar(context); - if (result253 !== null) { - var result252 = result253; + var result6 = parse_eolChar(context); + if (result6 !== null) { + var result5 = result6; } else { - var result252 = null;; + var result5 = null;; }; }; }; } - context.reportMatchFailures = savedReportMatchFailuresVar4; - if (result252 === null) { - var result250 = ''; + context.reportMatchFailures = savedReportMatchFailuresVar0; + if (result5 === null) { + var result3 = ''; } else { - var result250 = null; - pos = savedPos43; + var result3 = null; + pos = savedPos1; } - if (result250 !== null) { + if (result3 !== null) { if (input.length > pos) { - var result251 = input.charAt(pos); + var result4 = input.charAt(pos); pos++; } else { - var result251 = null; + var result4 = null; if (context.reportMatchFailures) { matchFailed('any character'); } } - if (result251 !== null) { - var result248 = [result249, result250, result251]; + if (result4 !== null) { + var result1 = [result2, result3, result4]; } else { - var result248 = null; - pos = savedPos42; + var result1 = null; + pos = savedPos0; } } else { - var result248 = null; - pos = savedPos42; + var result1 = null; + pos = savedPos0; } } else { - var result248 = null; - pos = savedPos42; + var result1 = null; + pos = savedPos0; } - var result247 = result248 !== null + var result0 = result1 !== null ? (function(char_) { return char_ .replace("b", "\b") @@ -2541,16 +2541,16 @@ PEG.grammarParser = (function(){ .replace("r", "\r") .replace("t", "\t") .replace("v", "\x0B") // IE does not recognize "\v". - })(result248[2]) + })(result1[2]) : null; cache[cacheKey] = { nextPos: pos, - result: result247 + result: result0 }; - return result247; + return result0; } function parse_zeroEscapeSequence(context) { @@ -2562,39 +2562,39 @@ PEG.grammarParser = (function(){ } - var savedPos44 = pos; + var savedPos0 = pos; if (input.substr(pos, 2) === "\\0") { - var result259 = "\\0"; + var result2 = "\\0"; pos += 2; } else { - var result259 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\\0")); } } - if (result259 !== null) { - var savedPos45 = pos; - var savedReportMatchFailuresVar5 = context.reportMatchFailures; + if (result2 !== null) { + var savedPos1 = pos; + var savedReportMatchFailuresVar0 = context.reportMatchFailures; context.reportMatchFailures = false; - var result261 = parse_digit(context); - context.reportMatchFailures = savedReportMatchFailuresVar5; - if (result261 === null) { - var result260 = ''; + var result4 = parse_digit(context); + context.reportMatchFailures = savedReportMatchFailuresVar0; + if (result4 === null) { + var result3 = ''; } else { - var result260 = null; - pos = savedPos45; + var result3 = null; + pos = savedPos1; } - if (result260 !== null) { - var result258 = [result259, result260]; + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result258 = null; - pos = savedPos44; + var result1 = null; + pos = savedPos0; } } else { - var result258 = null; - pos = savedPos44; + var result1 = null; + pos = savedPos0; } - var result257 = result258 !== null + var result0 = result1 !== null ? (function() { return "\0"; })() : null; @@ -2602,9 +2602,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result257 + result: result0 }; - return result257; + return result0; } function parse_hexEscapeSequence(context) { @@ -2616,47 +2616,47 @@ PEG.grammarParser = (function(){ } - var savedPos46 = pos; + var savedPos0 = pos; if (input.substr(pos, 2) === "\\x") { - var result264 = "\\x"; + var result2 = "\\x"; pos += 2; } else { - var result264 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\\x")); } } - if (result264 !== null) { - var result265 = parse_hexDigit(context); - if (result265 !== null) { - var result266 = parse_hexDigit(context); - if (result266 !== null) { - var result263 = [result264, result265, result266]; + if (result2 !== null) { + var result3 = parse_hexDigit(context); + if (result3 !== null) { + var result4 = parse_hexDigit(context); + if (result4 !== null) { + var result1 = [result2, result3, result4]; } else { - var result263 = null; - pos = savedPos46; + var result1 = null; + pos = savedPos0; } } else { - var result263 = null; - pos = savedPos46; + var result1 = null; + pos = savedPos0; } } else { - var result263 = null; - pos = savedPos46; + var result1 = null; + pos = savedPos0; } - var result262 = result263 !== null + var result0 = result1 !== null ? (function(h1, h2) { return String.fromCharCode(parseInt("0x" + h1 + h2)); - })(result263[1], result263[2]) + })(result1[1], result1[2]) : null; cache[cacheKey] = { nextPos: pos, - result: result262 + result: result0 }; - return result262; + return result0; } function parse_unicodeEscapeSequence(context) { @@ -2668,59 +2668,59 @@ PEG.grammarParser = (function(){ } - var savedPos47 = pos; + var savedPos0 = pos; if (input.substr(pos, 2) === "\\u") { - var result269 = "\\u"; + var result2 = "\\u"; pos += 2; } else { - var result269 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\\u")); } } - if (result269 !== null) { - var result270 = parse_hexDigit(context); - if (result270 !== null) { - var result271 = parse_hexDigit(context); - if (result271 !== null) { - var result272 = parse_hexDigit(context); - if (result272 !== null) { - var result273 = parse_hexDigit(context); - if (result273 !== null) { - var result268 = [result269, result270, result271, result272, result273]; + if (result2 !== null) { + var result3 = parse_hexDigit(context); + if (result3 !== null) { + var result4 = parse_hexDigit(context); + if (result4 !== null) { + var result5 = parse_hexDigit(context); + if (result5 !== null) { + var result6 = parse_hexDigit(context); + if (result6 !== null) { + var result1 = [result2, result3, result4, result5, result6]; } else { - var result268 = null; - pos = savedPos47; + var result1 = null; + pos = savedPos0; } } else { - var result268 = null; - pos = savedPos47; + var result1 = null; + pos = savedPos0; } } else { - var result268 = null; - pos = savedPos47; + var result1 = null; + pos = savedPos0; } } else { - var result268 = null; - pos = savedPos47; + var result1 = null; + pos = savedPos0; } } else { - var result268 = null; - pos = savedPos47; + var result1 = null; + pos = savedPos0; } - var result267 = result268 !== null + var result0 = result1 !== null ? (function(h1, h2, h3, h4) { return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); - })(result268[1], result268[2], result268[3], result268[4]) + })(result1[1], result1[2], result1[3], result1[4]) : null; cache[cacheKey] = { nextPos: pos, - result: result267 + result: result0 }; - return result267; + return result0; } function parse_eolEscapeSequence(context) { @@ -2732,39 +2732,39 @@ PEG.grammarParser = (function(){ } - var savedPos48 = pos; + var savedPos0 = pos; if (input.substr(pos, 1) === "\\") { - var result276 = "\\"; + var result2 = "\\"; pos += 1; } else { - var result276 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\\")); } } - if (result276 !== null) { - var result277 = parse_eol(context); - if (result277 !== null) { - var result275 = [result276, result277]; + if (result2 !== null) { + var result3 = parse_eol(context); + if (result3 !== null) { + var result1 = [result2, result3]; } else { - var result275 = null; - pos = savedPos48; + var result1 = null; + pos = savedPos0; } } else { - var result275 = null; - pos = savedPos48; + var result1 = null; + pos = savedPos0; } - var result274 = result275 !== null - ? (function(eol) { return eol; })(result275[1]) + var result0 = result1 !== null + ? (function(eol) { return eol; })(result1[1]) : null; cache[cacheKey] = { nextPos: pos, - result: result274 + result: result0 }; - return result274; + return result0; } function parse_digit(context) { @@ -2777,10 +2777,10 @@ PEG.grammarParser = (function(){ if (input.substr(pos).match(/^[0-9]/) !== null) { - var result278 = input.charAt(pos); + var result0 = input.charAt(pos); pos++; } else { - var result278 = null; + var result0 = null; if (context.reportMatchFailures) { matchFailed("[0-9]"); } @@ -2790,9 +2790,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result278 + result: result0 }; - return result278; + return result0; } function parse_hexDigit(context) { @@ -2805,10 +2805,10 @@ PEG.grammarParser = (function(){ if (input.substr(pos).match(/^[0-9a-fA-F]/) !== null) { - var result279 = input.charAt(pos); + var result0 = input.charAt(pos); pos++; } else { - var result279 = null; + var result0 = null; if (context.reportMatchFailures) { matchFailed("[0-9a-fA-F]"); } @@ -2818,9 +2818,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result279 + result: result0 }; - return result279; + return result0; } function parse_letter(context) { @@ -2832,15 +2832,15 @@ PEG.grammarParser = (function(){ } - var result282 = parse_lowerCaseLetter(context); - if (result282 !== null) { - var result280 = result282; + var result2 = parse_lowerCaseLetter(context); + if (result2 !== null) { + var result0 = result2; } else { - var result281 = parse_upperCaseLetter(context); - if (result281 !== null) { - var result280 = result281; + var result1 = parse_upperCaseLetter(context); + if (result1 !== null) { + var result0 = result1; } else { - var result280 = null;; + var result0 = null;; }; } @@ -2848,9 +2848,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result280 + result: result0 }; - return result280; + return result0; } function parse_lowerCaseLetter(context) { @@ -2863,10 +2863,10 @@ PEG.grammarParser = (function(){ if (input.substr(pos).match(/^[a-z]/) !== null) { - var result283 = input.charAt(pos); + var result0 = input.charAt(pos); pos++; } else { - var result283 = null; + var result0 = null; if (context.reportMatchFailures) { matchFailed("[a-z]"); } @@ -2876,9 +2876,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result283 + result: result0 }; - return result283; + return result0; } function parse_upperCaseLetter(context) { @@ -2891,10 +2891,10 @@ PEG.grammarParser = (function(){ if (input.substr(pos).match(/^[A-Z]/) !== null) { - var result284 = input.charAt(pos); + var result0 = input.charAt(pos); pos++; } else { - var result284 = null; + var result0 = null; if (context.reportMatchFailures) { matchFailed("[A-Z]"); } @@ -2904,9 +2904,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result284 + result: result0 }; - return result284; + return result0; } function parse___(context) { @@ -2918,38 +2918,38 @@ PEG.grammarParser = (function(){ } - var result285 = []; - var result289 = parse_whitespace(context); - if (result289 !== null) { - var result286 = result289; + var result0 = []; + var result4 = parse_whitespace(context); + if (result4 !== null) { + var result1 = result4; } else { - var result288 = parse_eol(context); - if (result288 !== null) { - var result286 = result288; + var result3 = parse_eol(context); + if (result3 !== null) { + var result1 = result3; } else { - var result287 = parse_comment(context); - if (result287 !== null) { - var result286 = result287; + var result2 = parse_comment(context); + if (result2 !== null) { + var result1 = result2; } else { - var result286 = null;; + var result1 = null;; }; }; } - while (result286 !== null) { - result285.push(result286); - var result289 = parse_whitespace(context); - if (result289 !== null) { - var result286 = result289; + while (result1 !== null) { + result0.push(result1); + var result4 = parse_whitespace(context); + if (result4 !== null) { + var result1 = result4; } else { - var result288 = parse_eol(context); - if (result288 !== null) { - var result286 = result288; + var result3 = parse_eol(context); + if (result3 !== null) { + var result1 = result3; } else { - var result287 = parse_comment(context); - if (result287 !== null) { - var result286 = result287; + var result2 = parse_comment(context); + if (result2 !== null) { + var result1 = result2; } else { - var result286 = null;; + var result1 = null;; }; }; } @@ -2959,9 +2959,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result285 + result: result0 }; - return result285; + return result0; } function parse_comment(context) { @@ -2974,27 +2974,27 @@ PEG.grammarParser = (function(){ var savedReportMatchFailures = context.reportMatchFailures; context.reportMatchFailures = false; - var result292 = parse_singleLineComment(context); - if (result292 !== null) { - var result290 = result292; + var result2 = parse_singleLineComment(context); + if (result2 !== null) { + var result0 = result2; } else { - var result291 = parse_multiLineComment(context); - if (result291 !== null) { - var result290 = result291; + var result1 = parse_multiLineComment(context); + if (result1 !== null) { + var result0 = result1; } else { - var result290 = null;; + var result0 = null;; }; } context.reportMatchFailures = savedReportMatchFailures; - if (context.reportMatchFailures && result290 === null) { + if (context.reportMatchFailures && result0 === null) { matchFailed("comment"); } cache[cacheKey] = { nextPos: pos, - result: result290 + result: result0 }; - return result290; + return result0; } function parse_singleLineComment(context) { @@ -3006,103 +3006,103 @@ PEG.grammarParser = (function(){ } - var savedPos49 = pos; + var savedPos0 = pos; if (input.substr(pos, 2) === "//") { - var result294 = "//"; + var result1 = "//"; pos += 2; } else { - var result294 = null; + var result1 = null; if (context.reportMatchFailures) { matchFailed(quoteString("//")); } } - if (result294 !== null) { - var result295 = []; - var savedPos50 = pos; - var savedPos51 = pos; - var savedReportMatchFailuresVar6 = context.reportMatchFailures; + if (result1 !== null) { + var result2 = []; + var savedPos1 = pos; + var savedPos2 = pos; + var savedReportMatchFailuresVar0 = context.reportMatchFailures; context.reportMatchFailures = false; - var result299 = parse_eolChar(context); - context.reportMatchFailures = savedReportMatchFailuresVar6; - if (result299 === null) { - var result297 = ''; + var result6 = parse_eolChar(context); + context.reportMatchFailures = savedReportMatchFailuresVar0; + if (result6 === null) { + var result4 = ''; } else { - var result297 = null; - pos = savedPos51; + var result4 = null; + pos = savedPos2; } - if (result297 !== null) { + if (result4 !== null) { if (input.length > pos) { - var result298 = input.charAt(pos); + var result5 = input.charAt(pos); pos++; } else { - var result298 = null; + var result5 = null; if (context.reportMatchFailures) { matchFailed('any character'); } } - if (result298 !== null) { - var result296 = [result297, result298]; + if (result5 !== null) { + var result3 = [result4, result5]; } else { - var result296 = null; - pos = savedPos50; + var result3 = null; + pos = savedPos1; } } else { - var result296 = null; - pos = savedPos50; + var result3 = null; + pos = savedPos1; } - while (result296 !== null) { - result295.push(result296); - var savedPos50 = pos; - var savedPos51 = pos; - var savedReportMatchFailuresVar6 = context.reportMatchFailures; + while (result3 !== null) { + result2.push(result3); + var savedPos1 = pos; + var savedPos2 = pos; + var savedReportMatchFailuresVar0 = context.reportMatchFailures; context.reportMatchFailures = false; - var result299 = parse_eolChar(context); - context.reportMatchFailures = savedReportMatchFailuresVar6; - if (result299 === null) { - var result297 = ''; + var result6 = parse_eolChar(context); + context.reportMatchFailures = savedReportMatchFailuresVar0; + if (result6 === null) { + var result4 = ''; } else { - var result297 = null; - pos = savedPos51; + var result4 = null; + pos = savedPos2; } - if (result297 !== null) { + if (result4 !== null) { if (input.length > pos) { - var result298 = input.charAt(pos); + var result5 = input.charAt(pos); pos++; } else { - var result298 = null; + var result5 = null; if (context.reportMatchFailures) { matchFailed('any character'); } } - if (result298 !== null) { - var result296 = [result297, result298]; + if (result5 !== null) { + var result3 = [result4, result5]; } else { - var result296 = null; - pos = savedPos50; + var result3 = null; + pos = savedPos1; } } else { - var result296 = null; - pos = savedPos50; + var result3 = null; + pos = savedPos1; } } - if (result295 !== null) { - var result293 = [result294, result295]; + if (result2 !== null) { + var result0 = [result1, result2]; } else { - var result293 = null; - pos = savedPos49; + var result0 = null; + pos = savedPos0; } } else { - var result293 = null; - pos = savedPos49; + var result0 = null; + pos = savedPos0; } cache[cacheKey] = { nextPos: pos, - result: result293 + result: result0 }; - return result293; + return result0; } function parse_multiLineComment(context) { @@ -3114,133 +3114,133 @@ PEG.grammarParser = (function(){ } - var savedPos52 = pos; + var savedPos0 = pos; if (input.substr(pos, 2) === "/*") { - var result301 = "/*"; + var result1 = "/*"; pos += 2; } else { - var result301 = null; + var result1 = null; if (context.reportMatchFailures) { matchFailed(quoteString("/*")); } } - if (result301 !== null) { - var result302 = []; - var savedPos53 = pos; - var savedPos54 = pos; - var savedReportMatchFailuresVar7 = context.reportMatchFailures; + if (result1 !== null) { + var result2 = []; + var savedPos1 = pos; + var savedPos2 = pos; + var savedReportMatchFailuresVar0 = context.reportMatchFailures; context.reportMatchFailures = false; if (input.substr(pos, 2) === "*/") { - var result307 = "*/"; + var result7 = "*/"; pos += 2; } else { - var result307 = null; + var result7 = null; if (context.reportMatchFailures) { matchFailed(quoteString("*/")); } } - context.reportMatchFailures = savedReportMatchFailuresVar7; - if (result307 === null) { - var result305 = ''; + context.reportMatchFailures = savedReportMatchFailuresVar0; + if (result7 === null) { + var result5 = ''; } else { - var result305 = null; - pos = savedPos54; + var result5 = null; + pos = savedPos2; } - if (result305 !== null) { + if (result5 !== null) { if (input.length > pos) { - var result306 = input.charAt(pos); + var result6 = input.charAt(pos); pos++; } else { - var result306 = null; + var result6 = null; if (context.reportMatchFailures) { matchFailed('any character'); } } - if (result306 !== null) { - var result304 = [result305, result306]; + if (result6 !== null) { + var result4 = [result5, result6]; } else { - var result304 = null; - pos = savedPos53; + var result4 = null; + pos = savedPos1; } } else { - var result304 = null; - pos = savedPos53; + var result4 = null; + pos = savedPos1; } - while (result304 !== null) { - result302.push(result304); - var savedPos53 = pos; - var savedPos54 = pos; - var savedReportMatchFailuresVar7 = context.reportMatchFailures; + while (result4 !== null) { + result2.push(result4); + var savedPos1 = pos; + var savedPos2 = pos; + var savedReportMatchFailuresVar0 = context.reportMatchFailures; context.reportMatchFailures = false; if (input.substr(pos, 2) === "*/") { - var result307 = "*/"; + var result7 = "*/"; pos += 2; } else { - var result307 = null; + var result7 = null; if (context.reportMatchFailures) { matchFailed(quoteString("*/")); } } - context.reportMatchFailures = savedReportMatchFailuresVar7; - if (result307 === null) { - var result305 = ''; + context.reportMatchFailures = savedReportMatchFailuresVar0; + if (result7 === null) { + var result5 = ''; } else { - var result305 = null; - pos = savedPos54; + var result5 = null; + pos = savedPos2; } - if (result305 !== null) { + if (result5 !== null) { if (input.length > pos) { - var result306 = input.charAt(pos); + var result6 = input.charAt(pos); pos++; } else { - var result306 = null; + var result6 = null; if (context.reportMatchFailures) { matchFailed('any character'); } } - if (result306 !== null) { - var result304 = [result305, result306]; + if (result6 !== null) { + var result4 = [result5, result6]; } else { - var result304 = null; - pos = savedPos53; + var result4 = null; + pos = savedPos1; } } else { - var result304 = null; - pos = savedPos53; + var result4 = null; + pos = savedPos1; } } - if (result302 !== null) { + if (result2 !== null) { if (input.substr(pos, 2) === "*/") { - var result303 = "*/"; + var result3 = "*/"; pos += 2; } else { - var result303 = null; + var result3 = null; if (context.reportMatchFailures) { matchFailed(quoteString("*/")); } } - if (result303 !== null) { - var result300 = [result301, result302, result303]; + if (result3 !== null) { + var result0 = [result1, result2, result3]; } else { - var result300 = null; - pos = savedPos52; + var result0 = null; + pos = savedPos0; } } else { - var result300 = null; - pos = savedPos52; + var result0 = null; + pos = savedPos0; } } else { - var result300 = null; - pos = savedPos52; + var result0 = null; + pos = savedPos0; } cache[cacheKey] = { nextPos: pos, - result: result300 + result: result0 }; - return result300; + return result0; } function parse_eol(context) { @@ -3254,81 +3254,81 @@ PEG.grammarParser = (function(){ var savedReportMatchFailures = context.reportMatchFailures; context.reportMatchFailures = false; if (input.substr(pos, 1) === "\n") { - var result313 = "\n"; + var result5 = "\n"; pos += 1; } else { - var result313 = null; + var result5 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\n")); } } - if (result313 !== null) { - var result308 = result313; + if (result5 !== null) { + var result0 = result5; } else { if (input.substr(pos, 2) === "\r\n") { - var result312 = "\r\n"; + var result4 = "\r\n"; pos += 2; } else { - var result312 = null; + var result4 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\r\n")); } } - if (result312 !== null) { - var result308 = result312; + if (result4 !== null) { + var result0 = result4; } else { if (input.substr(pos, 1) === "\r") { - var result311 = "\r"; + var result3 = "\r"; pos += 1; } else { - var result311 = null; + var result3 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\r")); } } - if (result311 !== null) { - var result308 = result311; + if (result3 !== null) { + var result0 = result3; } else { if (input.substr(pos, 1) === "\u2028") { - var result310 = "\u2028"; + var result2 = "\u2028"; pos += 1; } else { - var result310 = null; + var result2 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\u2028")); } } - if (result310 !== null) { - var result308 = result310; + if (result2 !== null) { + var result0 = result2; } else { if (input.substr(pos, 1) === "\u2029") { - var result309 = "\u2029"; + var result1 = "\u2029"; pos += 1; } else { - var result309 = null; + var result1 = null; if (context.reportMatchFailures) { matchFailed(quoteString("\u2029")); } } - if (result309 !== null) { - var result308 = result309; + if (result1 !== null) { + var result0 = result1; } else { - var result308 = null;; + var result0 = null;; }; }; }; }; } context.reportMatchFailures = savedReportMatchFailures; - if (context.reportMatchFailures && result308 === null) { + if (context.reportMatchFailures && result0 === null) { matchFailed("end of line"); } cache[cacheKey] = { nextPos: pos, - result: result308 + result: result0 }; - return result308; + return result0; } function parse_eolChar(context) { @@ -3341,10 +3341,10 @@ PEG.grammarParser = (function(){ if (input.substr(pos).match(/^[\n\r\u2028\u2029]/) !== null) { - var result314 = input.charAt(pos); + var result0 = input.charAt(pos); pos++; } else { - var result314 = null; + var result0 = null; if (context.reportMatchFailures) { matchFailed("[\\n\\r\\u2028\\u2029]"); } @@ -3354,9 +3354,9 @@ PEG.grammarParser = (function(){ cache[cacheKey] = { nextPos: pos, - result: result314 + result: result0 }; - return result314; + return result0; } function parse_whitespace(context) { @@ -3370,24 +3370,24 @@ PEG.grammarParser = (function(){ var savedReportMatchFailures = context.reportMatchFailures; context.reportMatchFailures = false; if (input.substr(pos).match(/^[   ᠎ -    ]/) !== null) { - var result315 = input.charAt(pos); + var result0 = input.charAt(pos); pos++; } else { - var result315 = null; + var result0 = null; if (context.reportMatchFailures) { matchFailed("[   ᠎ -    ]"); } } context.reportMatchFailures = savedReportMatchFailures; - if (context.reportMatchFailures && result315 === null) { + if (context.reportMatchFailures && result0 === null) { matchFailed("whitespace"); } cache[cacheKey] = { nextPos: pos, - result: result315 + result: result0 }; - return result315; + return result0; } function buildErrorMessage() { diff --git a/test/compiler-test.js b/test/compiler-test.js index 6a4625c..f6efb9e 100644 --- a/test/compiler-test.js +++ b/test/compiler-test.js @@ -180,6 +180,20 @@ test("generateUniqueIdentifier", function() { ); }); +test("resetUniqueIdentifierCounters", function() { + var ida1 = PEG.Compiler.generateUniqueIdentifier("a"); + var ida2 = PEG.Compiler.generateUniqueIdentifier("a"); + var idb1 = PEG.Compiler.generateUniqueIdentifier("b"); + var idb2 = PEG.Compiler.generateUniqueIdentifier("b"); + + PEG.Compiler.resetUniqueIdentifierCounters(); + + strictEqual(PEG.Compiler.generateUniqueIdentifier("a"), ida1); + strictEqual(PEG.Compiler.generateUniqueIdentifier("a"), ida2); + strictEqual(PEG.Compiler.generateUniqueIdentifier("b"), idb1); + strictEqual(PEG.Compiler.generateUniqueIdentifier("b"), idb2); +}); + /* ===== PEG ===== */ module("PEG");