3522 lines
100 KiB
JavaScript
3522 lines
100 KiB
JavaScript
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) {
|
||
return;
|
||
}
|
||
|
||
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) {
|
||
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(rules) {
|
||
var result = {};
|
||
PEG.ArrayUtils.each(rules, function(rule) { result[rule.name] = rule; });
|
||
return result;
|
||
})(result1[1])
|
||
: 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) {
|
||
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_equals(context);
|
||
if (result9 !== null) {
|
||
var result10 = this._parse_choice(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(name, displayName, expression) {
|
||
return {
|
||
type: "rule",
|
||
name: name,
|
||
displayName: displayName !== "" ? displayName : null,
|
||
expression: expression
|
||
};
|
||
})(result6[0], result6[1], result6[3])
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result5
|
||
};
|
||
return result5;
|
||
},
|
||
|
||
_parse_choice: function(context) {
|
||
var cacheKey = "choice" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos2 = this._pos;
|
||
var result15 = this._parse_sequence(context);
|
||
if (result15 !== null) {
|
||
var result16 = [];
|
||
var savedPos3 = this._pos;
|
||
var result18 = this._parse_slash(context);
|
||
if (result18 !== null) {
|
||
var result19 = this._parse_sequence(context);
|
||
if (result19 !== null) {
|
||
var result17 = [result18, result19];
|
||
} else {
|
||
var result17 = null;
|
||
this._pos = savedPos3;
|
||
}
|
||
} else {
|
||
var result17 = null;
|
||
this._pos = savedPos3;
|
||
}
|
||
while (result17 !== null) {
|
||
result16.push(result17);
|
||
var savedPos3 = this._pos;
|
||
var result18 = this._parse_slash(context);
|
||
if (result18 !== null) {
|
||
var result19 = this._parse_sequence(context);
|
||
if (result19 !== null) {
|
||
var result17 = [result18, result19];
|
||
} else {
|
||
var result17 = null;
|
||
this._pos = savedPos3;
|
||
}
|
||
} else {
|
||
var result17 = null;
|
||
this._pos = savedPos3;
|
||
}
|
||
}
|
||
if (result16 !== null) {
|
||
var result14 = [result15, result16];
|
||
} else {
|
||
var result14 = null;
|
||
this._pos = savedPos2;
|
||
}
|
||
} else {
|
||
var result14 = null;
|
||
this._pos = savedPos2;
|
||
}
|
||
var result13 = result14 !== null
|
||
? (function(head, tail) {
|
||
if (tail.length > 0) {
|
||
var alternatives = [head].concat(PEG.ArrayUtils.map(
|
||
tail,
|
||
function(element) { return element[1]; }
|
||
));
|
||
return {
|
||
type: "choice",
|
||
alternatives: alternatives
|
||
}
|
||
} else {
|
||
return head;
|
||
}
|
||
})(result14[0], result14[1])
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result13
|
||
};
|
||
return result13;
|
||
},
|
||
|
||
_parse_sequence: function(context) {
|
||
var cacheKey = "sequence" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos4 = this._pos;
|
||
var result26 = [];
|
||
var result28 = this._parse_labeled(context);
|
||
while (result28 !== null) {
|
||
result26.push(result28);
|
||
var result28 = this._parse_labeled(context);
|
||
}
|
||
if (result26 !== null) {
|
||
var result27 = this._parse_action(context);
|
||
if (result27 !== null) {
|
||
var result25 = [result26, result27];
|
||
} else {
|
||
var result25 = null;
|
||
this._pos = savedPos4;
|
||
}
|
||
} else {
|
||
var result25 = null;
|
||
this._pos = savedPos4;
|
||
}
|
||
var result24 = result25 !== null
|
||
? (function(elements, action) {
|
||
var expression = elements.length != 1
|
||
? {
|
||
type: "sequence",
|
||
elements: elements
|
||
}
|
||
: elements[0];
|
||
return {
|
||
type: "action",
|
||
expression: expression,
|
||
action: action
|
||
};
|
||
})(result25[0], result25[1])
|
||
: null;
|
||
if (result24 !== null) {
|
||
var result20 = result24;
|
||
} else {
|
||
var result22 = [];
|
||
var result23 = this._parse_labeled(context);
|
||
while (result23 !== null) {
|
||
result22.push(result23);
|
||
var result23 = this._parse_labeled(context);
|
||
}
|
||
var result21 = result22 !== null
|
||
? (function(elements) {
|
||
return elements.length != 1
|
||
? {
|
||
type: "sequence",
|
||
elements: elements
|
||
}
|
||
: elements[0];
|
||
})(result22)
|
||
: null;
|
||
if (result21 !== null) {
|
||
var result20 = result21;
|
||
} else {
|
||
var result20 = null;;
|
||
};
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result20
|
||
};
|
||
return result20;
|
||
},
|
||
|
||
_parse_labeled: function(context) {
|
||
var cacheKey = "labeled" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos5 = this._pos;
|
||
var result33 = this._parse_identifier(context);
|
||
if (result33 !== null) {
|
||
var result34 = this._parse_colon(context);
|
||
if (result34 !== null) {
|
||
var result35 = this._parse_prefixed(context);
|
||
if (result35 !== null) {
|
||
var result32 = [result33, result34, result35];
|
||
} else {
|
||
var result32 = null;
|
||
this._pos = savedPos5;
|
||
}
|
||
} else {
|
||
var result32 = null;
|
||
this._pos = savedPos5;
|
||
}
|
||
} else {
|
||
var result32 = null;
|
||
this._pos = savedPos5;
|
||
}
|
||
var result31 = result32 !== null
|
||
? (function(label, expression) {
|
||
return {
|
||
type: "labeled",
|
||
label: label,
|
||
expression: expression
|
||
};
|
||
})(result32[0], result32[2])
|
||
: null;
|
||
if (result31 !== null) {
|
||
var result29 = result31;
|
||
} else {
|
||
var result30 = this._parse_prefixed(context);
|
||
if (result30 !== null) {
|
||
var result29 = result30;
|
||
} else {
|
||
var result29 = null;;
|
||
};
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result29
|
||
};
|
||
return result29;
|
||
},
|
||
|
||
_parse_prefixed: function(context) {
|
||
var cacheKey = "prefixed" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos7 = this._pos;
|
||
var result44 = this._parse_and(context);
|
||
if (result44 !== null) {
|
||
var result45 = this._parse_suffixed(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(expression) {
|
||
return {
|
||
type: "and_predicate",
|
||
expression: expression
|
||
};
|
||
})(result43[1])
|
||
: null;
|
||
if (result42 !== null) {
|
||
var result36 = result42;
|
||
} else {
|
||
var savedPos6 = this._pos;
|
||
var result40 = this._parse_not(context);
|
||
if (result40 !== null) {
|
||
var result41 = this._parse_suffixed(context);
|
||
if (result41 !== null) {
|
||
var result39 = [result40, result41];
|
||
} else {
|
||
var result39 = null;
|
||
this._pos = savedPos6;
|
||
}
|
||
} else {
|
||
var result39 = null;
|
||
this._pos = savedPos6;
|
||
}
|
||
var result38 = result39 !== null
|
||
? (function(expression) {
|
||
return {
|
||
type: "not_predicate",
|
||
expression: expression
|
||
};
|
||
})(result39[1])
|
||
: null;
|
||
if (result38 !== null) {
|
||
var result36 = result38;
|
||
} else {
|
||
var result37 = this._parse_suffixed(context);
|
||
if (result37 !== null) {
|
||
var result36 = result37;
|
||
} else {
|
||
var result36 = null;;
|
||
};
|
||
};
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result36
|
||
};
|
||
return result36;
|
||
},
|
||
|
||
_parse_suffixed: function(context) {
|
||
var cacheKey = "suffixed" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos10 = this._pos;
|
||
var result58 = this._parse_primary(context);
|
||
if (result58 !== null) {
|
||
var result59 = this._parse_question(context);
|
||
if (result59 !== null) {
|
||
var result57 = [result58, result59];
|
||
} else {
|
||
var result57 = null;
|
||
this._pos = savedPos10;
|
||
}
|
||
} else {
|
||
var result57 = null;
|
||
this._pos = savedPos10;
|
||
}
|
||
var result56 = result57 !== null
|
||
? (function(expression) {
|
||
return {
|
||
type: "optional",
|
||
expression: expression
|
||
};
|
||
})(result57[0])
|
||
: null;
|
||
if (result56 !== null) {
|
||
var result46 = result56;
|
||
} else {
|
||
var savedPos9 = this._pos;
|
||
var result54 = this._parse_primary(context);
|
||
if (result54 !== null) {
|
||
var result55 = this._parse_star(context);
|
||
if (result55 !== null) {
|
||
var result53 = [result54, result55];
|
||
} else {
|
||
var result53 = null;
|
||
this._pos = savedPos9;
|
||
}
|
||
} else {
|
||
var result53 = null;
|
||
this._pos = savedPos9;
|
||
}
|
||
var result52 = result53 !== null
|
||
? (function(expression) {
|
||
return {
|
||
type: "zero_or_more",
|
||
expression: expression
|
||
};
|
||
})(result53[0])
|
||
: null;
|
||
if (result52 !== null) {
|
||
var result46 = result52;
|
||
} else {
|
||
var savedPos8 = this._pos;
|
||
var result50 = this._parse_primary(context);
|
||
if (result50 !== null) {
|
||
var result51 = this._parse_plus(context);
|
||
if (result51 !== null) {
|
||
var result49 = [result50, result51];
|
||
} else {
|
||
var result49 = null;
|
||
this._pos = savedPos8;
|
||
}
|
||
} else {
|
||
var result49 = null;
|
||
this._pos = savedPos8;
|
||
}
|
||
var result48 = result49 !== null
|
||
? (function(expression) {
|
||
return {
|
||
type: "one_or_more",
|
||
expression: expression
|
||
};
|
||
})(result49[0])
|
||
: null;
|
||
if (result48 !== null) {
|
||
var result46 = result48;
|
||
} else {
|
||
var result47 = this._parse_primary(context);
|
||
if (result47 !== null) {
|
||
var result46 = result47;
|
||
} else {
|
||
var result46 = null;;
|
||
};
|
||
};
|
||
};
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result46
|
||
};
|
||
return result46;
|
||
},
|
||
|
||
_parse_primary: function(context) {
|
||
var cacheKey = "primary" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos12 = this._pos;
|
||
var result73 = this._parse_identifier(context);
|
||
if (result73 !== null) {
|
||
var savedPos13 = this._pos;
|
||
var savedReportMatchFailuresVar0 = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
var savedPos14 = this._pos;
|
||
var result79 = this._parse_literal(context);
|
||
if (result79 !== null) {
|
||
var result76 = result79;
|
||
} else {
|
||
if (this._input.substr(this._pos, 0) === "") {
|
||
var result78 = "";
|
||
this._pos += 0;
|
||
} else {
|
||
var result78 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString(""));
|
||
}
|
||
}
|
||
if (result78 !== null) {
|
||
var result76 = result78;
|
||
} else {
|
||
var result76 = null;;
|
||
};
|
||
}
|
||
if (result76 !== null) {
|
||
var result77 = this._parse_equals(context);
|
||
if (result77 !== null) {
|
||
var result75 = [result76, result77];
|
||
} else {
|
||
var result75 = null;
|
||
this._pos = savedPos14;
|
||
}
|
||
} else {
|
||
var result75 = null;
|
||
this._pos = savedPos14;
|
||
}
|
||
context.reportMatchFailures = savedReportMatchFailuresVar0;
|
||
if (result75 === null) {
|
||
var result74 = '';
|
||
} else {
|
||
var result74 = null;
|
||
this._pos = savedPos13;
|
||
}
|
||
if (result74 !== null) {
|
||
var result72 = [result73, result74];
|
||
} else {
|
||
var result72 = null;
|
||
this._pos = savedPos12;
|
||
}
|
||
} else {
|
||
var result72 = null;
|
||
this._pos = savedPos12;
|
||
}
|
||
var result71 = result72 !== null
|
||
? (function(name) {
|
||
return {
|
||
type: "rule_ref",
|
||
name: name
|
||
};
|
||
})(result72[0])
|
||
: null;
|
||
if (result71 !== null) {
|
||
var result60 = result71;
|
||
} else {
|
||
var result70 = this._parse_literal(context);
|
||
var result69 = result70 !== null
|
||
? (function(value) {
|
||
return {
|
||
type: "literal",
|
||
value: value
|
||
};
|
||
})(result70)
|
||
: null;
|
||
if (result69 !== null) {
|
||
var result60 = result69;
|
||
} else {
|
||
var result68 = this._parse_dot(context);
|
||
var result67 = result68 !== null
|
||
? (function() { return { type: "any" }; })()
|
||
: null;
|
||
if (result67 !== null) {
|
||
var result60 = result67;
|
||
} else {
|
||
var result66 = this._parse_class(context);
|
||
if (result66 !== null) {
|
||
var result60 = result66;
|
||
} else {
|
||
var savedPos11 = this._pos;
|
||
var result63 = this._parse_lparen(context);
|
||
if (result63 !== null) {
|
||
var result64 = this._parse_choice(context);
|
||
if (result64 !== null) {
|
||
var result65 = this._parse_rparen(context);
|
||
if (result65 !== null) {
|
||
var result62 = [result63, result64, result65];
|
||
} else {
|
||
var result62 = null;
|
||
this._pos = savedPos11;
|
||
}
|
||
} else {
|
||
var result62 = null;
|
||
this._pos = savedPos11;
|
||
}
|
||
} else {
|
||
var result62 = null;
|
||
this._pos = savedPos11;
|
||
}
|
||
var result61 = result62 !== null
|
||
? (function(expression) { return expression; })(result62[1])
|
||
: null;
|
||
if (result61 !== null) {
|
||
var result60 = result61;
|
||
} else {
|
||
var result60 = null;;
|
||
};
|
||
};
|
||
};
|
||
};
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result60
|
||
};
|
||
return result60;
|
||
},
|
||
|
||
_parse_action: function(context) {
|
||
var cacheKey = "action" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
var savedReportMatchFailures = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
var savedPos15 = this._pos;
|
||
var result82 = this._parse_braced(context);
|
||
if (result82 !== null) {
|
||
var result83 = this._parse___(context);
|
||
if (result83 !== null) {
|
||
var result81 = [result82, result83];
|
||
} else {
|
||
var result81 = null;
|
||
this._pos = savedPos15;
|
||
}
|
||
} else {
|
||
var result81 = null;
|
||
this._pos = savedPos15;
|
||
}
|
||
var result80 = result81 !== null
|
||
? (function(braced) { return braced.substr(1, braced.length - 2); })(result81[0])
|
||
: null;
|
||
context.reportMatchFailures = savedReportMatchFailures;
|
||
if (context.reportMatchFailures && result80 === null) {
|
||
this._matchFailed("action");
|
||
}
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result80
|
||
};
|
||
return result80;
|
||
},
|
||
|
||
_parse_braced: function(context) {
|
||
var cacheKey = "braced" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos16 = this._pos;
|
||
if (this._input.substr(this._pos, 1) === "{") {
|
||
var result86 = "{";
|
||
this._pos += 1;
|
||
} else {
|
||
var result86 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("{"));
|
||
}
|
||
}
|
||
if (result86 !== null) {
|
||
var result87 = [];
|
||
var result91 = this._parse_braced(context);
|
||
if (result91 !== null) {
|
||
var result89 = result91;
|
||
} else {
|
||
var result90 = this._parse_nonBraceCharacter(context);
|
||
if (result90 !== null) {
|
||
var result89 = result90;
|
||
} else {
|
||
var result89 = null;;
|
||
};
|
||
}
|
||
while (result89 !== null) {
|
||
result87.push(result89);
|
||
var result91 = this._parse_braced(context);
|
||
if (result91 !== null) {
|
||
var result89 = result91;
|
||
} else {
|
||
var result90 = this._parse_nonBraceCharacter(context);
|
||
if (result90 !== null) {
|
||
var result89 = result90;
|
||
} else {
|
||
var result89 = null;;
|
||
};
|
||
}
|
||
}
|
||
if (result87 !== null) {
|
||
if (this._input.substr(this._pos, 1) === "}") {
|
||
var result88 = "}";
|
||
this._pos += 1;
|
||
} else {
|
||
var result88 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("}"));
|
||
}
|
||
}
|
||
if (result88 !== null) {
|
||
var result85 = [result86, result87, result88];
|
||
} else {
|
||
var result85 = null;
|
||
this._pos = savedPos16;
|
||
}
|
||
} else {
|
||
var result85 = null;
|
||
this._pos = savedPos16;
|
||
}
|
||
} else {
|
||
var result85 = null;
|
||
this._pos = savedPos16;
|
||
}
|
||
var result84 = result85 !== null
|
||
? (function(parts) {
|
||
return "{" + parts.join("") + "}";
|
||
})(result85[1])
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result84
|
||
};
|
||
return result84;
|
||
},
|
||
|
||
_parse_nonBraceCharacters: function(context) {
|
||
var cacheKey = "nonBraceCharacters" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var result94 = this._parse_nonBraceCharacter(context);
|
||
if (result94 !== null) {
|
||
var result93 = [];
|
||
while (result94 !== null) {
|
||
result93.push(result94);
|
||
var result94 = this._parse_nonBraceCharacter(context);
|
||
}
|
||
} else {
|
||
var result93 = null;
|
||
}
|
||
var result92 = result93 !== null
|
||
? (function(chars) { return chars.join(""); })(result93)
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result92
|
||
};
|
||
return result92;
|
||
},
|
||
|
||
_parse_nonBraceCharacter: function(context) {
|
||
var cacheKey = "nonBraceCharacter" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
if (this._input.substr(this._pos).match(/^[^{}]/) !== null) {
|
||
var result95 = this._input.charAt(this._pos);
|
||
this._pos++;
|
||
} else {
|
||
var result95 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed("[^{}]");
|
||
}
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result95
|
||
};
|
||
return result95;
|
||
},
|
||
|
||
_parse_equals: function(context) {
|
||
var cacheKey = "equals" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
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() { return "="; })()
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result96
|
||
};
|
||
return result96;
|
||
},
|
||
|
||
_parse_colon: function(context) {
|
||
var cacheKey = "colon" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
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() { return ":"; })()
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result100
|
||
};
|
||
return result100;
|
||
},
|
||
|
||
_parse_slash: function(context) {
|
||
var cacheKey = "slash" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
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() { return "/"; })()
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result104
|
||
};
|
||
return result104;
|
||
},
|
||
|
||
_parse_and: function(context) {
|
||
var cacheKey = "and" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
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() { return "&"; })()
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result108
|
||
};
|
||
return result108;
|
||
},
|
||
|
||
_parse_not: function(context) {
|
||
var cacheKey = "not" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
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() { return "!"; })()
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result112
|
||
};
|
||
return result112;
|
||
},
|
||
|
||
_parse_question: function(context) {
|
||
var cacheKey = "question" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
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() { return "?"; })()
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result116
|
||
};
|
||
return result116;
|
||
},
|
||
|
||
_parse_star: function(context) {
|
||
var cacheKey = "star" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
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() { return "*"; })()
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result120
|
||
};
|
||
return result120;
|
||
},
|
||
|
||
_parse_plus: function(context) {
|
||
var cacheKey = "plus" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
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() { return "+"; })()
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result124
|
||
};
|
||
return result124;
|
||
},
|
||
|
||
_parse_lparen: function(context) {
|
||
var cacheKey = "lparen" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
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() { return "("; })()
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result128
|
||
};
|
||
return result128;
|
||
},
|
||
|
||
_parse_rparen: function(context) {
|
||
var cacheKey = "rparen" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos26 = this._pos;
|
||
if (this._input.substr(this._pos, 1) === ")") {
|
||
var result134 = ")";
|
||
this._pos += 1;
|
||
} else {
|
||
var result134 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString(")"));
|
||
}
|
||
}
|
||
if (result134 !== null) {
|
||
var result135 = this._parse___(context);
|
||
if (result135 !== null) {
|
||
var result133 = [result134, result135];
|
||
} else {
|
||
var result133 = null;
|
||
this._pos = savedPos26;
|
||
}
|
||
} else {
|
||
var result133 = null;
|
||
this._pos = savedPos26;
|
||
}
|
||
var result132 = result133 !== null
|
||
? (function() { return ")"; })()
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result132
|
||
};
|
||
return result132;
|
||
},
|
||
|
||
_parse_dot: function(context) {
|
||
var cacheKey = "dot" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos27 = this._pos;
|
||
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 result139 = this._parse___(context);
|
||
if (result139 !== null) {
|
||
var result137 = [result138, result139];
|
||
} else {
|
||
var result137 = null;
|
||
this._pos = savedPos27;
|
||
}
|
||
} else {
|
||
var result137 = null;
|
||
this._pos = savedPos27;
|
||
}
|
||
var result136 = result137 !== null
|
||
? (function() { return "."; })()
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result136
|
||
};
|
||
return result136;
|
||
},
|
||
|
||
_parse_identifier: function(context) {
|
||
var cacheKey = "identifier" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
var savedReportMatchFailures = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
var savedPos28 = this._pos;
|
||
var result152 = this._parse_letter(context);
|
||
if (result152 !== null) {
|
||
var result142 = result152;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "_") {
|
||
var result151 = "_";
|
||
this._pos += 1;
|
||
} else {
|
||
var result151 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("_"));
|
||
}
|
||
}
|
||
if (result151 !== null) {
|
||
var result142 = result151;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "$") {
|
||
var result150 = "$";
|
||
this._pos += 1;
|
||
} else {
|
||
var result150 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("$"));
|
||
}
|
||
}
|
||
if (result150 !== null) {
|
||
var result142 = result150;
|
||
} else {
|
||
var result142 = null;;
|
||
};
|
||
};
|
||
}
|
||
if (result142 !== null) {
|
||
var result143 = [];
|
||
var result149 = this._parse_letter(context);
|
||
if (result149 !== null) {
|
||
var result145 = result149;
|
||
} else {
|
||
var result148 = this._parse_digit(context);
|
||
if (result148 !== null) {
|
||
var result145 = result148;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "_") {
|
||
var result147 = "_";
|
||
this._pos += 1;
|
||
} else {
|
||
var result147 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("_"));
|
||
}
|
||
}
|
||
if (result147 !== null) {
|
||
var result145 = result147;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "$") {
|
||
var result146 = "$";
|
||
this._pos += 1;
|
||
} else {
|
||
var result146 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("$"));
|
||
}
|
||
}
|
||
if (result146 !== null) {
|
||
var result145 = result146;
|
||
} else {
|
||
var result145 = null;;
|
||
};
|
||
};
|
||
};
|
||
}
|
||
while (result145 !== null) {
|
||
result143.push(result145);
|
||
var result149 = this._parse_letter(context);
|
||
if (result149 !== null) {
|
||
var result145 = result149;
|
||
} else {
|
||
var result148 = this._parse_digit(context);
|
||
if (result148 !== null) {
|
||
var result145 = result148;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "_") {
|
||
var result147 = "_";
|
||
this._pos += 1;
|
||
} else {
|
||
var result147 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("_"));
|
||
}
|
||
}
|
||
if (result147 !== null) {
|
||
var result145 = result147;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "$") {
|
||
var result146 = "$";
|
||
this._pos += 1;
|
||
} else {
|
||
var result146 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("$"));
|
||
}
|
||
}
|
||
if (result146 !== null) {
|
||
var result145 = result146;
|
||
} else {
|
||
var result145 = null;;
|
||
};
|
||
};
|
||
};
|
||
}
|
||
}
|
||
if (result143 !== null) {
|
||
var result144 = this._parse___(context);
|
||
if (result144 !== null) {
|
||
var result141 = [result142, result143, result144];
|
||
} else {
|
||
var result141 = null;
|
||
this._pos = savedPos28;
|
||
}
|
||
} else {
|
||
var result141 = null;
|
||
this._pos = savedPos28;
|
||
}
|
||
} else {
|
||
var result141 = null;
|
||
this._pos = savedPos28;
|
||
}
|
||
var result140 = result141 !== null
|
||
? (function(head, tail) {
|
||
return head + tail.join("");
|
||
})(result141[0], result141[1])
|
||
: null;
|
||
context.reportMatchFailures = savedReportMatchFailures;
|
||
if (context.reportMatchFailures && result140 === null) {
|
||
this._matchFailed("identifier");
|
||
}
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result140
|
||
};
|
||
return result140;
|
||
},
|
||
|
||
_parse_literal: function(context) {
|
||
var cacheKey = "literal" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
var savedReportMatchFailures = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
var savedPos29 = this._pos;
|
||
var result158 = this._parse_doubleQuotedLiteral(context);
|
||
if (result158 !== null) {
|
||
var result155 = result158;
|
||
} else {
|
||
var result157 = this._parse_singleQuotedLiteral(context);
|
||
if (result157 !== null) {
|
||
var result155 = result157;
|
||
} else {
|
||
var result155 = null;;
|
||
};
|
||
}
|
||
if (result155 !== null) {
|
||
var result156 = this._parse___(context);
|
||
if (result156 !== null) {
|
||
var result154 = [result155, result156];
|
||
} else {
|
||
var result154 = null;
|
||
this._pos = savedPos29;
|
||
}
|
||
} else {
|
||
var result154 = null;
|
||
this._pos = savedPos29;
|
||
}
|
||
var result153 = result154 !== null
|
||
? (function(literal) { return literal; })(result154[0])
|
||
: null;
|
||
context.reportMatchFailures = savedReportMatchFailures;
|
||
if (context.reportMatchFailures && result153 === null) {
|
||
this._matchFailed("literal");
|
||
}
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result153
|
||
};
|
||
return result153;
|
||
},
|
||
|
||
_parse_doubleQuotedLiteral: function(context) {
|
||
var cacheKey = "doubleQuotedLiteral" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos30 = this._pos;
|
||
if (this._input.substr(this._pos, 1) === "\"") {
|
||
var result161 = "\"";
|
||
this._pos += 1;
|
||
} else {
|
||
var result161 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\""));
|
||
}
|
||
}
|
||
if (result161 !== null) {
|
||
var result162 = [];
|
||
var result164 = this._parse_doubleQuotedCharacter(context);
|
||
while (result164 !== null) {
|
||
result162.push(result164);
|
||
var result164 = this._parse_doubleQuotedCharacter(context);
|
||
}
|
||
if (result162 !== null) {
|
||
if (this._input.substr(this._pos, 1) === "\"") {
|
||
var result163 = "\"";
|
||
this._pos += 1;
|
||
} else {
|
||
var result163 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\""));
|
||
}
|
||
}
|
||
if (result163 !== null) {
|
||
var result160 = [result161, result162, result163];
|
||
} else {
|
||
var result160 = null;
|
||
this._pos = savedPos30;
|
||
}
|
||
} else {
|
||
var result160 = null;
|
||
this._pos = savedPos30;
|
||
}
|
||
} else {
|
||
var result160 = null;
|
||
this._pos = savedPos30;
|
||
}
|
||
var result159 = result160 !== null
|
||
? (function(chars) { return chars.join(""); })(result160[1])
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result159
|
||
};
|
||
return result159;
|
||
},
|
||
|
||
_parse_doubleQuotedCharacter: function(context) {
|
||
var cacheKey = "doubleQuotedCharacter" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var result171 = this._parse_simpleDoubleQuotedCharacter(context);
|
||
if (result171 !== null) {
|
||
var result165 = result171;
|
||
} else {
|
||
var result170 = this._parse_simpleEscapeSequence(context);
|
||
if (result170 !== null) {
|
||
var result165 = result170;
|
||
} else {
|
||
var result169 = this._parse_zeroEscapeSequence(context);
|
||
if (result169 !== null) {
|
||
var result165 = result169;
|
||
} else {
|
||
var result168 = this._parse_hexEscapeSequence(context);
|
||
if (result168 !== null) {
|
||
var result165 = result168;
|
||
} else {
|
||
var result167 = this._parse_unicodeEscapeSequence(context);
|
||
if (result167 !== null) {
|
||
var result165 = result167;
|
||
} else {
|
||
var result166 = this._parse_eolEscapeSequence(context);
|
||
if (result166 !== null) {
|
||
var result165 = result166;
|
||
} else {
|
||
var result165 = null;;
|
||
};
|
||
};
|
||
};
|
||
};
|
||
};
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result165
|
||
};
|
||
return result165;
|
||
},
|
||
|
||
_parse_simpleDoubleQuotedCharacter: function(context) {
|
||
var cacheKey = "simpleDoubleQuotedCharacter" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos31 = this._pos;
|
||
var savedPos32 = this._pos;
|
||
var savedReportMatchFailuresVar1 = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
if (this._input.substr(this._pos, 1) === "\"") {
|
||
var result179 = "\"";
|
||
this._pos += 1;
|
||
} else {
|
||
var result179 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\""));
|
||
}
|
||
}
|
||
if (result179 !== null) {
|
||
var result176 = result179;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "\\") {
|
||
var result178 = "\\";
|
||
this._pos += 1;
|
||
} else {
|
||
var result178 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\\"));
|
||
}
|
||
}
|
||
if (result178 !== null) {
|
||
var result176 = result178;
|
||
} else {
|
||
var result177 = this._parse_eolChar(context);
|
||
if (result177 !== null) {
|
||
var result176 = result177;
|
||
} else {
|
||
var result176 = null;;
|
||
};
|
||
};
|
||
}
|
||
context.reportMatchFailures = savedReportMatchFailuresVar1;
|
||
if (result176 === null) {
|
||
var result174 = '';
|
||
} else {
|
||
var result174 = null;
|
||
this._pos = savedPos32;
|
||
}
|
||
if (result174 !== null) {
|
||
if (this._input.length > this._pos) {
|
||
var result175 = this._input.charAt(this._pos);
|
||
this._pos++;
|
||
} else {
|
||
var result175 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed('any character');
|
||
}
|
||
}
|
||
if (result175 !== null) {
|
||
var result173 = [result174, result175];
|
||
} else {
|
||
var result173 = null;
|
||
this._pos = savedPos31;
|
||
}
|
||
} else {
|
||
var result173 = null;
|
||
this._pos = savedPos31;
|
||
}
|
||
var result172 = result173 !== null
|
||
? (function(char_) { return char_; })(result173[1])
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result172
|
||
};
|
||
return result172;
|
||
},
|
||
|
||
_parse_singleQuotedLiteral: function(context) {
|
||
var cacheKey = "singleQuotedLiteral" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos33 = this._pos;
|
||
if (this._input.substr(this._pos, 1) === "'") {
|
||
var result182 = "'";
|
||
this._pos += 1;
|
||
} else {
|
||
var result182 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("'"));
|
||
}
|
||
}
|
||
if (result182 !== null) {
|
||
var result183 = [];
|
||
var result185 = this._parse_singleQuotedCharacter(context);
|
||
while (result185 !== null) {
|
||
result183.push(result185);
|
||
var result185 = this._parse_singleQuotedCharacter(context);
|
||
}
|
||
if (result183 !== null) {
|
||
if (this._input.substr(this._pos, 1) === "'") {
|
||
var result184 = "'";
|
||
this._pos += 1;
|
||
} else {
|
||
var result184 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("'"));
|
||
}
|
||
}
|
||
if (result184 !== null) {
|
||
var result181 = [result182, result183, result184];
|
||
} else {
|
||
var result181 = null;
|
||
this._pos = savedPos33;
|
||
}
|
||
} else {
|
||
var result181 = null;
|
||
this._pos = savedPos33;
|
||
}
|
||
} else {
|
||
var result181 = null;
|
||
this._pos = savedPos33;
|
||
}
|
||
var result180 = result181 !== null
|
||
? (function(chars) { return chars.join(""); })(result181[1])
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result180
|
||
};
|
||
return result180;
|
||
},
|
||
|
||
_parse_singleQuotedCharacter: function(context) {
|
||
var cacheKey = "singleQuotedCharacter" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var result192 = this._parse_simpleSingleQuotedCharacter(context);
|
||
if (result192 !== null) {
|
||
var result186 = result192;
|
||
} else {
|
||
var result191 = this._parse_simpleEscapeSequence(context);
|
||
if (result191 !== null) {
|
||
var result186 = result191;
|
||
} else {
|
||
var result190 = this._parse_zeroEscapeSequence(context);
|
||
if (result190 !== null) {
|
||
var result186 = result190;
|
||
} else {
|
||
var result189 = this._parse_hexEscapeSequence(context);
|
||
if (result189 !== null) {
|
||
var result186 = result189;
|
||
} else {
|
||
var result188 = this._parse_unicodeEscapeSequence(context);
|
||
if (result188 !== null) {
|
||
var result186 = result188;
|
||
} else {
|
||
var result187 = this._parse_eolEscapeSequence(context);
|
||
if (result187 !== null) {
|
||
var result186 = result187;
|
||
} else {
|
||
var result186 = null;;
|
||
};
|
||
};
|
||
};
|
||
};
|
||
};
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result186
|
||
};
|
||
return result186;
|
||
},
|
||
|
||
_parse_simpleSingleQuotedCharacter: function(context) {
|
||
var cacheKey = "simpleSingleQuotedCharacter" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos34 = this._pos;
|
||
var savedPos35 = this._pos;
|
||
var savedReportMatchFailuresVar2 = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
if (this._input.substr(this._pos, 1) === "'") {
|
||
var result200 = "'";
|
||
this._pos += 1;
|
||
} else {
|
||
var result200 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("'"));
|
||
}
|
||
}
|
||
if (result200 !== null) {
|
||
var result197 = result200;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "\\") {
|
||
var result199 = "\\";
|
||
this._pos += 1;
|
||
} else {
|
||
var result199 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\\"));
|
||
}
|
||
}
|
||
if (result199 !== null) {
|
||
var result197 = result199;
|
||
} else {
|
||
var result198 = this._parse_eolChar(context);
|
||
if (result198 !== null) {
|
||
var result197 = result198;
|
||
} else {
|
||
var result197 = null;;
|
||
};
|
||
};
|
||
}
|
||
context.reportMatchFailures = savedReportMatchFailuresVar2;
|
||
if (result197 === null) {
|
||
var result195 = '';
|
||
} else {
|
||
var result195 = null;
|
||
this._pos = savedPos35;
|
||
}
|
||
if (result195 !== null) {
|
||
if (this._input.length > this._pos) {
|
||
var result196 = this._input.charAt(this._pos);
|
||
this._pos++;
|
||
} else {
|
||
var result196 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed('any character');
|
||
}
|
||
}
|
||
if (result196 !== null) {
|
||
var result194 = [result195, result196];
|
||
} else {
|
||
var result194 = null;
|
||
this._pos = savedPos34;
|
||
}
|
||
} else {
|
||
var result194 = null;
|
||
this._pos = savedPos34;
|
||
}
|
||
var result193 = result194 !== null
|
||
? (function(char_) { return char_; })(result194[1])
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result193
|
||
};
|
||
return result193;
|
||
},
|
||
|
||
_parse_class: function(context) {
|
||
var cacheKey = "class" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
var savedReportMatchFailures = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
var savedPos36 = this._pos;
|
||
if (this._input.substr(this._pos, 1) === "[") {
|
||
var result203 = "[";
|
||
this._pos += 1;
|
||
} else {
|
||
var result203 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("["));
|
||
}
|
||
}
|
||
if (result203 !== null) {
|
||
if (this._input.substr(this._pos, 1) === "^") {
|
||
var result211 = "^";
|
||
this._pos += 1;
|
||
} else {
|
||
var result211 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("^"));
|
||
}
|
||
}
|
||
var result204 = result211 !== null ? result211 : '';
|
||
if (result204 !== null) {
|
||
var result205 = [];
|
||
var result210 = this._parse_classCharacterRange(context);
|
||
if (result210 !== null) {
|
||
var result208 = result210;
|
||
} else {
|
||
var result209 = this._parse_classCharacter(context);
|
||
if (result209 !== null) {
|
||
var result208 = result209;
|
||
} else {
|
||
var result208 = null;;
|
||
};
|
||
}
|
||
while (result208 !== null) {
|
||
result205.push(result208);
|
||
var result210 = this._parse_classCharacterRange(context);
|
||
if (result210 !== null) {
|
||
var result208 = result210;
|
||
} else {
|
||
var result209 = this._parse_classCharacter(context);
|
||
if (result209 !== null) {
|
||
var result208 = result209;
|
||
} else {
|
||
var result208 = null;;
|
||
};
|
||
}
|
||
}
|
||
if (result205 !== null) {
|
||
if (this._input.substr(this._pos, 1) === "]") {
|
||
var result206 = "]";
|
||
this._pos += 1;
|
||
} else {
|
||
var result206 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("]"));
|
||
}
|
||
}
|
||
if (result206 !== null) {
|
||
var result207 = this._parse___(context);
|
||
if (result207 !== null) {
|
||
var result202 = [result203, result204, result205, result206, result207];
|
||
} else {
|
||
var result202 = null;
|
||
this._pos = savedPos36;
|
||
}
|
||
} else {
|
||
var result202 = null;
|
||
this._pos = savedPos36;
|
||
}
|
||
} else {
|
||
var result202 = null;
|
||
this._pos = savedPos36;
|
||
}
|
||
} else {
|
||
var result202 = null;
|
||
this._pos = savedPos36;
|
||
}
|
||
} else {
|
||
var result202 = null;
|
||
this._pos = savedPos36;
|
||
}
|
||
var result201 = result202 !== null
|
||
? (function(inverted, parts) {
|
||
partsConverted = PEG.ArrayUtils.map(parts, function(part) {
|
||
return part.data;
|
||
});
|
||
rawText = "["
|
||
+ inverted
|
||
+ PEG.ArrayUtils.map(parts, function(part) {
|
||
return part.rawText;
|
||
}).join("")
|
||
+ "]";
|
||
|
||
return {
|
||
type: "class",
|
||
inverted: inverted === "^",
|
||
parts: partsConverted,
|
||
// FIXME: Get the raw text from the input directly.
|
||
rawText: rawText
|
||
};
|
||
})(result202[1], result202[2])
|
||
: null;
|
||
context.reportMatchFailures = savedReportMatchFailures;
|
||
if (context.reportMatchFailures && result201 === null) {
|
||
this._matchFailed("character class");
|
||
}
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result201
|
||
};
|
||
return result201;
|
||
},
|
||
|
||
_parse_classCharacterRange: function(context) {
|
||
var cacheKey = "classCharacterRange" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos37 = this._pos;
|
||
var result214 = this._parse_classCharacter(context);
|
||
if (result214 !== null) {
|
||
if (this._input.substr(this._pos, 1) === "-") {
|
||
var result215 = "-";
|
||
this._pos += 1;
|
||
} else {
|
||
var result215 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("-"));
|
||
}
|
||
}
|
||
if (result215 !== null) {
|
||
var result216 = this._parse_classCharacter(context);
|
||
if (result216 !== null) {
|
||
var result213 = [result214, result215, result216];
|
||
} else {
|
||
var result213 = null;
|
||
this._pos = savedPos37;
|
||
}
|
||
} else {
|
||
var result213 = null;
|
||
this._pos = savedPos37;
|
||
}
|
||
} else {
|
||
var result213 = null;
|
||
this._pos = savedPos37;
|
||
}
|
||
var result212 = result213 !== null
|
||
? (function(begin, end) {
|
||
if (begin.data.charCodeAt(0) > end.data.charCodeAt(0)) {
|
||
throw new this.SyntaxError(
|
||
"Invalid character range: " + begin.rawText + "-" + end.rawText + "."
|
||
);
|
||
}
|
||
|
||
return {
|
||
data: [begin.data, end.data],
|
||
// FIXME: Get the raw text from the input directly.
|
||
rawText: begin.rawText + "-" + end.rawText
|
||
}
|
||
})(result213[0], result213[2])
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result212
|
||
};
|
||
return result212;
|
||
},
|
||
|
||
_parse_classCharacter: function(context) {
|
||
var cacheKey = "classCharacter" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var result218 = this._parse_bracketDelimitedCharacter(context);
|
||
var result217 = result218 !== null
|
||
? (function(char_) {
|
||
return {
|
||
data: char_,
|
||
// FIXME: Get the raw text from the input directly.
|
||
rawText: PEG.RegExpUtils.quoteForClass(char_)
|
||
};
|
||
})(result218)
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result217
|
||
};
|
||
return result217;
|
||
},
|
||
|
||
_parse_bracketDelimitedCharacter: function(context) {
|
||
var cacheKey = "bracketDelimitedCharacter" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var result225 = this._parse_simpleBracketDelimitedCharacter(context);
|
||
if (result225 !== null) {
|
||
var result219 = result225;
|
||
} else {
|
||
var result224 = this._parse_simpleEscapeSequence(context);
|
||
if (result224 !== null) {
|
||
var result219 = result224;
|
||
} else {
|
||
var result223 = this._parse_zeroEscapeSequence(context);
|
||
if (result223 !== null) {
|
||
var result219 = result223;
|
||
} else {
|
||
var result222 = this._parse_hexEscapeSequence(context);
|
||
if (result222 !== null) {
|
||
var result219 = result222;
|
||
} else {
|
||
var result221 = this._parse_unicodeEscapeSequence(context);
|
||
if (result221 !== null) {
|
||
var result219 = result221;
|
||
} else {
|
||
var result220 = this._parse_eolEscapeSequence(context);
|
||
if (result220 !== null) {
|
||
var result219 = result220;
|
||
} else {
|
||
var result219 = null;;
|
||
};
|
||
};
|
||
};
|
||
};
|
||
};
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result219
|
||
};
|
||
return result219;
|
||
},
|
||
|
||
_parse_simpleBracketDelimitedCharacter: function(context) {
|
||
var cacheKey = "simpleBracketDelimitedCharacter" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos38 = this._pos;
|
||
var savedPos39 = this._pos;
|
||
var savedReportMatchFailuresVar3 = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
if (this._input.substr(this._pos, 1) === "]") {
|
||
var result233 = "]";
|
||
this._pos += 1;
|
||
} else {
|
||
var result233 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("]"));
|
||
}
|
||
}
|
||
if (result233 !== null) {
|
||
var result230 = result233;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "\\") {
|
||
var result232 = "\\";
|
||
this._pos += 1;
|
||
} else {
|
||
var result232 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\\"));
|
||
}
|
||
}
|
||
if (result232 !== null) {
|
||
var result230 = result232;
|
||
} else {
|
||
var result231 = this._parse_eolChar(context);
|
||
if (result231 !== null) {
|
||
var result230 = result231;
|
||
} else {
|
||
var result230 = null;;
|
||
};
|
||
};
|
||
}
|
||
context.reportMatchFailures = savedReportMatchFailuresVar3;
|
||
if (result230 === null) {
|
||
var result228 = '';
|
||
} else {
|
||
var result228 = null;
|
||
this._pos = savedPos39;
|
||
}
|
||
if (result228 !== null) {
|
||
if (this._input.length > this._pos) {
|
||
var result229 = this._input.charAt(this._pos);
|
||
this._pos++;
|
||
} else {
|
||
var result229 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed('any character');
|
||
}
|
||
}
|
||
if (result229 !== null) {
|
||
var result227 = [result228, result229];
|
||
} else {
|
||
var result227 = null;
|
||
this._pos = savedPos38;
|
||
}
|
||
} else {
|
||
var result227 = null;
|
||
this._pos = savedPos38;
|
||
}
|
||
var result226 = result227 !== null
|
||
? (function(char_) { return char_; })(result227[1])
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result226
|
||
};
|
||
return result226;
|
||
},
|
||
|
||
_parse_simpleEscapeSequence: function(context) {
|
||
var cacheKey = "simpleEscapeSequence" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos40 = this._pos;
|
||
if (this._input.substr(this._pos, 1) === "\\") {
|
||
var result236 = "\\";
|
||
this._pos += 1;
|
||
} else {
|
||
var result236 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\\"));
|
||
}
|
||
}
|
||
if (result236 !== null) {
|
||
var savedPos41 = this._pos;
|
||
var savedReportMatchFailuresVar4 = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
var result243 = this._parse_digit(context);
|
||
if (result243 !== null) {
|
||
var result239 = result243;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "x") {
|
||
var result242 = "x";
|
||
this._pos += 1;
|
||
} else {
|
||
var result242 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("x"));
|
||
}
|
||
}
|
||
if (result242 !== null) {
|
||
var result239 = result242;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "u") {
|
||
var result241 = "u";
|
||
this._pos += 1;
|
||
} else {
|
||
var result241 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("u"));
|
||
}
|
||
}
|
||
if (result241 !== null) {
|
||
var result239 = result241;
|
||
} else {
|
||
var result240 = this._parse_eolChar(context);
|
||
if (result240 !== null) {
|
||
var result239 = result240;
|
||
} else {
|
||
var result239 = null;;
|
||
};
|
||
};
|
||
};
|
||
}
|
||
context.reportMatchFailures = savedReportMatchFailuresVar4;
|
||
if (result239 === null) {
|
||
var result237 = '';
|
||
} else {
|
||
var result237 = null;
|
||
this._pos = savedPos41;
|
||
}
|
||
if (result237 !== null) {
|
||
if (this._input.length > this._pos) {
|
||
var result238 = this._input.charAt(this._pos);
|
||
this._pos++;
|
||
} else {
|
||
var result238 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed('any character');
|
||
}
|
||
}
|
||
if (result238 !== null) {
|
||
var result235 = [result236, result237, result238];
|
||
} else {
|
||
var result235 = null;
|
||
this._pos = savedPos40;
|
||
}
|
||
} else {
|
||
var result235 = null;
|
||
this._pos = savedPos40;
|
||
}
|
||
} else {
|
||
var result235 = null;
|
||
this._pos = savedPos40;
|
||
}
|
||
var result234 = result235 !== null
|
||
? (function(char_) {
|
||
return char_
|
||
.replace("b", "\b")
|
||
.replace("f", "\f")
|
||
.replace("n", "\n")
|
||
.replace("r", "\r")
|
||
.replace("t", "\t")
|
||
.replace("v", "\x0B") // IE does not recognize "\v".
|
||
})(result235[2])
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result234
|
||
};
|
||
return result234;
|
||
},
|
||
|
||
_parse_zeroEscapeSequence: function(context) {
|
||
var cacheKey = "zeroEscapeSequence" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos42 = this._pos;
|
||
if (this._input.substr(this._pos, 2) === "\\0") {
|
||
var result246 = "\\0";
|
||
this._pos += 2;
|
||
} else {
|
||
var result246 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\\0"));
|
||
}
|
||
}
|
||
if (result246 !== null) {
|
||
var savedPos43 = this._pos;
|
||
var savedReportMatchFailuresVar5 = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
var result248 = this._parse_digit(context);
|
||
context.reportMatchFailures = savedReportMatchFailuresVar5;
|
||
if (result248 === null) {
|
||
var result247 = '';
|
||
} else {
|
||
var result247 = null;
|
||
this._pos = savedPos43;
|
||
}
|
||
if (result247 !== null) {
|
||
var result245 = [result246, result247];
|
||
} else {
|
||
var result245 = null;
|
||
this._pos = savedPos42;
|
||
}
|
||
} else {
|
||
var result245 = null;
|
||
this._pos = savedPos42;
|
||
}
|
||
var result244 = result245 !== null
|
||
? (function() { return "\0"; })()
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result244
|
||
};
|
||
return result244;
|
||
},
|
||
|
||
_parse_hexEscapeSequence: function(context) {
|
||
var cacheKey = "hexEscapeSequence" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos44 = this._pos;
|
||
if (this._input.substr(this._pos, 2) === "\\x") {
|
||
var result251 = "\\x";
|
||
this._pos += 2;
|
||
} else {
|
||
var result251 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\\x"));
|
||
}
|
||
}
|
||
if (result251 !== null) {
|
||
var result252 = this._parse_hexDigit(context);
|
||
if (result252 !== null) {
|
||
var result253 = this._parse_hexDigit(context);
|
||
if (result253 !== null) {
|
||
var result250 = [result251, result252, result253];
|
||
} else {
|
||
var result250 = null;
|
||
this._pos = savedPos44;
|
||
}
|
||
} else {
|
||
var result250 = null;
|
||
this._pos = savedPos44;
|
||
}
|
||
} else {
|
||
var result250 = null;
|
||
this._pos = savedPos44;
|
||
}
|
||
var result249 = result250 !== null
|
||
? (function(h1, h2) {
|
||
return String.fromCharCode(parseInt("0x" + h1 + h2));
|
||
})(result250[1], result250[2])
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result249
|
||
};
|
||
return result249;
|
||
},
|
||
|
||
_parse_unicodeEscapeSequence: function(context) {
|
||
var cacheKey = "unicodeEscapeSequence" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos45 = this._pos;
|
||
if (this._input.substr(this._pos, 2) === "\\u") {
|
||
var result256 = "\\u";
|
||
this._pos += 2;
|
||
} else {
|
||
var result256 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\\u"));
|
||
}
|
||
}
|
||
if (result256 !== null) {
|
||
var result257 = this._parse_hexDigit(context);
|
||
if (result257 !== null) {
|
||
var result258 = this._parse_hexDigit(context);
|
||
if (result258 !== null) {
|
||
var result259 = this._parse_hexDigit(context);
|
||
if (result259 !== null) {
|
||
var result260 = this._parse_hexDigit(context);
|
||
if (result260 !== null) {
|
||
var result255 = [result256, result257, result258, result259, result260];
|
||
} else {
|
||
var result255 = null;
|
||
this._pos = savedPos45;
|
||
}
|
||
} else {
|
||
var result255 = null;
|
||
this._pos = savedPos45;
|
||
}
|
||
} else {
|
||
var result255 = null;
|
||
this._pos = savedPos45;
|
||
}
|
||
} else {
|
||
var result255 = null;
|
||
this._pos = savedPos45;
|
||
}
|
||
} else {
|
||
var result255 = null;
|
||
this._pos = savedPos45;
|
||
}
|
||
var result254 = result255 !== null
|
||
? (function(h1, h2, h3, h4) {
|
||
return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4));
|
||
})(result255[1], result255[2], result255[3], result255[4])
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result254
|
||
};
|
||
return result254;
|
||
},
|
||
|
||
_parse_eolEscapeSequence: function(context) {
|
||
var cacheKey = "eolEscapeSequence" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos46 = this._pos;
|
||
if (this._input.substr(this._pos, 1) === "\\") {
|
||
var result263 = "\\";
|
||
this._pos += 1;
|
||
} else {
|
||
var result263 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\\"));
|
||
}
|
||
}
|
||
if (result263 !== null) {
|
||
var result264 = this._parse_eol(context);
|
||
if (result264 !== null) {
|
||
var result262 = [result263, result264];
|
||
} else {
|
||
var result262 = null;
|
||
this._pos = savedPos46;
|
||
}
|
||
} else {
|
||
var result262 = null;
|
||
this._pos = savedPos46;
|
||
}
|
||
var result261 = result262 !== null
|
||
? (function(eol) { return eol; })(result262[1])
|
||
: null;
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result261
|
||
};
|
||
return result261;
|
||
},
|
||
|
||
_parse_digit: function(context) {
|
||
var cacheKey = "digit" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
if (this._input.substr(this._pos).match(/^[0-9]/) !== null) {
|
||
var result265 = this._input.charAt(this._pos);
|
||
this._pos++;
|
||
} else {
|
||
var result265 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed("[0-9]");
|
||
}
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result265
|
||
};
|
||
return result265;
|
||
},
|
||
|
||
_parse_hexDigit: function(context) {
|
||
var cacheKey = "hexDigit" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
if (this._input.substr(this._pos).match(/^[0-9a-fA-F]/) !== null) {
|
||
var result266 = this._input.charAt(this._pos);
|
||
this._pos++;
|
||
} else {
|
||
var result266 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed("[0-9a-fA-F]");
|
||
}
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result266
|
||
};
|
||
return result266;
|
||
},
|
||
|
||
_parse_letter: function(context) {
|
||
var cacheKey = "letter" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var result269 = this._parse_lowerCaseLetter(context);
|
||
if (result269 !== null) {
|
||
var result267 = result269;
|
||
} else {
|
||
var result268 = this._parse_upperCaseLetter(context);
|
||
if (result268 !== null) {
|
||
var result267 = result268;
|
||
} else {
|
||
var result267 = null;;
|
||
};
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result267
|
||
};
|
||
return result267;
|
||
},
|
||
|
||
_parse_lowerCaseLetter: function(context) {
|
||
var cacheKey = "lowerCaseLetter" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
if (this._input.substr(this._pos).match(/^[a-z]/) !== null) {
|
||
var result270 = this._input.charAt(this._pos);
|
||
this._pos++;
|
||
} else {
|
||
var result270 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed("[a-z]");
|
||
}
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result270
|
||
};
|
||
return result270;
|
||
},
|
||
|
||
_parse_upperCaseLetter: function(context) {
|
||
var cacheKey = "upperCaseLetter" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
if (this._input.substr(this._pos).match(/^[A-Z]/) !== null) {
|
||
var result271 = this._input.charAt(this._pos);
|
||
this._pos++;
|
||
} else {
|
||
var result271 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed("[A-Z]");
|
||
}
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result271
|
||
};
|
||
return result271;
|
||
},
|
||
|
||
_parse___: function(context) {
|
||
var cacheKey = "__" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var result272 = [];
|
||
var result276 = this._parse_whitespace(context);
|
||
if (result276 !== null) {
|
||
var result273 = result276;
|
||
} else {
|
||
var result275 = this._parse_eol(context);
|
||
if (result275 !== null) {
|
||
var result273 = result275;
|
||
} else {
|
||
var result274 = this._parse_comment(context);
|
||
if (result274 !== null) {
|
||
var result273 = result274;
|
||
} else {
|
||
var result273 = null;;
|
||
};
|
||
};
|
||
}
|
||
while (result273 !== null) {
|
||
result272.push(result273);
|
||
var result276 = this._parse_whitespace(context);
|
||
if (result276 !== null) {
|
||
var result273 = result276;
|
||
} else {
|
||
var result275 = this._parse_eol(context);
|
||
if (result275 !== null) {
|
||
var result273 = result275;
|
||
} else {
|
||
var result274 = this._parse_comment(context);
|
||
if (result274 !== null) {
|
||
var result273 = result274;
|
||
} else {
|
||
var result273 = null;;
|
||
};
|
||
};
|
||
}
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result272
|
||
};
|
||
return result272;
|
||
},
|
||
|
||
_parse_comment: function(context) {
|
||
var cacheKey = "comment" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
var savedReportMatchFailures = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
var result279 = this._parse_singleLineComment(context);
|
||
if (result279 !== null) {
|
||
var result277 = result279;
|
||
} else {
|
||
var result278 = this._parse_multiLineComment(context);
|
||
if (result278 !== null) {
|
||
var result277 = result278;
|
||
} else {
|
||
var result277 = null;;
|
||
};
|
||
}
|
||
context.reportMatchFailures = savedReportMatchFailures;
|
||
if (context.reportMatchFailures && result277 === null) {
|
||
this._matchFailed("comment");
|
||
}
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result277
|
||
};
|
||
return result277;
|
||
},
|
||
|
||
_parse_singleLineComment: function(context) {
|
||
var cacheKey = "singleLineComment" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos47 = this._pos;
|
||
if (this._input.substr(this._pos, 2) === "//") {
|
||
var result281 = "//";
|
||
this._pos += 2;
|
||
} else {
|
||
var result281 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("//"));
|
||
}
|
||
}
|
||
if (result281 !== null) {
|
||
var result282 = [];
|
||
var savedPos48 = this._pos;
|
||
var savedPos49 = this._pos;
|
||
var savedReportMatchFailuresVar6 = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
var result286 = this._parse_eolChar(context);
|
||
context.reportMatchFailures = savedReportMatchFailuresVar6;
|
||
if (result286 === null) {
|
||
var result284 = '';
|
||
} else {
|
||
var result284 = null;
|
||
this._pos = savedPos49;
|
||
}
|
||
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 = savedPos48;
|
||
}
|
||
} else {
|
||
var result283 = null;
|
||
this._pos = savedPos48;
|
||
}
|
||
while (result283 !== null) {
|
||
result282.push(result283);
|
||
var savedPos48 = this._pos;
|
||
var savedPos49 = this._pos;
|
||
var savedReportMatchFailuresVar6 = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
var result286 = this._parse_eolChar(context);
|
||
context.reportMatchFailures = savedReportMatchFailuresVar6;
|
||
if (result286 === null) {
|
||
var result284 = '';
|
||
} else {
|
||
var result284 = null;
|
||
this._pos = savedPos49;
|
||
}
|
||
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 = savedPos48;
|
||
}
|
||
} else {
|
||
var result283 = null;
|
||
this._pos = savedPos48;
|
||
}
|
||
}
|
||
if (result282 !== null) {
|
||
var result280 = [result281, result282];
|
||
} else {
|
||
var result280 = null;
|
||
this._pos = savedPos47;
|
||
}
|
||
} else {
|
||
var result280 = null;
|
||
this._pos = savedPos47;
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result280
|
||
};
|
||
return result280;
|
||
},
|
||
|
||
_parse_multiLineComment: function(context) {
|
||
var cacheKey = "multiLineComment" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
var savedPos50 = this._pos;
|
||
if (this._input.substr(this._pos, 2) === "/*") {
|
||
var result288 = "/*";
|
||
this._pos += 2;
|
||
} else {
|
||
var result288 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("/*"));
|
||
}
|
||
}
|
||
if (result288 !== null) {
|
||
var result289 = [];
|
||
var savedPos51 = this._pos;
|
||
var savedPos52 = this._pos;
|
||
var savedReportMatchFailuresVar7 = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
if (this._input.substr(this._pos, 2) === "*/") {
|
||
var result294 = "*/";
|
||
this._pos += 2;
|
||
} else {
|
||
var result294 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("*/"));
|
||
}
|
||
}
|
||
context.reportMatchFailures = savedReportMatchFailuresVar7;
|
||
if (result294 === null) {
|
||
var result292 = '';
|
||
} else {
|
||
var result292 = null;
|
||
this._pos = savedPos52;
|
||
}
|
||
if (result292 !== null) {
|
||
if (this._input.length > this._pos) {
|
||
var result293 = this._input.charAt(this._pos);
|
||
this._pos++;
|
||
} else {
|
||
var result293 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed('any character');
|
||
}
|
||
}
|
||
if (result293 !== null) {
|
||
var result291 = [result292, result293];
|
||
} else {
|
||
var result291 = null;
|
||
this._pos = savedPos51;
|
||
}
|
||
} else {
|
||
var result291 = null;
|
||
this._pos = savedPos51;
|
||
}
|
||
while (result291 !== null) {
|
||
result289.push(result291);
|
||
var savedPos51 = this._pos;
|
||
var savedPos52 = this._pos;
|
||
var savedReportMatchFailuresVar7 = context.reportMatchFailures;
|
||
context.reportMatchFailures = false;
|
||
if (this._input.substr(this._pos, 2) === "*/") {
|
||
var result294 = "*/";
|
||
this._pos += 2;
|
||
} else {
|
||
var result294 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("*/"));
|
||
}
|
||
}
|
||
context.reportMatchFailures = savedReportMatchFailuresVar7;
|
||
if (result294 === null) {
|
||
var result292 = '';
|
||
} else {
|
||
var result292 = null;
|
||
this._pos = savedPos52;
|
||
}
|
||
if (result292 !== null) {
|
||
if (this._input.length > this._pos) {
|
||
var result293 = this._input.charAt(this._pos);
|
||
this._pos++;
|
||
} else {
|
||
var result293 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed('any character');
|
||
}
|
||
}
|
||
if (result293 !== null) {
|
||
var result291 = [result292, result293];
|
||
} else {
|
||
var result291 = null;
|
||
this._pos = savedPos51;
|
||
}
|
||
} else {
|
||
var result291 = null;
|
||
this._pos = savedPos51;
|
||
}
|
||
}
|
||
if (result289 !== null) {
|
||
if (this._input.substr(this._pos, 2) === "*/") {
|
||
var result290 = "*/";
|
||
this._pos += 2;
|
||
} else {
|
||
var result290 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("*/"));
|
||
}
|
||
}
|
||
if (result290 !== null) {
|
||
var result287 = [result288, result289, result290];
|
||
} else {
|
||
var result287 = null;
|
||
this._pos = savedPos50;
|
||
}
|
||
} else {
|
||
var result287 = null;
|
||
this._pos = savedPos50;
|
||
}
|
||
} else {
|
||
var result287 = null;
|
||
this._pos = savedPos50;
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result287
|
||
};
|
||
return result287;
|
||
},
|
||
|
||
_parse_eol: function(context) {
|
||
var cacheKey = "eol" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
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 result300 = "\n";
|
||
this._pos += 1;
|
||
} else {
|
||
var result300 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\n"));
|
||
}
|
||
}
|
||
if (result300 !== null) {
|
||
var result295 = result300;
|
||
} else {
|
||
if (this._input.substr(this._pos, 2) === "\r\n") {
|
||
var result299 = "\r\n";
|
||
this._pos += 2;
|
||
} else {
|
||
var result299 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\r\n"));
|
||
}
|
||
}
|
||
if (result299 !== null) {
|
||
var result295 = result299;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "\r") {
|
||
var result298 = "\r";
|
||
this._pos += 1;
|
||
} else {
|
||
var result298 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\r"));
|
||
}
|
||
}
|
||
if (result298 !== null) {
|
||
var result295 = result298;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "\u2028") {
|
||
var result297 = "\u2028";
|
||
this._pos += 1;
|
||
} else {
|
||
var result297 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\u2028"));
|
||
}
|
||
}
|
||
if (result297 !== null) {
|
||
var result295 = result297;
|
||
} else {
|
||
if (this._input.substr(this._pos, 1) === "\u2029") {
|
||
var result296 = "\u2029";
|
||
this._pos += 1;
|
||
} else {
|
||
var result296 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed(this._quoteString("\u2029"));
|
||
}
|
||
}
|
||
if (result296 !== null) {
|
||
var result295 = result296;
|
||
} else {
|
||
var result295 = null;;
|
||
};
|
||
};
|
||
};
|
||
};
|
||
}
|
||
context.reportMatchFailures = savedReportMatchFailures;
|
||
if (context.reportMatchFailures && result295 === null) {
|
||
this._matchFailed("end of line");
|
||
}
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result295
|
||
};
|
||
return result295;
|
||
},
|
||
|
||
_parse_eolChar: function(context) {
|
||
var cacheKey = "eolChar" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
this._pos = cachedResult.nextPos;
|
||
return cachedResult.result;
|
||
}
|
||
|
||
var pos = this._pos;
|
||
|
||
|
||
if (this._input.substr(this._pos).match(/^[\n\r\u2028\u2029]/) !== null) {
|
||
var result301 = this._input.charAt(this._pos);
|
||
this._pos++;
|
||
} else {
|
||
var result301 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed("[\\n\\r\\u2028\\u2029]");
|
||
}
|
||
}
|
||
|
||
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result301
|
||
};
|
||
return result301;
|
||
},
|
||
|
||
_parse_whitespace: function(context) {
|
||
var cacheKey = "whitespace" + '@' + this._pos;
|
||
var cachedResult = this._cache[cacheKey];
|
||
if (cachedResult) {
|
||
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 result302 = this._input.charAt(this._pos);
|
||
this._pos++;
|
||
} else {
|
||
var result302 = null;
|
||
if (context.reportMatchFailures) {
|
||
this._matchFailed("[ - ]");
|
||
}
|
||
}
|
||
context.reportMatchFailures = savedReportMatchFailures;
|
||
if (context.reportMatchFailures && result302 === null) {
|
||
this._matchFailed("whitespace");
|
||
}
|
||
|
||
this._cache[cacheKey] = {
|
||
nextPos: this._pos,
|
||
result: result302
|
||
};
|
||
return result302;
|
||
},
|
||
|
||
/*
|
||
* 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;
|
||
})();
|