You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pegjs/lib/metagrammar.js

3360 lines
97 KiB
JavaScript

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

PEG.grammarParser = (function(){
/* Generated by PEG.js (http://pegjs.majda.cz/). */
var result = {
_startRule: "grammar",
_quoteString: function(s) {
/*
* ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a string
* literal except for the closing quote character, backslash, carriage
* return, line separator, paragraph separator, and line feed. Any character
* may appear in the form of an escape sequence.
*/
return '"' + s
.replace(/\\/g, '\\\\') // backslash
.replace(/"/g, '\\"') // closing quote character
.replace(/\r/g, '\\r') // carriage return
.replace(/\u2028/g, '\\u2028') // line separator
.replace(/\u2029/g, '\\u2029') // paragraph separator
.replace(/\n/g, '\\n') // line feed
+ '"';
},
_arrayContains: function(array, value) {
/*
* Stupid IE does not have Array.prototype.indexOf, otherwise this function
* would be a one-liner.
*/
var length = array.length;
for (var i = 0; i < length; i++) {
if (array[i] === value) {
return true;
}
}
return false;
},
_matchFailed: function(failure) {
if (this._pos > this._rightmostMatchFailuresPos) {
this._rightmostMatchFailuresPos = this._pos;
this._rightmostMatchFailuresExpected = [];
}
if (!this._arrayContains(this._rightmostMatchFailuresExpected, failure)) {
this._rightmostMatchFailuresExpected.push(failure);
}
},
_parse_grammar: function(context) {
var cacheKey = "grammar" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos0 = this._pos;
var result2 = this._parse___(context);
if (result2 !== null) {
var result4 = this._parse_rule(context);
if (result4 !== null) {
var result3 = [];
while (result4 !== null) {
result3.push(result4);
var result4 = this._parse_rule(context);
}
} else {
var result3 = null;
}
if (result3 !== null) {
var result1 = [result2, result3];
} else {
var result1 = null;
this._pos = savedPos0;
}
} else {
var result1 = null;
this._pos = savedPos0;
}
var result0 = result1 !== null
? (function($1, $2) {
var result = {};
PEG.ArrayUtils.each($2, function(rule) { result[rule.getName()] = rule; });
return result;
}).apply(null, result1)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result0
};
return result0;
},
_parse_rule: function(context) {
var cacheKey = "rule" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos1 = this._pos;
var result7 = this._parse_identifier(context);
if (result7 !== null) {
var result12 = this._parse_literal(context);
if (result12 !== null) {
var result8 = result12;
} else {
if (this._input.substr(this._pos, 0) === "") {
var result11 = "";
this._pos += 0;
} else {
var result11 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString(""));
}
}
if (result11 !== null) {
var result8 = result11;
} else {
var result8 = null;;
};
}
if (result8 !== null) {
var result9 = this._parse_colon(context);
if (result9 !== null) {
var result10 = this._parse_expression(context);
if (result10 !== null) {
var result6 = [result7, result8, result9, result10];
} else {
var result6 = null;
this._pos = savedPos1;
}
} else {
var result6 = null;
this._pos = savedPos1;
}
} else {
var result6 = null;
this._pos = savedPos1;
}
} else {
var result6 = null;
this._pos = savedPos1;
}
var result5 = result6 !== null
? (function($1, $2, $3, $4) {
return new PEG.Grammar.Rule($1, $2 !== "" ? $2 : null, $4);
}).apply(null, result6)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result5
};
return result5;
},
_parse_expression: function(context) {
var cacheKey = "expression" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var result13 = this._parse_choice(context);
this._cache[cacheKey] = {
nextPos: this._pos,
result: result13
};
return result13;
},
_parse_choice: function(context) {
var cacheKey = "choice" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos2 = this._pos;
var result16 = this._parse_sequence(context);
if (result16 !== null) {
var result17 = [];
var savedPos3 = this._pos;
var result19 = this._parse_slash(context);
if (result19 !== null) {
var result20 = this._parse_sequence(context);
if (result20 !== null) {
var result18 = [result19, result20];
} else {
var result18 = null;
this._pos = savedPos3;
}
} else {
var result18 = null;
this._pos = savedPos3;
}
while (result18 !== null) {
result17.push(result18);
var savedPos3 = this._pos;
var result19 = this._parse_slash(context);
if (result19 !== null) {
var result20 = this._parse_sequence(context);
if (result20 !== null) {
var result18 = [result19, result20];
} else {
var result18 = null;
this._pos = savedPos3;
}
} else {
var result18 = null;
this._pos = savedPos3;
}
}
if (result17 !== null) {
var result15 = [result16, result17];
} else {
var result15 = null;
this._pos = savedPos2;
}
} else {
var result15 = null;
this._pos = savedPos2;
}
var result14 = result15 !== null
? (function($1, $2) {
return $2.length > 0
? new PEG.Grammar.Choice([$1].concat(PEG.ArrayUtils.map(
$2,
function(element) { return element[1]; }
)))
: $1;
}).apply(null, result15)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result14
};
return result14;
},
_parse_sequence: function(context) {
var cacheKey = "sequence" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos4 = this._pos;
var result27 = [];
var result29 = this._parse_prefixed(context);
while (result29 !== null) {
result27.push(result29);
var result29 = this._parse_prefixed(context);
}
if (result27 !== null) {
var result28 = this._parse_action(context);
if (result28 !== null) {
var result26 = [result27, result28];
} else {
var result26 = null;
this._pos = savedPos4;
}
} else {
var result26 = null;
this._pos = savedPos4;
}
var result25 = result26 !== null
? (function($1, $2) {
return new PEG.Grammar.Action(
$1.length != 1 ? new PEG.Grammar.Sequence($1) : $1[0],
$2
);
}).apply(null, result26)
: null;
if (result25 !== null) {
var result21 = result25;
} else {
var result23 = [];
var result24 = this._parse_prefixed(context);
while (result24 !== null) {
result23.push(result24);
var result24 = this._parse_prefixed(context);
}
var result22 = result23 !== null
? (function($1) { return $1.length != 1 ? new PEG.Grammar.Sequence($1) : $1[0]; })(result23)
: null;
if (result22 !== null) {
var result21 = result22;
} else {
var result21 = null;;
};
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result21
};
return result21;
},
_parse_prefixed: function(context) {
var cacheKey = "prefixed" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos6 = this._pos;
var result38 = this._parse_and(context);
if (result38 !== null) {
var result39 = this._parse_suffixed(context);
if (result39 !== null) {
var result37 = [result38, result39];
} else {
var result37 = null;
this._pos = savedPos6;
}
} else {
var result37 = null;
this._pos = savedPos6;
}
var result36 = result37 !== null
? (function($1, $2) { return new PEG.Grammar.AndPredicate($2); }).apply(null, result37)
: null;
if (result36 !== null) {
var result30 = result36;
} else {
var savedPos5 = this._pos;
var result34 = this._parse_not(context);
if (result34 !== null) {
var result35 = this._parse_suffixed(context);
if (result35 !== null) {
var result33 = [result34, result35];
} else {
var result33 = null;
this._pos = savedPos5;
}
} else {
var result33 = null;
this._pos = savedPos5;
}
var result32 = result33 !== null
? (function($1, $2) { return new PEG.Grammar.NotPredicate($2); }).apply(null, result33)
: null;
if (result32 !== null) {
var result30 = result32;
} else {
var result31 = this._parse_suffixed(context);
if (result31 !== null) {
var result30 = result31;
} else {
var result30 = null;;
};
};
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result30
};
return result30;
},
_parse_suffixed: function(context) {
var cacheKey = "suffixed" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos9 = this._pos;
var result52 = this._parse_primary(context);
if (result52 !== null) {
var result53 = this._parse_question(context);
if (result53 !== null) {
var result51 = [result52, result53];
} else {
var result51 = null;
this._pos = savedPos9;
}
} else {
var result51 = null;
this._pos = savedPos9;
}
var result50 = result51 !== null
? (function($1, $2) { return new PEG.Grammar.Optional($1); }).apply(null, result51)
: null;
if (result50 !== null) {
var result40 = result50;
} else {
var savedPos8 = this._pos;
var result48 = this._parse_primary(context);
if (result48 !== null) {
var result49 = this._parse_star(context);
if (result49 !== null) {
var result47 = [result48, result49];
} else {
var result47 = null;
this._pos = savedPos8;
}
} else {
var result47 = null;
this._pos = savedPos8;
}
var result46 = result47 !== null
? (function($1, $2) { return new PEG.Grammar.ZeroOrMore($1); }).apply(null, result47)
: null;
if (result46 !== null) {
var result40 = result46;
} else {
var savedPos7 = this._pos;
var result44 = this._parse_primary(context);
if (result44 !== null) {
var result45 = this._parse_plus(context);
if (result45 !== null) {
var result43 = [result44, result45];
} else {
var result43 = null;
this._pos = savedPos7;
}
} else {
var result43 = null;
this._pos = savedPos7;
}
var result42 = result43 !== null
? (function($1, $2) { return new PEG.Grammar.OneOrMore($1); }).apply(null, result43)
: null;
if (result42 !== null) {
var result40 = result42;
} else {
var result41 = this._parse_primary(context);
if (result41 !== null) {
var result40 = result41;
} else {
var result40 = null;;
};
};
};
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result40
};
return result40;
},
_parse_primary: function(context) {
var cacheKey = "primary" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos11 = this._pos;
var result68 = this._parse_identifier(context);
if (result68 !== null) {
var savedPos12 = this._pos;
var savedReportMatchFailuresVar0 = context.reportMatchFailures;
context.reportMatchFailures = false;
var savedPos13 = this._pos;
var result74 = this._parse_literal(context);
if (result74 !== null) {
var result71 = result74;
} else {
if (this._input.substr(this._pos, 0) === "") {
var result73 = "";
this._pos += 0;
} else {
var result73 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString(""));
}
}
if (result73 !== null) {
var result71 = result73;
} else {
var result71 = null;;
};
}
if (result71 !== null) {
var result72 = this._parse_colon(context);
if (result72 !== null) {
var result70 = [result71, result72];
} else {
var result70 = null;
this._pos = savedPos13;
}
} else {
var result70 = null;
this._pos = savedPos13;
}
context.reportMatchFailures = savedReportMatchFailuresVar0;
if (result70 === null) {
var result69 = '';
} else {
var result69 = null;
this._pos = savedPos12;
}
if (result69 !== null) {
var result67 = [result68, result69];
} else {
var result67 = null;
this._pos = savedPos11;
}
} else {
var result67 = null;
this._pos = savedPos11;
}
var result66 = result67 !== null
? (function($1, $2) { return new PEG.Grammar.RuleRef($1); }).apply(null, result67)
: null;
if (result66 !== null) {
var result54 = result66;
} else {
var result65 = this._parse_literal(context);
var result64 = result65 !== null
? (function($1) { return new PEG.Grammar.Literal($1); })(result65)
: null;
if (result64 !== null) {
var result54 = result64;
} else {
var result63 = this._parse_dot(context);
var result62 = result63 !== null
? (function($1) { return new PEG.Grammar.Any(); })(result63)
: null;
if (result62 !== null) {
var result54 = result62;
} else {
var result61 = this._parse_class(context);
var result60 = result61 !== null
? (function($1) { return new PEG.Grammar.Class($1); })(result61)
: null;
if (result60 !== null) {
var result54 = result60;
} else {
var savedPos10 = this._pos;
var result57 = this._parse_lparen(context);
if (result57 !== null) {
var result58 = this._parse_expression(context);
if (result58 !== null) {
var result59 = this._parse_rparen(context);
if (result59 !== null) {
var result56 = [result57, result58, result59];
} else {
var result56 = null;
this._pos = savedPos10;
}
} else {
var result56 = null;
this._pos = savedPos10;
}
} else {
var result56 = null;
this._pos = savedPos10;
}
var result55 = result56 !== null
? (function($1, $2, $3) { return $2; }).apply(null, result56)
: null;
if (result55 !== null) {
var result54 = result55;
} else {
var result54 = null;;
};
};
};
};
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result54
};
return result54;
},
_parse_action: function(context) {
var cacheKey = "action" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedReportMatchFailures = context.reportMatchFailures;
context.reportMatchFailures = false;
var savedPos14 = this._pos;
var result77 = this._parse_braced(context);
if (result77 !== null) {
var result78 = this._parse___(context);
if (result78 !== null) {
var result76 = [result77, result78];
} else {
var result76 = null;
this._pos = savedPos14;
}
} else {
var result76 = null;
this._pos = savedPos14;
}
var result75 = result76 !== null
? (function($1, $2) { return $1.substr(1, $1.length - 2); }).apply(null, result76)
: null;
context.reportMatchFailures = savedReportMatchFailures;
if (context.reportMatchFailures && result75 === null) {
this._matchFailed("action");
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result75
};
return result75;
},
_parse_braced: function(context) {
var cacheKey = "braced" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos15 = this._pos;
if (this._input.substr(this._pos, 1) === "{") {
var result81 = "{";
this._pos += 1;
} else {
var result81 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("{"));
}
}
if (result81 !== null) {
var result82 = [];
var result86 = this._parse_braced(context);
if (result86 !== null) {
var result84 = result86;
} else {
var result85 = this._parse_nonBraceCharacter(context);
if (result85 !== null) {
var result84 = result85;
} else {
var result84 = null;;
};
}
while (result84 !== null) {
result82.push(result84);
var result86 = this._parse_braced(context);
if (result86 !== null) {
var result84 = result86;
} else {
var result85 = this._parse_nonBraceCharacter(context);
if (result85 !== null) {
var result84 = result85;
} else {
var result84 = null;;
};
}
}
if (result82 !== null) {
if (this._input.substr(this._pos, 1) === "}") {
var result83 = "}";
this._pos += 1;
} else {
var result83 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("}"));
}
}
if (result83 !== null) {
var result80 = [result81, result82, result83];
} else {
var result80 = null;
this._pos = savedPos15;
}
} else {
var result80 = null;
this._pos = savedPos15;
}
} else {
var result80 = null;
this._pos = savedPos15;
}
var result79 = result80 !== null
? (function($1, $2, $3) { return $1 + $2.join("") + $3; }).apply(null, result80)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result79
};
return result79;
},
_parse_nonBraceCharacters: function(context) {
var cacheKey = "nonBraceCharacters" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var result89 = this._parse_nonBraceCharacter(context);
if (result89 !== null) {
var result88 = [];
while (result89 !== null) {
result88.push(result89);
var result89 = this._parse_nonBraceCharacter(context);
}
} else {
var result88 = null;
}
var result87 = result88 !== null
? (function($1) { return $1.join(""); })(result88)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result87
};
return result87;
},
_parse_nonBraceCharacter: function(context) {
var cacheKey = "nonBraceCharacter" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
if (this._input.substr(this._pos).match(/^[^{}]/) !== null) {
var result91 = this._input.charAt(this._pos);
this._pos++;
} else {
var result91 = null;
if (context.reportMatchFailures) {
this._matchFailed('[' + "^{}" + ']');
}
}
var result90 = result91 !== null
? (function($1) { return $1; })(result91)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result90
};
return result90;
},
_parse_colon: function(context) {
var cacheKey = "colon" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos16 = this._pos;
if (this._input.substr(this._pos, 1) === ":") {
var result94 = ":";
this._pos += 1;
} else {
var result94 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString(":"));
}
}
if (result94 !== null) {
var result95 = this._parse___(context);
if (result95 !== null) {
var result93 = [result94, result95];
} else {
var result93 = null;
this._pos = savedPos16;
}
} else {
var result93 = null;
this._pos = savedPos16;
}
var result92 = result93 !== null
? (function($1, $2) { return $1; }).apply(null, result93)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result92
};
return result92;
},
_parse_slash: function(context) {
var cacheKey = "slash" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos17 = this._pos;
if (this._input.substr(this._pos, 1) === "/") {
var result98 = "/";
this._pos += 1;
} else {
var result98 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("/"));
}
}
if (result98 !== null) {
var result99 = this._parse___(context);
if (result99 !== null) {
var result97 = [result98, result99];
} else {
var result97 = null;
this._pos = savedPos17;
}
} else {
var result97 = null;
this._pos = savedPos17;
}
var result96 = result97 !== null
? (function($1, $2) { return $1; }).apply(null, result97)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result96
};
return result96;
},
_parse_and: function(context) {
var cacheKey = "and" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos18 = this._pos;
if (this._input.substr(this._pos, 1) === "&") {
var result102 = "&";
this._pos += 1;
} else {
var result102 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("&"));
}
}
if (result102 !== null) {
var result103 = this._parse___(context);
if (result103 !== null) {
var result101 = [result102, result103];
} else {
var result101 = null;
this._pos = savedPos18;
}
} else {
var result101 = null;
this._pos = savedPos18;
}
var result100 = result101 !== null
? (function($1, $2) { return $1; }).apply(null, result101)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result100
};
return result100;
},
_parse_not: function(context) {
var cacheKey = "not" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos19 = this._pos;
if (this._input.substr(this._pos, 1) === "!") {
var result106 = "!";
this._pos += 1;
} else {
var result106 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("!"));
}
}
if (result106 !== null) {
var result107 = this._parse___(context);
if (result107 !== null) {
var result105 = [result106, result107];
} else {
var result105 = null;
this._pos = savedPos19;
}
} else {
var result105 = null;
this._pos = savedPos19;
}
var result104 = result105 !== null
? (function($1, $2) { return $1; }).apply(null, result105)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result104
};
return result104;
},
_parse_question: function(context) {
var cacheKey = "question" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos20 = this._pos;
if (this._input.substr(this._pos, 1) === "?") {
var result110 = "?";
this._pos += 1;
} else {
var result110 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("?"));
}
}
if (result110 !== null) {
var result111 = this._parse___(context);
if (result111 !== null) {
var result109 = [result110, result111];
} else {
var result109 = null;
this._pos = savedPos20;
}
} else {
var result109 = null;
this._pos = savedPos20;
}
var result108 = result109 !== null
? (function($1, $2) { return $1; }).apply(null, result109)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result108
};
return result108;
},
_parse_star: function(context) {
var cacheKey = "star" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos21 = this._pos;
if (this._input.substr(this._pos, 1) === "*") {
var result114 = "*";
this._pos += 1;
} else {
var result114 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("*"));
}
}
if (result114 !== null) {
var result115 = this._parse___(context);
if (result115 !== null) {
var result113 = [result114, result115];
} else {
var result113 = null;
this._pos = savedPos21;
}
} else {
var result113 = null;
this._pos = savedPos21;
}
var result112 = result113 !== null
? (function($1, $2) { return $1; }).apply(null, result113)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result112
};
return result112;
},
_parse_plus: function(context) {
var cacheKey = "plus" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos22 = this._pos;
if (this._input.substr(this._pos, 1) === "+") {
var result118 = "+";
this._pos += 1;
} else {
var result118 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("+"));
}
}
if (result118 !== null) {
var result119 = this._parse___(context);
if (result119 !== null) {
var result117 = [result118, result119];
} else {
var result117 = null;
this._pos = savedPos22;
}
} else {
var result117 = null;
this._pos = savedPos22;
}
var result116 = result117 !== null
? (function($1, $2) { return $1; }).apply(null, result117)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result116
};
return result116;
},
_parse_lparen: function(context) {
var cacheKey = "lparen" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos23 = this._pos;
if (this._input.substr(this._pos, 1) === "(") {
var result122 = "(";
this._pos += 1;
} else {
var result122 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("("));
}
}
if (result122 !== null) {
var result123 = this._parse___(context);
if (result123 !== null) {
var result121 = [result122, result123];
} else {
var result121 = null;
this._pos = savedPos23;
}
} else {
var result121 = null;
this._pos = savedPos23;
}
var result120 = result121 !== null
? (function($1, $2) { return $1; }).apply(null, result121)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result120
};
return result120;
},
_parse_rparen: function(context) {
var cacheKey = "rparen" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos24 = this._pos;
if (this._input.substr(this._pos, 1) === ")") {
var result126 = ")";
this._pos += 1;
} else {
var result126 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString(")"));
}
}
if (result126 !== null) {
var result127 = this._parse___(context);
if (result127 !== null) {
var result125 = [result126, result127];
} else {
var result125 = null;
this._pos = savedPos24;
}
} else {
var result125 = null;
this._pos = savedPos24;
}
var result124 = result125 !== null
? (function($1, $2) { return $1; }).apply(null, result125)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result124
};
return result124;
},
_parse_dot: function(context) {
var cacheKey = "dot" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos25 = this._pos;
if (this._input.substr(this._pos, 1) === ".") {
var result130 = ".";
this._pos += 1;
} else {
var result130 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("."));
}
}
if (result130 !== null) {
var result131 = this._parse___(context);
if (result131 !== null) {
var result129 = [result130, result131];
} else {
var result129 = null;
this._pos = savedPos25;
}
} else {
var result129 = null;
this._pos = savedPos25;
}
var result128 = result129 !== null
? (function($1, $2) { return $1; }).apply(null, result129)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result128
};
return result128;
},
_parse_identifier: function(context) {
var cacheKey = "identifier" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedReportMatchFailures = context.reportMatchFailures;
context.reportMatchFailures = false;
var savedPos26 = this._pos;
var result144 = this._parse_letter(context);
if (result144 !== null) {
var result134 = result144;
} else {
if (this._input.substr(this._pos, 1) === "_") {
var result143 = "_";
this._pos += 1;
} else {
var result143 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("_"));
}
}
if (result143 !== null) {
var result134 = result143;
} else {
if (this._input.substr(this._pos, 1) === "$") {
var result142 = "$";
this._pos += 1;
} else {
var result142 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("$"));
}
}
if (result142 !== null) {
var result134 = result142;
} else {
var result134 = null;;
};
};
}
if (result134 !== null) {
var result135 = [];
var result141 = this._parse_letter(context);
if (result141 !== null) {
var result137 = result141;
} else {
var result140 = this._parse_digit(context);
if (result140 !== null) {
var result137 = result140;
} else {
if (this._input.substr(this._pos, 1) === "_") {
var result139 = "_";
this._pos += 1;
} else {
var result139 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("_"));
}
}
if (result139 !== null) {
var result137 = result139;
} else {
if (this._input.substr(this._pos, 1) === "$") {
var result138 = "$";
this._pos += 1;
} else {
var result138 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("$"));
}
}
if (result138 !== null) {
var result137 = result138;
} else {
var result137 = null;;
};
};
};
}
while (result137 !== null) {
result135.push(result137);
var result141 = this._parse_letter(context);
if (result141 !== null) {
var result137 = result141;
} else {
var result140 = this._parse_digit(context);
if (result140 !== null) {
var result137 = result140;
} else {
if (this._input.substr(this._pos, 1) === "_") {
var result139 = "_";
this._pos += 1;
} else {
var result139 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("_"));
}
}
if (result139 !== null) {
var result137 = result139;
} else {
if (this._input.substr(this._pos, 1) === "$") {
var result138 = "$";
this._pos += 1;
} else {
var result138 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("$"));
}
}
if (result138 !== null) {
var result137 = result138;
} else {
var result137 = null;;
};
};
};
}
}
if (result135 !== null) {
var result136 = this._parse___(context);
if (result136 !== null) {
var result133 = [result134, result135, result136];
} else {
var result133 = null;
this._pos = savedPos26;
}
} else {
var result133 = null;
this._pos = savedPos26;
}
} else {
var result133 = null;
this._pos = savedPos26;
}
var result132 = result133 !== null
? (function($1, $2, $3) {
return $1 + $2.join("");
}).apply(null, result133)
: null;
context.reportMatchFailures = savedReportMatchFailures;
if (context.reportMatchFailures && result132 === null) {
this._matchFailed("identifier");
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result132
};
return result132;
},
_parse_literal: function(context) {
var cacheKey = "literal" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedReportMatchFailures = context.reportMatchFailures;
context.reportMatchFailures = false;
var savedPos27 = this._pos;
var result150 = this._parse_doubleQuotedLiteral(context);
if (result150 !== null) {
var result147 = result150;
} else {
var result149 = this._parse_singleQuotedLiteral(context);
if (result149 !== null) {
var result147 = result149;
} else {
var result147 = null;;
};
}
if (result147 !== null) {
var result148 = this._parse___(context);
if (result148 !== null) {
var result146 = [result147, result148];
} else {
var result146 = null;
this._pos = savedPos27;
}
} else {
var result146 = null;
this._pos = savedPos27;
}
var result145 = result146 !== null
? (function($1, $2) { return $1; }).apply(null, result146)
: null;
context.reportMatchFailures = savedReportMatchFailures;
if (context.reportMatchFailures && result145 === null) {
this._matchFailed("literal");
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result145
};
return result145;
},
_parse_doubleQuotedLiteral: function(context) {
var cacheKey = "doubleQuotedLiteral" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos28 = this._pos;
if (this._input.substr(this._pos, 1) === "\"") {
var result153 = "\"";
this._pos += 1;
} else {
var result153 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\""));
}
}
if (result153 !== null) {
var result154 = [];
var result156 = this._parse_doubleQuotedCharacter(context);
while (result156 !== null) {
result154.push(result156);
var result156 = this._parse_doubleQuotedCharacter(context);
}
if (result154 !== null) {
if (this._input.substr(this._pos, 1) === "\"") {
var result155 = "\"";
this._pos += 1;
} else {
var result155 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\""));
}
}
if (result155 !== null) {
var result152 = [result153, result154, result155];
} else {
var result152 = null;
this._pos = savedPos28;
}
} else {
var result152 = null;
this._pos = savedPos28;
}
} else {
var result152 = null;
this._pos = savedPos28;
}
var result151 = result152 !== null
? (function($1, $2, $3) { return $2.join(""); }).apply(null, result152)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result151
};
return result151;
},
_parse_doubleQuotedCharacter: function(context) {
var cacheKey = "doubleQuotedCharacter" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var result163 = this._parse_simpleDoubleQuotedCharacter(context);
if (result163 !== null) {
var result157 = result163;
} else {
var result162 = this._parse_simpleEscapeSequence(context);
if (result162 !== null) {
var result157 = result162;
} else {
var result161 = this._parse_zeroEscapeSequence(context);
if (result161 !== null) {
var result157 = result161;
} else {
var result160 = this._parse_hexEscapeSequence(context);
if (result160 !== null) {
var result157 = result160;
} else {
var result159 = this._parse_unicodeEscapeSequence(context);
if (result159 !== null) {
var result157 = result159;
} else {
var result158 = this._parse_eolEscapeSequence(context);
if (result158 !== null) {
var result157 = result158;
} else {
var result157 = null;;
};
};
};
};
};
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result157
};
return result157;
},
_parse_simpleDoubleQuotedCharacter: function(context) {
var cacheKey = "simpleDoubleQuotedCharacter" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos29 = this._pos;
var savedPos30 = this._pos;
var savedReportMatchFailuresVar1 = context.reportMatchFailures;
context.reportMatchFailures = false;
if (this._input.substr(this._pos, 1) === "\"") {
var result171 = "\"";
this._pos += 1;
} else {
var result171 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\""));
}
}
if (result171 !== null) {
var result168 = result171;
} else {
if (this._input.substr(this._pos, 1) === "\\") {
var result170 = "\\";
this._pos += 1;
} else {
var result170 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\\"));
}
}
if (result170 !== null) {
var result168 = result170;
} else {
var result169 = this._parse_eolChar(context);
if (result169 !== null) {
var result168 = result169;
} else {
var result168 = null;;
};
};
}
context.reportMatchFailures = savedReportMatchFailuresVar1;
if (result168 === null) {
var result166 = '';
} else {
var result166 = null;
this._pos = savedPos30;
}
if (result166 !== null) {
if (this._input.length > this._pos) {
var result167 = this._input.charAt(this._pos);
this._pos++;
} else {
var result167 = null;
if (context.reportMatchFailures) {
this._matchFailed('any character');
}
}
if (result167 !== null) {
var result165 = [result166, result167];
} else {
var result165 = null;
this._pos = savedPos29;
}
} else {
var result165 = null;
this._pos = savedPos29;
}
var result164 = result165 !== null
? (function($1, $2) { return $2; }).apply(null, result165)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result164
};
return result164;
},
_parse_singleQuotedLiteral: function(context) {
var cacheKey = "singleQuotedLiteral" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos31 = this._pos;
if (this._input.substr(this._pos, 1) === "'") {
var result174 = "'";
this._pos += 1;
} else {
var result174 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("'"));
}
}
if (result174 !== null) {
var result175 = [];
var result177 = this._parse_singleQuotedCharacter(context);
while (result177 !== null) {
result175.push(result177);
var result177 = this._parse_singleQuotedCharacter(context);
}
if (result175 !== null) {
if (this._input.substr(this._pos, 1) === "'") {
var result176 = "'";
this._pos += 1;
} else {
var result176 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("'"));
}
}
if (result176 !== null) {
var result173 = [result174, result175, result176];
} else {
var result173 = null;
this._pos = savedPos31;
}
} else {
var result173 = null;
this._pos = savedPos31;
}
} else {
var result173 = null;
this._pos = savedPos31;
}
var result172 = result173 !== null
? (function($1, $2, $3) { return $2.join(""); }).apply(null, result173)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result172
};
return result172;
},
_parse_singleQuotedCharacter: function(context) {
var cacheKey = "singleQuotedCharacter" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var result184 = this._parse_simpleSingleQuotedCharacter(context);
if (result184 !== null) {
var result178 = result184;
} else {
var result183 = this._parse_simpleEscapeSequence(context);
if (result183 !== null) {
var result178 = result183;
} else {
var result182 = this._parse_zeroEscapeSequence(context);
if (result182 !== null) {
var result178 = result182;
} else {
var result181 = this._parse_hexEscapeSequence(context);
if (result181 !== null) {
var result178 = result181;
} else {
var result180 = this._parse_unicodeEscapeSequence(context);
if (result180 !== null) {
var result178 = result180;
} else {
var result179 = this._parse_eolEscapeSequence(context);
if (result179 !== null) {
var result178 = result179;
} else {
var result178 = null;;
};
};
};
};
};
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result178
};
return result178;
},
_parse_simpleSingleQuotedCharacter: function(context) {
var cacheKey = "simpleSingleQuotedCharacter" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos32 = this._pos;
var savedPos33 = this._pos;
var savedReportMatchFailuresVar2 = context.reportMatchFailures;
context.reportMatchFailures = false;
if (this._input.substr(this._pos, 1) === "'") {
var result192 = "'";
this._pos += 1;
} else {
var result192 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("'"));
}
}
if (result192 !== null) {
var result189 = result192;
} else {
if (this._input.substr(this._pos, 1) === "\\") {
var result191 = "\\";
this._pos += 1;
} else {
var result191 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\\"));
}
}
if (result191 !== null) {
var result189 = result191;
} else {
var result190 = this._parse_eolChar(context);
if (result190 !== null) {
var result189 = result190;
} else {
var result189 = null;;
};
};
}
context.reportMatchFailures = savedReportMatchFailuresVar2;
if (result189 === null) {
var result187 = '';
} else {
var result187 = null;
this._pos = savedPos33;
}
if (result187 !== null) {
if (this._input.length > this._pos) {
var result188 = this._input.charAt(this._pos);
this._pos++;
} else {
var result188 = null;
if (context.reportMatchFailures) {
this._matchFailed('any character');
}
}
if (result188 !== null) {
var result186 = [result187, result188];
} else {
var result186 = null;
this._pos = savedPos32;
}
} else {
var result186 = null;
this._pos = savedPos32;
}
var result185 = result186 !== null
? (function($1, $2) { return $2; }).apply(null, result186)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result185
};
return result185;
},
_parse_class: function(context) {
var cacheKey = "class" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedReportMatchFailures = context.reportMatchFailures;
context.reportMatchFailures = false;
var savedPos34 = this._pos;
if (this._input.substr(this._pos, 1) === "[") {
var result195 = "[";
this._pos += 1;
} else {
var result195 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("["));
}
}
if (result195 !== null) {
if (this._input.substr(this._pos, 1) === "^") {
var result203 = "^";
this._pos += 1;
} else {
var result203 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("^"));
}
}
var result196 = result203 !== null ? result203 : '';
if (result196 !== null) {
var result197 = [];
var result202 = this._parse_classCharacterRange(context);
if (result202 !== null) {
var result200 = result202;
} else {
var result201 = this._parse_classCharacter(context);
if (result201 !== null) {
var result200 = result201;
} else {
var result200 = null;;
};
}
while (result200 !== null) {
result197.push(result200);
var result202 = this._parse_classCharacterRange(context);
if (result202 !== null) {
var result200 = result202;
} else {
var result201 = this._parse_classCharacter(context);
if (result201 !== null) {
var result200 = result201;
} else {
var result200 = null;;
};
}
}
if (result197 !== null) {
if (this._input.substr(this._pos, 1) === "]") {
var result198 = "]";
this._pos += 1;
} else {
var result198 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("]"));
}
}
if (result198 !== null) {
var result199 = this._parse___(context);
if (result199 !== null) {
var result194 = [result195, result196, result197, result198, result199];
} else {
var result194 = null;
this._pos = savedPos34;
}
} else {
var result194 = null;
this._pos = savedPos34;
}
} else {
var result194 = null;
this._pos = savedPos34;
}
} else {
var result194 = null;
this._pos = savedPos34;
}
} else {
var result194 = null;
this._pos = savedPos34;
}
var result193 = result194 !== null
? (function($1, $2, $3, $4, $5) {
return $2 + $3.join("");
}).apply(null, result194)
: null;
context.reportMatchFailures = savedReportMatchFailures;
if (context.reportMatchFailures && result193 === null) {
this._matchFailed("character class");
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result193
};
return result193;
},
_parse_classCharacterRange: function(context) {
var cacheKey = "classCharacterRange" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos35 = this._pos;
var result206 = this._parse_bracketDelimitedCharacter(context);
if (result206 !== null) {
if (this._input.substr(this._pos, 1) === "-") {
var result207 = "-";
this._pos += 1;
} else {
var result207 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("-"));
}
}
if (result207 !== null) {
var result208 = this._parse_bracketDelimitedCharacter(context);
if (result208 !== null) {
var result205 = [result206, result207, result208];
} else {
var result205 = null;
this._pos = savedPos35;
}
} else {
var result205 = null;
this._pos = savedPos35;
}
} else {
var result205 = null;
this._pos = savedPos35;
}
var result204 = result205 !== null
? (function($1, $2, $3) {
if ($1.charCodeAt(0) > $3.charCodeAt(0)) {
throw new this.SyntaxError(
"Invalid character range: "
+ PEG.RegExpUtils.quoteForClass($1)
+ "-"
+ PEG.RegExpUtils.quoteForClass($3)
+ "."
);
}
return PEG.RegExpUtils.quoteForClass($1)
+ "-"
+ PEG.RegExpUtils.quoteForClass($3);
}).apply(null, result205)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result204
};
return result204;
},
_parse_classCharacter: function(context) {
var cacheKey = "classCharacter" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var result210 = this._parse_bracketDelimitedCharacter(context);
var result209 = result210 !== null
? (function($1) {
return PEG.RegExpUtils.quoteForClass($1);
})(result210)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result209
};
return result209;
},
_parse_bracketDelimitedCharacter: function(context) {
var cacheKey = "bracketDelimitedCharacter" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var result217 = this._parse_simpleBracketDelimitedCharacter(context);
if (result217 !== null) {
var result211 = result217;
} else {
var result216 = this._parse_simpleEscapeSequence(context);
if (result216 !== null) {
var result211 = result216;
} else {
var result215 = this._parse_zeroEscapeSequence(context);
if (result215 !== null) {
var result211 = result215;
} else {
var result214 = this._parse_hexEscapeSequence(context);
if (result214 !== null) {
var result211 = result214;
} else {
var result213 = this._parse_unicodeEscapeSequence(context);
if (result213 !== null) {
var result211 = result213;
} else {
var result212 = this._parse_eolEscapeSequence(context);
if (result212 !== null) {
var result211 = result212;
} else {
var result211 = null;;
};
};
};
};
};
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result211
};
return result211;
},
_parse_simpleBracketDelimitedCharacter: function(context) {
var cacheKey = "simpleBracketDelimitedCharacter" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos36 = this._pos;
var savedPos37 = this._pos;
var savedReportMatchFailuresVar3 = context.reportMatchFailures;
context.reportMatchFailures = false;
if (this._input.substr(this._pos, 1) === "]") {
var result225 = "]";
this._pos += 1;
} else {
var result225 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("]"));
}
}
if (result225 !== null) {
var result222 = result225;
} else {
if (this._input.substr(this._pos, 1) === "\\") {
var result224 = "\\";
this._pos += 1;
} else {
var result224 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\\"));
}
}
if (result224 !== null) {
var result222 = result224;
} else {
var result223 = this._parse_eolChar(context);
if (result223 !== null) {
var result222 = result223;
} else {
var result222 = null;;
};
};
}
context.reportMatchFailures = savedReportMatchFailuresVar3;
if (result222 === null) {
var result220 = '';
} else {
var result220 = null;
this._pos = savedPos37;
}
if (result220 !== null) {
if (this._input.length > this._pos) {
var result221 = this._input.charAt(this._pos);
this._pos++;
} else {
var result221 = null;
if (context.reportMatchFailures) {
this._matchFailed('any character');
}
}
if (result221 !== null) {
var result219 = [result220, result221];
} else {
var result219 = null;
this._pos = savedPos36;
}
} else {
var result219 = null;
this._pos = savedPos36;
}
var result218 = result219 !== null
? (function($1, $2) { return $2; }).apply(null, result219)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result218
};
return result218;
},
_parse_simpleEscapeSequence: function(context) {
var cacheKey = "simpleEscapeSequence" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos38 = this._pos;
if (this._input.substr(this._pos, 1) === "\\") {
var result228 = "\\";
this._pos += 1;
} else {
var result228 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\\"));
}
}
if (result228 !== null) {
var savedPos39 = this._pos;
var savedReportMatchFailuresVar4 = context.reportMatchFailures;
context.reportMatchFailures = false;
var result235 = this._parse_digit(context);
if (result235 !== null) {
var result231 = result235;
} else {
if (this._input.substr(this._pos, 1) === "x") {
var result234 = "x";
this._pos += 1;
} else {
var result234 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("x"));
}
}
if (result234 !== null) {
var result231 = result234;
} else {
if (this._input.substr(this._pos, 1) === "u") {
var result233 = "u";
this._pos += 1;
} else {
var result233 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("u"));
}
}
if (result233 !== null) {
var result231 = result233;
} else {
var result232 = this._parse_eolChar(context);
if (result232 !== null) {
var result231 = result232;
} else {
var result231 = null;;
};
};
};
}
context.reportMatchFailures = savedReportMatchFailuresVar4;
if (result231 === null) {
var result229 = '';
} else {
var result229 = null;
this._pos = savedPos39;
}
if (result229 !== null) {
if (this._input.length > this._pos) {
var result230 = this._input.charAt(this._pos);
this._pos++;
} else {
var result230 = null;
if (context.reportMatchFailures) {
this._matchFailed('any character');
}
}
if (result230 !== null) {
var result227 = [result228, result229, result230];
} else {
var result227 = null;
this._pos = savedPos38;
}
} else {
var result227 = null;
this._pos = savedPos38;
}
} else {
var result227 = null;
this._pos = savedPos38;
}
var result226 = result227 !== null
? (function($1, $2, $3) {
return $3
.replace("b", "\b")
.replace("f", "\f")
.replace("n", "\n")
.replace("r", "\r")
.replace("t", "\t")
.replace("v", "\x0B") // IE does not recognize "\v".
}).apply(null, result227)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result226
};
return result226;
},
_parse_zeroEscapeSequence: function(context) {
var cacheKey = "zeroEscapeSequence" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos40 = this._pos;
if (this._input.substr(this._pos, 2) === "\\0") {
var result238 = "\\0";
this._pos += 2;
} else {
var result238 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\\0"));
}
}
if (result238 !== null) {
var savedPos41 = this._pos;
var savedReportMatchFailuresVar5 = context.reportMatchFailures;
context.reportMatchFailures = false;
var result240 = this._parse_digit(context);
context.reportMatchFailures = savedReportMatchFailuresVar5;
if (result240 === null) {
var result239 = '';
} else {
var result239 = null;
this._pos = savedPos41;
}
if (result239 !== null) {
var result237 = [result238, result239];
} else {
var result237 = null;
this._pos = savedPos40;
}
} else {
var result237 = null;
this._pos = savedPos40;
}
var result236 = result237 !== null
? (function($1, $2) { return "\0"; }).apply(null, result237)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result236
};
return result236;
},
_parse_hexEscapeSequence: function(context) {
var cacheKey = "hexEscapeSequence" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos42 = this._pos;
if (this._input.substr(this._pos, 2) === "\\x") {
var result243 = "\\x";
this._pos += 2;
} else {
var result243 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\\x"));
}
}
if (result243 !== null) {
var result244 = this._parse_hexDigit(context);
if (result244 !== null) {
var result245 = this._parse_hexDigit(context);
if (result245 !== null) {
var result242 = [result243, result244, result245];
} else {
var result242 = null;
this._pos = savedPos42;
}
} else {
var result242 = null;
this._pos = savedPos42;
}
} else {
var result242 = null;
this._pos = savedPos42;
}
var result241 = result242 !== null
? (function($1, $2, $3) {
return String.fromCharCode(parseInt("0x" + $2 + $3));
}).apply(null, result242)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result241
};
return result241;
},
_parse_unicodeEscapeSequence: function(context) {
var cacheKey = "unicodeEscapeSequence" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos43 = this._pos;
if (this._input.substr(this._pos, 2) === "\\u") {
var result248 = "\\u";
this._pos += 2;
} else {
var result248 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\\u"));
}
}
if (result248 !== null) {
var result249 = this._parse_hexDigit(context);
if (result249 !== null) {
var result250 = this._parse_hexDigit(context);
if (result250 !== null) {
var result251 = this._parse_hexDigit(context);
if (result251 !== null) {
var result252 = this._parse_hexDigit(context);
if (result252 !== null) {
var result247 = [result248, result249, result250, result251, result252];
} else {
var result247 = null;
this._pos = savedPos43;
}
} else {
var result247 = null;
this._pos = savedPos43;
}
} else {
var result247 = null;
this._pos = savedPos43;
}
} else {
var result247 = null;
this._pos = savedPos43;
}
} else {
var result247 = null;
this._pos = savedPos43;
}
var result246 = result247 !== null
? (function($1, $2, $3, $4, $5) {
return String.fromCharCode(parseInt("0x" + $2 + $3 + $4 + $5));
}).apply(null, result247)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result246
};
return result246;
},
_parse_eolEscapeSequence: function(context) {
var cacheKey = "eolEscapeSequence" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos44 = this._pos;
if (this._input.substr(this._pos, 1) === "\\") {
var result255 = "\\";
this._pos += 1;
} else {
var result255 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\\"));
}
}
if (result255 !== null) {
var result256 = this._parse_eol(context);
if (result256 !== null) {
var result254 = [result255, result256];
} else {
var result254 = null;
this._pos = savedPos44;
}
} else {
var result254 = null;
this._pos = savedPos44;
}
var result253 = result254 !== null
? (function($1, $2) { return $2; }).apply(null, result254)
: null;
this._cache[cacheKey] = {
nextPos: this._pos,
result: result253
};
return result253;
},
_parse_digit: function(context) {
var cacheKey = "digit" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
if (this._input.substr(this._pos).match(/^[0-9]/) !== null) {
var result257 = this._input.charAt(this._pos);
this._pos++;
} else {
var result257 = null;
if (context.reportMatchFailures) {
this._matchFailed('[' + "0-9" + ']');
}
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result257
};
return result257;
},
_parse_hexDigit: function(context) {
var cacheKey = "hexDigit" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
if (this._input.substr(this._pos).match(/^[0-9a-fA-F]/) !== null) {
var result258 = this._input.charAt(this._pos);
this._pos++;
} else {
var result258 = null;
if (context.reportMatchFailures) {
this._matchFailed('[' + "0-9a-fA-F" + ']');
}
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result258
};
return result258;
},
_parse_letter: function(context) {
var cacheKey = "letter" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var result261 = this._parse_lowerCaseLetter(context);
if (result261 !== null) {
var result259 = result261;
} else {
var result260 = this._parse_upperCaseLetter(context);
if (result260 !== null) {
var result259 = result260;
} else {
var result259 = null;;
};
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result259
};
return result259;
},
_parse_lowerCaseLetter: function(context) {
var cacheKey = "lowerCaseLetter" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
if (this._input.substr(this._pos).match(/^[a-z]/) !== null) {
var result262 = this._input.charAt(this._pos);
this._pos++;
} else {
var result262 = null;
if (context.reportMatchFailures) {
this._matchFailed('[' + "a-z" + ']');
}
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result262
};
return result262;
},
_parse_upperCaseLetter: function(context) {
var cacheKey = "upperCaseLetter" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
if (this._input.substr(this._pos).match(/^[A-Z]/) !== null) {
var result263 = this._input.charAt(this._pos);
this._pos++;
} else {
var result263 = null;
if (context.reportMatchFailures) {
this._matchFailed('[' + "A-Z" + ']');
}
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result263
};
return result263;
},
_parse___: function(context) {
var cacheKey = "__" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var result264 = [];
var result268 = this._parse_whitespace(context);
if (result268 !== null) {
var result265 = result268;
} else {
var result267 = this._parse_eol(context);
if (result267 !== null) {
var result265 = result267;
} else {
var result266 = this._parse_comment(context);
if (result266 !== null) {
var result265 = result266;
} else {
var result265 = null;;
};
};
}
while (result265 !== null) {
result264.push(result265);
var result268 = this._parse_whitespace(context);
if (result268 !== null) {
var result265 = result268;
} else {
var result267 = this._parse_eol(context);
if (result267 !== null) {
var result265 = result267;
} else {
var result266 = this._parse_comment(context);
if (result266 !== null) {
var result265 = result266;
} else {
var result265 = null;;
};
};
}
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result264
};
return result264;
},
_parse_comment: function(context) {
var cacheKey = "comment" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedReportMatchFailures = context.reportMatchFailures;
context.reportMatchFailures = false;
var result271 = this._parse_singleLineComment(context);
if (result271 !== null) {
var result269 = result271;
} else {
var result270 = this._parse_multiLineComment(context);
if (result270 !== null) {
var result269 = result270;
} else {
var result269 = null;;
};
}
context.reportMatchFailures = savedReportMatchFailures;
if (context.reportMatchFailures && result269 === null) {
this._matchFailed("comment");
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result269
};
return result269;
},
_parse_singleLineComment: function(context) {
var cacheKey = "singleLineComment" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos45 = this._pos;
if (this._input.substr(this._pos, 2) === "//") {
var result273 = "//";
this._pos += 2;
} else {
var result273 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("//"));
}
}
if (result273 !== null) {
var result274 = [];
var savedPos46 = this._pos;
var savedPos47 = this._pos;
var savedReportMatchFailuresVar6 = context.reportMatchFailures;
context.reportMatchFailures = false;
var result278 = this._parse_eolChar(context);
context.reportMatchFailures = savedReportMatchFailuresVar6;
if (result278 === null) {
var result276 = '';
} else {
var result276 = null;
this._pos = savedPos47;
}
if (result276 !== null) {
if (this._input.length > this._pos) {
var result277 = this._input.charAt(this._pos);
this._pos++;
} else {
var result277 = null;
if (context.reportMatchFailures) {
this._matchFailed('any character');
}
}
if (result277 !== null) {
var result275 = [result276, result277];
} else {
var result275 = null;
this._pos = savedPos46;
}
} else {
var result275 = null;
this._pos = savedPos46;
}
while (result275 !== null) {
result274.push(result275);
var savedPos46 = this._pos;
var savedPos47 = this._pos;
var savedReportMatchFailuresVar6 = context.reportMatchFailures;
context.reportMatchFailures = false;
var result278 = this._parse_eolChar(context);
context.reportMatchFailures = savedReportMatchFailuresVar6;
if (result278 === null) {
var result276 = '';
} else {
var result276 = null;
this._pos = savedPos47;
}
if (result276 !== null) {
if (this._input.length > this._pos) {
var result277 = this._input.charAt(this._pos);
this._pos++;
} else {
var result277 = null;
if (context.reportMatchFailures) {
this._matchFailed('any character');
}
}
if (result277 !== null) {
var result275 = [result276, result277];
} else {
var result275 = null;
this._pos = savedPos46;
}
} else {
var result275 = null;
this._pos = savedPos46;
}
}
if (result274 !== null) {
var result272 = [result273, result274];
} else {
var result272 = null;
this._pos = savedPos45;
}
} else {
var result272 = null;
this._pos = savedPos45;
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result272
};
return result272;
},
_parse_multiLineComment: function(context) {
var cacheKey = "multiLineComment" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedPos48 = this._pos;
if (this._input.substr(this._pos, 2) === "/*") {
var result280 = "/*";
this._pos += 2;
} else {
var result280 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("/*"));
}
}
if (result280 !== null) {
var result281 = [];
var savedPos49 = this._pos;
var savedPos50 = this._pos;
var savedReportMatchFailuresVar7 = context.reportMatchFailures;
context.reportMatchFailures = false;
if (this._input.substr(this._pos, 2) === "*/") {
var result286 = "*/";
this._pos += 2;
} else {
var result286 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("*/"));
}
}
context.reportMatchFailures = savedReportMatchFailuresVar7;
if (result286 === null) {
var result284 = '';
} else {
var result284 = null;
this._pos = savedPos50;
}
if (result284 !== null) {
if (this._input.length > this._pos) {
var result285 = this._input.charAt(this._pos);
this._pos++;
} else {
var result285 = null;
if (context.reportMatchFailures) {
this._matchFailed('any character');
}
}
if (result285 !== null) {
var result283 = [result284, result285];
} else {
var result283 = null;
this._pos = savedPos49;
}
} else {
var result283 = null;
this._pos = savedPos49;
}
while (result283 !== null) {
result281.push(result283);
var savedPos49 = this._pos;
var savedPos50 = this._pos;
var savedReportMatchFailuresVar7 = context.reportMatchFailures;
context.reportMatchFailures = false;
if (this._input.substr(this._pos, 2) === "*/") {
var result286 = "*/";
this._pos += 2;
} else {
var result286 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("*/"));
}
}
context.reportMatchFailures = savedReportMatchFailuresVar7;
if (result286 === null) {
var result284 = '';
} else {
var result284 = null;
this._pos = savedPos50;
}
if (result284 !== null) {
if (this._input.length > this._pos) {
var result285 = this._input.charAt(this._pos);
this._pos++;
} else {
var result285 = null;
if (context.reportMatchFailures) {
this._matchFailed('any character');
}
}
if (result285 !== null) {
var result283 = [result284, result285];
} else {
var result283 = null;
this._pos = savedPos49;
}
} else {
var result283 = null;
this._pos = savedPos49;
}
}
if (result281 !== null) {
if (this._input.substr(this._pos, 2) === "*/") {
var result282 = "*/";
this._pos += 2;
} else {
var result282 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("*/"));
}
}
if (result282 !== null) {
var result279 = [result280, result281, result282];
} else {
var result279 = null;
this._pos = savedPos48;
}
} else {
var result279 = null;
this._pos = savedPos48;
}
} else {
var result279 = null;
this._pos = savedPos48;
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result279
};
return result279;
},
_parse_eol: function(context) {
var cacheKey = "eol" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedReportMatchFailures = context.reportMatchFailures;
context.reportMatchFailures = false;
if (this._input.substr(this._pos, 1) === "\n") {
var result292 = "\n";
this._pos += 1;
} else {
var result292 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\n"));
}
}
if (result292 !== null) {
var result287 = result292;
} else {
if (this._input.substr(this._pos, 2) === "\r\n") {
var result291 = "\r\n";
this._pos += 2;
} else {
var result291 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\r\n"));
}
}
if (result291 !== null) {
var result287 = result291;
} else {
if (this._input.substr(this._pos, 1) === "\r") {
var result290 = "\r";
this._pos += 1;
} else {
var result290 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\r"));
}
}
if (result290 !== null) {
var result287 = result290;
} else {
if (this._input.substr(this._pos, 1) === "\u2028") {
var result289 = "\u2028";
this._pos += 1;
} else {
var result289 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\u2028"));
}
}
if (result289 !== null) {
var result287 = result289;
} else {
if (this._input.substr(this._pos, 1) === "\u2029") {
var result288 = "\u2029";
this._pos += 1;
} else {
var result288 = null;
if (context.reportMatchFailures) {
this._matchFailed(this._quoteString("\u2029"));
}
}
if (result288 !== null) {
var result287 = result288;
} else {
var result287 = null;;
};
};
};
};
}
context.reportMatchFailures = savedReportMatchFailures;
if (context.reportMatchFailures && result287 === null) {
this._matchFailed("end of line");
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result287
};
return result287;
},
_parse_eolChar: function(context) {
var cacheKey = "eolChar" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
if (this._input.substr(this._pos).match(/^[\n\r\u2028\u2029]/) !== null) {
var result293 = this._input.charAt(this._pos);
this._pos++;
} else {
var result293 = null;
if (context.reportMatchFailures) {
this._matchFailed('[' + "\\n\\r\\u2028\\u2029" + ']');
}
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result293
};
return result293;
},
_parse_whitespace: function(context) {
var cacheKey = "whitespace" + '@' + this._pos;
var cachedResult = this._cache[cacheKey];
if (cachedResult !== undefined) {
this._pos = cachedResult.nextPos;
return cachedResult.result;
}
var pos = this._pos;
var savedReportMatchFailures = context.reportMatchFailures;
context.reportMatchFailures = false;
if (this._input.substr(this._pos).match(/^[   - ]/) !== null) {
var result294 = this._input.charAt(this._pos);
this._pos++;
} else {
var result294 = null;
if (context.reportMatchFailures) {
this._matchFailed('[' + "   - " + ']');
}
}
context.reportMatchFailures = savedReportMatchFailures;
if (context.reportMatchFailures && result294 === null) {
this._matchFailed("whitespace");
}
this._cache[cacheKey] = {
nextPos: this._pos,
result: result294
};
return result294;
},
/*
* Parses the input with a generated parser. If the parsing is successfull,
* returns a value explicitly or implicitly specified by the grammar from
* which the parser was generated (see |PEG.buildParser|). If the parsing is
* unsuccessful, throws |PEG.grammarParser.SyntaxError| describing the error.
*/
parse: function(input) {
var that = this;
function initialize() {
that._input = input;
that._pos = 0;
that._rightmostMatchFailuresPos = 0;
that._rightmostMatchFailuresExpected = [];
that._cache = {};
}
function buildErrorMessage() {
function buildExpected(failuresExpected) {
switch (failuresExpected.length) {
case 0:
return 'end of input';
case 1:
return failuresExpected[0];
default:
failuresExpected.sort();
return failuresExpected.slice(0, failuresExpected.length - 1).join(', ')
+ ' or '
+ failuresExpected[failuresExpected.length - 1];
}
}
var expected = buildExpected(that._rightmostMatchFailuresExpected);
var pos = Math.max(that._pos, that._rightmostMatchFailuresPos);
var actual = pos < that._input.length
? that._quoteString(that._input.charAt(pos))
: 'end of input';
return 'Expected ' + expected + ' but ' + actual + ' found.';
}
function computeErrorPosition() {
/*
* The first idea was to use |String.split| to break the input up to the
* error position along newlines and derive the line and column from
* there. However IE's |split| implementation is so broken that it was
* enough to prevent it.
*/
var input = that._input;
var pos = that._rightmostMatchFailuresPos;
var line = 1;
var column = 1;
var seenCR = false;
for (var i = 0; i < pos; i++) {
var ch = input.charAt(i);
if (ch === '\n') {
if (!seenCR) { line++; }
column = 1;
seenCR = false;
} else if (ch === '\r' | ch === '\u2028' || ch === '\u2029') {
line++;
column = 1;
seenCR = true;
} else {
column++;
seenCR = false;
}
}
return { line: line, column: column };
}
initialize();
var initialContext = {
reportMatchFailures: true
};
var result = this['_parse_' + this._startRule](initialContext);
/*
* The parser is now in one of the following three states:
*
* 1. The parser successfully parsed the whole input.
*
* - |result !== null|
* - |that._pos === input.length|
* - |that._rightmostMatchFailuresExpected.length| may or may not contain
* something
*
* 2. The parser successfully parsed only a part of the input.
*
* - |result !== null|
* - |that._pos < input.length|
* - |that._rightmostMatchFailuresExpected.length| may or may not contain
* something
*
* 3. The parser did not successfully parse any part of the input.
*
* - |result === null|
* - |that._pos === 0|
* - |that._rightmostMatchFailuresExpected.length| contains at least one failure
*
* All code following this comment (including called functions) must
* handle these states.
*/
if (result === null || this._pos !== input.length) {
var errorPosition = computeErrorPosition();
throw new this.SyntaxError(
buildErrorMessage(),
errorPosition.line,
errorPosition.column
);
}
return result;
},
/* Returns the parser source code. */
toSource: function() { return this._source; }
};
/* Thrown when a parser encounters a syntax error. */
result.SyntaxError = function(message, line, column) {
this.name = 'SyntaxError';
this.message = message;
this.line = line;
this.column = column;
};
result.SyntaxError.prototype = Error.prototype;
return result;
})();