|
|
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($1, $2) {
|
|
|
var result = {};
|
|
|
PEG.ArrayUtils.each($2, function(rule) { result[rule.name] = 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) {
|
|
|
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_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($1, $2, $3, $4) {
|
|
|
return {
|
|
|
type: "rule",
|
|
|
name: $1,
|
|
|
displayName: $2 !== "" ? $2 : null,
|
|
|
expression: $4
|
|
|
};
|
|
|
}).apply(null, result6)
|
|
|
: 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($1, $2) {
|
|
|
if ($2.length > 0) {
|
|
|
var alternatives = [$1].concat(PEG.ArrayUtils.map(
|
|
|
$2,
|
|
|
function(element) { return element[1]; }
|
|
|
));
|
|
|
return {
|
|
|
type: "choice",
|
|
|
alternatives: alternatives
|
|
|
}
|
|
|
} else {
|
|
|
return $1;
|
|
|
}
|
|
|
}).apply(null, result14)
|
|
|
: 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_prefixed(context);
|
|
|
while (result28 !== null) {
|
|
|
result26.push(result28);
|
|
|
var result28 = this._parse_prefixed(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($1, $2) {
|
|
|
var expression = $1.length != 1
|
|
|
? {
|
|
|
type: "sequence",
|
|
|
elements: $1
|
|
|
}
|
|
|
: $1[0];
|
|
|
return {
|
|
|
type: "action",
|
|
|
expression: expression,
|
|
|
action: $2
|
|
|
};
|
|
|
}).apply(null, result25)
|
|
|
: null;
|
|
|
if (result24 !== null) {
|
|
|
var result20 = result24;
|
|
|
} else {
|
|
|
var result22 = [];
|
|
|
var result23 = this._parse_prefixed(context);
|
|
|
while (result23 !== null) {
|
|
|
result22.push(result23);
|
|
|
var result23 = this._parse_prefixed(context);
|
|
|
}
|
|
|
var result21 = result22 !== null
|
|
|
? (function($1) {
|
|
|
return $1.length != 1
|
|
|
? {
|
|
|
type: "sequence",
|
|
|
elements: $1
|
|
|
}
|
|
|
: $1[0];
|
|
|
})(result22)
|
|
|
: null;
|
|
|
if (result21 !== null) {
|
|
|
var result20 = result21;
|
|
|
} else {
|
|
|
var result20 = null;;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result20
|
|
|
};
|
|
|
return result20;
|
|
|
},
|
|
|
|
|
|
_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 savedPos6 = this._pos;
|
|
|
var result37 = this._parse_and(context);
|
|
|
if (result37 !== null) {
|
|
|
var result38 = this._parse_suffixed(context);
|
|
|
if (result38 !== null) {
|
|
|
var result36 = [result37, result38];
|
|
|
} else {
|
|
|
var result36 = null;
|
|
|
this._pos = savedPos6;
|
|
|
}
|
|
|
} else {
|
|
|
var result36 = null;
|
|
|
this._pos = savedPos6;
|
|
|
}
|
|
|
var result35 = result36 !== null
|
|
|
? (function($1, $2) { return { type: "and_predicate", expression: $2 }; }).apply(null, result36)
|
|
|
: null;
|
|
|
if (result35 !== null) {
|
|
|
var result29 = result35;
|
|
|
} else {
|
|
|
var savedPos5 = this._pos;
|
|
|
var result33 = this._parse_not(context);
|
|
|
if (result33 !== null) {
|
|
|
var result34 = this._parse_suffixed(context);
|
|
|
if (result34 !== null) {
|
|
|
var result32 = [result33, result34];
|
|
|
} else {
|
|
|
var result32 = null;
|
|
|
this._pos = savedPos5;
|
|
|
}
|
|
|
} else {
|
|
|
var result32 = null;
|
|
|
this._pos = savedPos5;
|
|
|
}
|
|
|
var result31 = result32 !== null
|
|
|
? (function($1, $2) { return { type: "not_predicate", expression: $2 }; }).apply(null, result32)
|
|
|
: null;
|
|
|
if (result31 !== null) {
|
|
|
var result29 = result31;
|
|
|
} else {
|
|
|
var result30 = this._parse_suffixed(context);
|
|
|
if (result30 !== null) {
|
|
|
var result29 = result30;
|
|
|
} else {
|
|
|
var result29 = null;;
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result29
|
|
|
};
|
|
|
return result29;
|
|
|
},
|
|
|
|
|
|
_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 savedPos9 = this._pos;
|
|
|
var result51 = this._parse_primary(context);
|
|
|
if (result51 !== null) {
|
|
|
var result52 = this._parse_question(context);
|
|
|
if (result52 !== null) {
|
|
|
var result50 = [result51, result52];
|
|
|
} else {
|
|
|
var result50 = null;
|
|
|
this._pos = savedPos9;
|
|
|
}
|
|
|
} else {
|
|
|
var result50 = null;
|
|
|
this._pos = savedPos9;
|
|
|
}
|
|
|
var result49 = result50 !== null
|
|
|
? (function($1, $2) { return { type: "optional", expression: $1}; }).apply(null, result50)
|
|
|
: null;
|
|
|
if (result49 !== null) {
|
|
|
var result39 = result49;
|
|
|
} else {
|
|
|
var savedPos8 = this._pos;
|
|
|
var result47 = this._parse_primary(context);
|
|
|
if (result47 !== null) {
|
|
|
var result48 = this._parse_star(context);
|
|
|
if (result48 !== null) {
|
|
|
var result46 = [result47, result48];
|
|
|
} else {
|
|
|
var result46 = null;
|
|
|
this._pos = savedPos8;
|
|
|
}
|
|
|
} else {
|
|
|
var result46 = null;
|
|
|
this._pos = savedPos8;
|
|
|
}
|
|
|
var result45 = result46 !== null
|
|
|
? (function($1, $2) { return { type: "zero_or_more", expression: $1}; }).apply(null, result46)
|
|
|
: null;
|
|
|
if (result45 !== null) {
|
|
|
var result39 = result45;
|
|
|
} else {
|
|
|
var savedPos7 = this._pos;
|
|
|
var result43 = this._parse_primary(context);
|
|
|
if (result43 !== null) {
|
|
|
var result44 = this._parse_plus(context);
|
|
|
if (result44 !== null) {
|
|
|
var result42 = [result43, result44];
|
|
|
} else {
|
|
|
var result42 = null;
|
|
|
this._pos = savedPos7;
|
|
|
}
|
|
|
} else {
|
|
|
var result42 = null;
|
|
|
this._pos = savedPos7;
|
|
|
}
|
|
|
var result41 = result42 !== null
|
|
|
? (function($1, $2) { return { type: "one_or_more", expression: $1}; }).apply(null, result42)
|
|
|
: null;
|
|
|
if (result41 !== null) {
|
|
|
var result39 = result41;
|
|
|
} else {
|
|
|
var result40 = this._parse_primary(context);
|
|
|
if (result40 !== null) {
|
|
|
var result39 = result40;
|
|
|
} else {
|
|
|
var result39 = null;;
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result39
|
|
|
};
|
|
|
return result39;
|
|
|
},
|
|
|
|
|
|
_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 savedPos11 = this._pos;
|
|
|
var result66 = this._parse_identifier(context);
|
|
|
if (result66 !== null) {
|
|
|
var savedPos12 = this._pos;
|
|
|
var savedReportMatchFailuresVar0 = context.reportMatchFailures;
|
|
|
context.reportMatchFailures = false;
|
|
|
var savedPos13 = this._pos;
|
|
|
var result72 = this._parse_literal(context);
|
|
|
if (result72 !== null) {
|
|
|
var result69 = result72;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 0) === "") {
|
|
|
var result71 = "";
|
|
|
this._pos += 0;
|
|
|
} else {
|
|
|
var result71 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString(""));
|
|
|
}
|
|
|
}
|
|
|
if (result71 !== null) {
|
|
|
var result69 = result71;
|
|
|
} else {
|
|
|
var result69 = null;;
|
|
|
};
|
|
|
}
|
|
|
if (result69 !== null) {
|
|
|
var result70 = this._parse_colon(context);
|
|
|
if (result70 !== null) {
|
|
|
var result68 = [result69, result70];
|
|
|
} else {
|
|
|
var result68 = null;
|
|
|
this._pos = savedPos13;
|
|
|
}
|
|
|
} else {
|
|
|
var result68 = null;
|
|
|
this._pos = savedPos13;
|
|
|
}
|
|
|
context.reportMatchFailures = savedReportMatchFailuresVar0;
|
|
|
if (result68 === null) {
|
|
|
var result67 = '';
|
|
|
} else {
|
|
|
var result67 = null;
|
|
|
this._pos = savedPos12;
|
|
|
}
|
|
|
if (result67 !== null) {
|
|
|
var result65 = [result66, result67];
|
|
|
} else {
|
|
|
var result65 = null;
|
|
|
this._pos = savedPos11;
|
|
|
}
|
|
|
} else {
|
|
|
var result65 = null;
|
|
|
this._pos = savedPos11;
|
|
|
}
|
|
|
var result64 = result65 !== null
|
|
|
? (function($1, $2) { return { type: "rule_ref", name: $1 }; }).apply(null, result65)
|
|
|
: null;
|
|
|
if (result64 !== null) {
|
|
|
var result53 = result64;
|
|
|
} else {
|
|
|
var result63 = this._parse_literal(context);
|
|
|
var result62 = result63 !== null
|
|
|
? (function($1) { return { type: "literal", value: $1 }; })(result63)
|
|
|
: null;
|
|
|
if (result62 !== null) {
|
|
|
var result53 = result62;
|
|
|
} else {
|
|
|
var result61 = this._parse_dot(context);
|
|
|
var result60 = result61 !== null
|
|
|
? (function($1) { return { type: "any" }; })(result61)
|
|
|
: null;
|
|
|
if (result60 !== null) {
|
|
|
var result53 = result60;
|
|
|
} else {
|
|
|
var result59 = this._parse_class(context);
|
|
|
if (result59 !== null) {
|
|
|
var result53 = result59;
|
|
|
} else {
|
|
|
var savedPos10 = this._pos;
|
|
|
var result56 = this._parse_lparen(context);
|
|
|
if (result56 !== null) {
|
|
|
var result57 = this._parse_choice(context);
|
|
|
if (result57 !== null) {
|
|
|
var result58 = this._parse_rparen(context);
|
|
|
if (result58 !== null) {
|
|
|
var result55 = [result56, result57, result58];
|
|
|
} else {
|
|
|
var result55 = null;
|
|
|
this._pos = savedPos10;
|
|
|
}
|
|
|
} else {
|
|
|
var result55 = null;
|
|
|
this._pos = savedPos10;
|
|
|
}
|
|
|
} else {
|
|
|
var result55 = null;
|
|
|
this._pos = savedPos10;
|
|
|
}
|
|
|
var result54 = result55 !== null
|
|
|
? (function($1, $2, $3) { return $2; }).apply(null, result55)
|
|
|
: null;
|
|
|
if (result54 !== null) {
|
|
|
var result53 = result54;
|
|
|
} else {
|
|
|
var result53 = null;;
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result53
|
|
|
};
|
|
|
return result53;
|
|
|
},
|
|
|
|
|
|
_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 savedPos14 = this._pos;
|
|
|
var result75 = this._parse_braced(context);
|
|
|
if (result75 !== null) {
|
|
|
var result76 = this._parse___(context);
|
|
|
if (result76 !== null) {
|
|
|
var result74 = [result75, result76];
|
|
|
} else {
|
|
|
var result74 = null;
|
|
|
this._pos = savedPos14;
|
|
|
}
|
|
|
} else {
|
|
|
var result74 = null;
|
|
|
this._pos = savedPos14;
|
|
|
}
|
|
|
var result73 = result74 !== null
|
|
|
? (function($1, $2) { return $1.substr(1, $1.length - 2); }).apply(null, result74)
|
|
|
: null;
|
|
|
context.reportMatchFailures = savedReportMatchFailures;
|
|
|
if (context.reportMatchFailures && result73 === null) {
|
|
|
this._matchFailed("action");
|
|
|
}
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result73
|
|
|
};
|
|
|
return result73;
|
|
|
},
|
|
|
|
|
|
_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 savedPos15 = this._pos;
|
|
|
if (this._input.substr(this._pos, 1) === "{") {
|
|
|
var result79 = "{";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result79 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("{"));
|
|
|
}
|
|
|
}
|
|
|
if (result79 !== null) {
|
|
|
var result80 = [];
|
|
|
var result84 = this._parse_braced(context);
|
|
|
if (result84 !== null) {
|
|
|
var result82 = result84;
|
|
|
} else {
|
|
|
var result83 = this._parse_nonBraceCharacter(context);
|
|
|
if (result83 !== null) {
|
|
|
var result82 = result83;
|
|
|
} else {
|
|
|
var result82 = null;;
|
|
|
};
|
|
|
}
|
|
|
while (result82 !== null) {
|
|
|
result80.push(result82);
|
|
|
var result84 = this._parse_braced(context);
|
|
|
if (result84 !== null) {
|
|
|
var result82 = result84;
|
|
|
} else {
|
|
|
var result83 = this._parse_nonBraceCharacter(context);
|
|
|
if (result83 !== null) {
|
|
|
var result82 = result83;
|
|
|
} else {
|
|
|
var result82 = null;;
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
if (result80 !== null) {
|
|
|
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 result78 = [result79, result80, result81];
|
|
|
} else {
|
|
|
var result78 = null;
|
|
|
this._pos = savedPos15;
|
|
|
}
|
|
|
} else {
|
|
|
var result78 = null;
|
|
|
this._pos = savedPos15;
|
|
|
}
|
|
|
} else {
|
|
|
var result78 = null;
|
|
|
this._pos = savedPos15;
|
|
|
}
|
|
|
var result77 = result78 !== null
|
|
|
? (function($1, $2, $3) { return $1 + $2.join("") + $3; }).apply(null, result78)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result77
|
|
|
};
|
|
|
return result77;
|
|
|
},
|
|
|
|
|
|
_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 result87 = this._parse_nonBraceCharacter(context);
|
|
|
if (result87 !== null) {
|
|
|
var result86 = [];
|
|
|
while (result87 !== null) {
|
|
|
result86.push(result87);
|
|
|
var result87 = this._parse_nonBraceCharacter(context);
|
|
|
}
|
|
|
} else {
|
|
|
var result86 = null;
|
|
|
}
|
|
|
var result85 = result86 !== null
|
|
|
? (function($1) { return $1.join(""); })(result86)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result85
|
|
|
};
|
|
|
return result85;
|
|
|
},
|
|
|
|
|
|
_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 result88 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result88 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed("[^{}]");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result88
|
|
|
};
|
|
|
return result88;
|
|
|
},
|
|
|
|
|
|
_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 savedPos16 = this._pos;
|
|
|
if (this._input.substr(this._pos, 1) === ":") {
|
|
|
var result91 = ":";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result91 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString(":"));
|
|
|
}
|
|
|
}
|
|
|
if (result91 !== null) {
|
|
|
var result92 = this._parse___(context);
|
|
|
if (result92 !== null) {
|
|
|
var result90 = [result91, result92];
|
|
|
} else {
|
|
|
var result90 = null;
|
|
|
this._pos = savedPos16;
|
|
|
}
|
|
|
} else {
|
|
|
var result90 = null;
|
|
|
this._pos = savedPos16;
|
|
|
}
|
|
|
var result89 = result90 !== null
|
|
|
? (function($1, $2) { return $1; }).apply(null, result90)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result89
|
|
|
};
|
|
|
return result89;
|
|
|
},
|
|
|
|
|
|
_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 savedPos17 = this._pos;
|
|
|
if (this._input.substr(this._pos, 1) === "/") {
|
|
|
var result95 = "/";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result95 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("/"));
|
|
|
}
|
|
|
}
|
|
|
if (result95 !== null) {
|
|
|
var result96 = this._parse___(context);
|
|
|
if (result96 !== null) {
|
|
|
var result94 = [result95, result96];
|
|
|
} else {
|
|
|
var result94 = null;
|
|
|
this._pos = savedPos17;
|
|
|
}
|
|
|
} else {
|
|
|
var result94 = null;
|
|
|
this._pos = savedPos17;
|
|
|
}
|
|
|
var result93 = result94 !== null
|
|
|
? (function($1, $2) { return $1; }).apply(null, result94)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result93
|
|
|
};
|
|
|
return result93;
|
|
|
},
|
|
|
|
|
|
_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 savedPos18 = this._pos;
|
|
|
if (this._input.substr(this._pos, 1) === "&") {
|
|
|
var result99 = "&";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result99 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("&"));
|
|
|
}
|
|
|
}
|
|
|
if (result99 !== null) {
|
|
|
var result100 = this._parse___(context);
|
|
|
if (result100 !== null) {
|
|
|
var result98 = [result99, result100];
|
|
|
} else {
|
|
|
var result98 = null;
|
|
|
this._pos = savedPos18;
|
|
|
}
|
|
|
} else {
|
|
|
var result98 = null;
|
|
|
this._pos = savedPos18;
|
|
|
}
|
|
|
var result97 = result98 !== null
|
|
|
? (function($1, $2) { return $1; }).apply(null, result98)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result97
|
|
|
};
|
|
|
return result97;
|
|
|
},
|
|
|
|
|
|
_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 savedPos19 = this._pos;
|
|
|
if (this._input.substr(this._pos, 1) === "!") {
|
|
|
var result103 = "!";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result103 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("!"));
|
|
|
}
|
|
|
}
|
|
|
if (result103 !== null) {
|
|
|
var result104 = this._parse___(context);
|
|
|
if (result104 !== null) {
|
|
|
var result102 = [result103, result104];
|
|
|
} else {
|
|
|
var result102 = null;
|
|
|
this._pos = savedPos19;
|
|
|
}
|
|
|
} else {
|
|
|
var result102 = null;
|
|
|
this._pos = savedPos19;
|
|
|
}
|
|
|
var result101 = result102 !== null
|
|
|
? (function($1, $2) { return $1; }).apply(null, result102)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result101
|
|
|
};
|
|
|
return result101;
|
|
|
},
|
|
|
|
|
|
_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 savedPos20 = this._pos;
|
|
|
if (this._input.substr(this._pos, 1) === "?") {
|
|
|
var result107 = "?";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result107 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("?"));
|
|
|
}
|
|
|
}
|
|
|
if (result107 !== null) {
|
|
|
var result108 = this._parse___(context);
|
|
|
if (result108 !== null) {
|
|
|
var result106 = [result107, result108];
|
|
|
} else {
|
|
|
var result106 = null;
|
|
|
this._pos = savedPos20;
|
|
|
}
|
|
|
} else {
|
|
|
var result106 = null;
|
|
|
this._pos = savedPos20;
|
|
|
}
|
|
|
var result105 = result106 !== null
|
|
|
? (function($1, $2) { return $1; }).apply(null, result106)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result105
|
|
|
};
|
|
|
return result105;
|
|
|
},
|
|
|
|
|
|
_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 savedPos21 = this._pos;
|
|
|
if (this._input.substr(this._pos, 1) === "*") {
|
|
|
var result111 = "*";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result111 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("*"));
|
|
|
}
|
|
|
}
|
|
|
if (result111 !== null) {
|
|
|
var result112 = this._parse___(context);
|
|
|
if (result112 !== null) {
|
|
|
var result110 = [result111, result112];
|
|
|
} else {
|
|
|
var result110 = null;
|
|
|
this._pos = savedPos21;
|
|
|
}
|
|
|
} else {
|
|
|
var result110 = null;
|
|
|
this._pos = savedPos21;
|
|
|
}
|
|
|
var result109 = result110 !== null
|
|
|
? (function($1, $2) { return $1; }).apply(null, result110)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result109
|
|
|
};
|
|
|
return result109;
|
|
|
},
|
|
|
|
|
|
_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 savedPos22 = this._pos;
|
|
|
if (this._input.substr(this._pos, 1) === "+") {
|
|
|
var result115 = "+";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result115 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("+"));
|
|
|
}
|
|
|
}
|
|
|
if (result115 !== null) {
|
|
|
var result116 = this._parse___(context);
|
|
|
if (result116 !== null) {
|
|
|
var result114 = [result115, result116];
|
|
|
} else {
|
|
|
var result114 = null;
|
|
|
this._pos = savedPos22;
|
|
|
}
|
|
|
} else {
|
|
|
var result114 = null;
|
|
|
this._pos = savedPos22;
|
|
|
}
|
|
|
var result113 = result114 !== null
|
|
|
? (function($1, $2) { return $1; }).apply(null, result114)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result113
|
|
|
};
|
|
|
return result113;
|
|
|
},
|
|
|
|
|
|
_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 savedPos23 = this._pos;
|
|
|
if (this._input.substr(this._pos, 1) === "(") {
|
|
|
var result119 = "(";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result119 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("("));
|
|
|
}
|
|
|
}
|
|
|
if (result119 !== null) {
|
|
|
var result120 = this._parse___(context);
|
|
|
if (result120 !== null) {
|
|
|
var result118 = [result119, result120];
|
|
|
} else {
|
|
|
var result118 = null;
|
|
|
this._pos = savedPos23;
|
|
|
}
|
|
|
} else {
|
|
|
var result118 = null;
|
|
|
this._pos = savedPos23;
|
|
|
}
|
|
|
var result117 = result118 !== null
|
|
|
? (function($1, $2) { return $1; }).apply(null, result118)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result117
|
|
|
};
|
|
|
return result117;
|
|
|
},
|
|
|
|
|
|
_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 savedPos24 = this._pos;
|
|
|
if (this._input.substr(this._pos, 1) === ")") {
|
|
|
var result123 = ")";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result123 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString(")"));
|
|
|
}
|
|
|
}
|
|
|
if (result123 !== null) {
|
|
|
var result124 = this._parse___(context);
|
|
|
if (result124 !== null) {
|
|
|
var result122 = [result123, result124];
|
|
|
} else {
|
|
|
var result122 = null;
|
|
|
this._pos = savedPos24;
|
|
|
}
|
|
|
} else {
|
|
|
var result122 = null;
|
|
|
this._pos = savedPos24;
|
|
|
}
|
|
|
var result121 = result122 !== null
|
|
|
? (function($1, $2) { return $1; }).apply(null, result122)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result121
|
|
|
};
|
|
|
return result121;
|
|
|
},
|
|
|
|
|
|
_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 savedPos25 = this._pos;
|
|
|
if (this._input.substr(this._pos, 1) === ".") {
|
|
|
var result127 = ".";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result127 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("."));
|
|
|
}
|
|
|
}
|
|
|
if (result127 !== null) {
|
|
|
var result128 = this._parse___(context);
|
|
|
if (result128 !== null) {
|
|
|
var result126 = [result127, result128];
|
|
|
} else {
|
|
|
var result126 = null;
|
|
|
this._pos = savedPos25;
|
|
|
}
|
|
|
} else {
|
|
|
var result126 = null;
|
|
|
this._pos = savedPos25;
|
|
|
}
|
|
|
var result125 = result126 !== null
|
|
|
? (function($1, $2) { return $1; }).apply(null, result126)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result125
|
|
|
};
|
|
|
return result125;
|
|
|
},
|
|
|
|
|
|
_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 savedPos26 = this._pos;
|
|
|
var result141 = this._parse_letter(context);
|
|
|
if (result141 !== null) {
|
|
|
var result131 = result141;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 1) === "_") {
|
|
|
var result140 = "_";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result140 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("_"));
|
|
|
}
|
|
|
}
|
|
|
if (result140 !== null) {
|
|
|
var result131 = 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 result131 = result139;
|
|
|
} else {
|
|
|
var result131 = null;;
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
if (result131 !== null) {
|
|
|
var result132 = [];
|
|
|
var result138 = this._parse_letter(context);
|
|
|
if (result138 !== null) {
|
|
|
var result134 = result138;
|
|
|
} else {
|
|
|
var result137 = this._parse_digit(context);
|
|
|
if (result137 !== null) {
|
|
|
var result134 = result137;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 1) === "_") {
|
|
|
var result136 = "_";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result136 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("_"));
|
|
|
}
|
|
|
}
|
|
|
if (result136 !== null) {
|
|
|
var result134 = result136;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 1) === "$") {
|
|
|
var result135 = "$";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result135 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("$"));
|
|
|
}
|
|
|
}
|
|
|
if (result135 !== null) {
|
|
|
var result134 = result135;
|
|
|
} else {
|
|
|
var result134 = null;;
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
while (result134 !== null) {
|
|
|
result132.push(result134);
|
|
|
var result138 = this._parse_letter(context);
|
|
|
if (result138 !== null) {
|
|
|
var result134 = result138;
|
|
|
} else {
|
|
|
var result137 = this._parse_digit(context);
|
|
|
if (result137 !== null) {
|
|
|
var result134 = result137;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 1) === "_") {
|
|
|
var result136 = "_";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result136 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("_"));
|
|
|
}
|
|
|
}
|
|
|
if (result136 !== null) {
|
|
|
var result134 = result136;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 1) === "$") {
|
|
|
var result135 = "$";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result135 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("$"));
|
|
|
}
|
|
|
}
|
|
|
if (result135 !== null) {
|
|
|
var result134 = result135;
|
|
|
} else {
|
|
|
var result134 = null;;
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
if (result132 !== null) {
|
|
|
var result133 = this._parse___(context);
|
|
|
if (result133 !== null) {
|
|
|
var result130 = [result131, result132, result133];
|
|
|
} else {
|
|
|
var result130 = null;
|
|
|
this._pos = savedPos26;
|
|
|
}
|
|
|
} else {
|
|
|
var result130 = null;
|
|
|
this._pos = savedPos26;
|
|
|
}
|
|
|
} else {
|
|
|
var result130 = null;
|
|
|
this._pos = savedPos26;
|
|
|
}
|
|
|
var result129 = result130 !== null
|
|
|
? (function($1, $2, $3) {
|
|
|
return $1 + $2.join("");
|
|
|
}).apply(null, result130)
|
|
|
: null;
|
|
|
context.reportMatchFailures = savedReportMatchFailures;
|
|
|
if (context.reportMatchFailures && result129 === null) {
|
|
|
this._matchFailed("identifier");
|
|
|
}
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result129
|
|
|
};
|
|
|
return result129;
|
|
|
},
|
|
|
|
|
|
_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 savedPos27 = this._pos;
|
|
|
var result147 = this._parse_doubleQuotedLiteral(context);
|
|
|
if (result147 !== null) {
|
|
|
var result144 = result147;
|
|
|
} else {
|
|
|
var result146 = this._parse_singleQuotedLiteral(context);
|
|
|
if (result146 !== null) {
|
|
|
var result144 = result146;
|
|
|
} else {
|
|
|
var result144 = null;;
|
|
|
};
|
|
|
}
|
|
|
if (result144 !== null) {
|
|
|
var result145 = this._parse___(context);
|
|
|
if (result145 !== null) {
|
|
|
var result143 = [result144, result145];
|
|
|
} else {
|
|
|
var result143 = null;
|
|
|
this._pos = savedPos27;
|
|
|
}
|
|
|
} else {
|
|
|
var result143 = null;
|
|
|
this._pos = savedPos27;
|
|
|
}
|
|
|
var result142 = result143 !== null
|
|
|
? (function($1, $2) { return $1; }).apply(null, result143)
|
|
|
: null;
|
|
|
context.reportMatchFailures = savedReportMatchFailures;
|
|
|
if (context.reportMatchFailures && result142 === null) {
|
|
|
this._matchFailed("literal");
|
|
|
}
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result142
|
|
|
};
|
|
|
return result142;
|
|
|
},
|
|
|
|
|
|
_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 savedPos28 = this._pos;
|
|
|
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 result151 = [];
|
|
|
var result153 = this._parse_doubleQuotedCharacter(context);
|
|
|
while (result153 !== null) {
|
|
|
result151.push(result153);
|
|
|
var result153 = this._parse_doubleQuotedCharacter(context);
|
|
|
}
|
|
|
if (result151 !== null) {
|
|
|
if (this._input.substr(this._pos, 1) === "\"") {
|
|
|
var result152 = "\"";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result152 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\""));
|
|
|
}
|
|
|
}
|
|
|
if (result152 !== null) {
|
|
|
var result149 = [result150, result151, result152];
|
|
|
} else {
|
|
|
var result149 = null;
|
|
|
this._pos = savedPos28;
|
|
|
}
|
|
|
} else {
|
|
|
var result149 = null;
|
|
|
this._pos = savedPos28;
|
|
|
}
|
|
|
} else {
|
|
|
var result149 = null;
|
|
|
this._pos = savedPos28;
|
|
|
}
|
|
|
var result148 = result149 !== null
|
|
|
? (function($1, $2, $3) { return $2.join(""); }).apply(null, result149)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result148
|
|
|
};
|
|
|
return result148;
|
|
|
},
|
|
|
|
|
|
_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 result160 = this._parse_simpleDoubleQuotedCharacter(context);
|
|
|
if (result160 !== null) {
|
|
|
var result154 = result160;
|
|
|
} else {
|
|
|
var result159 = this._parse_simpleEscapeSequence(context);
|
|
|
if (result159 !== null) {
|
|
|
var result154 = result159;
|
|
|
} else {
|
|
|
var result158 = this._parse_zeroEscapeSequence(context);
|
|
|
if (result158 !== null) {
|
|
|
var result154 = result158;
|
|
|
} else {
|
|
|
var result157 = this._parse_hexEscapeSequence(context);
|
|
|
if (result157 !== null) {
|
|
|
var result154 = result157;
|
|
|
} else {
|
|
|
var result156 = this._parse_unicodeEscapeSequence(context);
|
|
|
if (result156 !== null) {
|
|
|
var result154 = result156;
|
|
|
} else {
|
|
|
var result155 = this._parse_eolEscapeSequence(context);
|
|
|
if (result155 !== null) {
|
|
|
var result154 = result155;
|
|
|
} else {
|
|
|
var result154 = null;;
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result154
|
|
|
};
|
|
|
return result154;
|
|
|
},
|
|
|
|
|
|
_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 savedPos29 = this._pos;
|
|
|
var savedPos30 = this._pos;
|
|
|
var savedReportMatchFailuresVar1 = context.reportMatchFailures;
|
|
|
context.reportMatchFailures = false;
|
|
|
if (this._input.substr(this._pos, 1) === "\"") {
|
|
|
var result168 = "\"";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result168 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\""));
|
|
|
}
|
|
|
}
|
|
|
if (result168 !== null) {
|
|
|
var result165 = result168;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 1) === "\\") {
|
|
|
var result167 = "\\";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result167 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\\"));
|
|
|
}
|
|
|
}
|
|
|
if (result167 !== null) {
|
|
|
var result165 = result167;
|
|
|
} else {
|
|
|
var result166 = this._parse_eolChar(context);
|
|
|
if (result166 !== null) {
|
|
|
var result165 = result166;
|
|
|
} else {
|
|
|
var result165 = null;;
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
context.reportMatchFailures = savedReportMatchFailuresVar1;
|
|
|
if (result165 === null) {
|
|
|
var result163 = '';
|
|
|
} else {
|
|
|
var result163 = null;
|
|
|
this._pos = savedPos30;
|
|
|
}
|
|
|
if (result163 !== null) {
|
|
|
if (this._input.length > this._pos) {
|
|
|
var result164 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result164 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed('any character');
|
|
|
}
|
|
|
}
|
|
|
if (result164 !== null) {
|
|
|
var result162 = [result163, result164];
|
|
|
} else {
|
|
|
var result162 = null;
|
|
|
this._pos = savedPos29;
|
|
|
}
|
|
|
} else {
|
|
|
var result162 = null;
|
|
|
this._pos = savedPos29;
|
|
|
}
|
|
|
var result161 = result162 !== null
|
|
|
? (function($1, $2) { return $2; }).apply(null, result162)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result161
|
|
|
};
|
|
|
return result161;
|
|
|
},
|
|
|
|
|
|
_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 savedPos31 = this._pos;
|
|
|
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 result172 = [];
|
|
|
var result174 = this._parse_singleQuotedCharacter(context);
|
|
|
while (result174 !== null) {
|
|
|
result172.push(result174);
|
|
|
var result174 = this._parse_singleQuotedCharacter(context);
|
|
|
}
|
|
|
if (result172 !== null) {
|
|
|
if (this._input.substr(this._pos, 1) === "'") {
|
|
|
var result173 = "'";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result173 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("'"));
|
|
|
}
|
|
|
}
|
|
|
if (result173 !== null) {
|
|
|
var result170 = [result171, result172, result173];
|
|
|
} else {
|
|
|
var result170 = null;
|
|
|
this._pos = savedPos31;
|
|
|
}
|
|
|
} else {
|
|
|
var result170 = null;
|
|
|
this._pos = savedPos31;
|
|
|
}
|
|
|
} else {
|
|
|
var result170 = null;
|
|
|
this._pos = savedPos31;
|
|
|
}
|
|
|
var result169 = result170 !== null
|
|
|
? (function($1, $2, $3) { return $2.join(""); }).apply(null, result170)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result169
|
|
|
};
|
|
|
return result169;
|
|
|
},
|
|
|
|
|
|
_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 result181 = this._parse_simpleSingleQuotedCharacter(context);
|
|
|
if (result181 !== null) {
|
|
|
var result175 = result181;
|
|
|
} else {
|
|
|
var result180 = this._parse_simpleEscapeSequence(context);
|
|
|
if (result180 !== null) {
|
|
|
var result175 = result180;
|
|
|
} else {
|
|
|
var result179 = this._parse_zeroEscapeSequence(context);
|
|
|
if (result179 !== null) {
|
|
|
var result175 = result179;
|
|
|
} else {
|
|
|
var result178 = this._parse_hexEscapeSequence(context);
|
|
|
if (result178 !== null) {
|
|
|
var result175 = result178;
|
|
|
} else {
|
|
|
var result177 = this._parse_unicodeEscapeSequence(context);
|
|
|
if (result177 !== null) {
|
|
|
var result175 = result177;
|
|
|
} else {
|
|
|
var result176 = this._parse_eolEscapeSequence(context);
|
|
|
if (result176 !== null) {
|
|
|
var result175 = result176;
|
|
|
} else {
|
|
|
var result175 = null;;
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result175
|
|
|
};
|
|
|
return result175;
|
|
|
},
|
|
|
|
|
|
_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 savedPos32 = this._pos;
|
|
|
var savedPos33 = this._pos;
|
|
|
var savedReportMatchFailuresVar2 = context.reportMatchFailures;
|
|
|
context.reportMatchFailures = false;
|
|
|
if (this._input.substr(this._pos, 1) === "'") {
|
|
|
var result189 = "'";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result189 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("'"));
|
|
|
}
|
|
|
}
|
|
|
if (result189 !== null) {
|
|
|
var result186 = result189;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 1) === "\\") {
|
|
|
var result188 = "\\";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result188 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\\"));
|
|
|
}
|
|
|
}
|
|
|
if (result188 !== null) {
|
|
|
var result186 = result188;
|
|
|
} else {
|
|
|
var result187 = this._parse_eolChar(context);
|
|
|
if (result187 !== null) {
|
|
|
var result186 = result187;
|
|
|
} else {
|
|
|
var result186 = null;;
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
context.reportMatchFailures = savedReportMatchFailuresVar2;
|
|
|
if (result186 === null) {
|
|
|
var result184 = '';
|
|
|
} else {
|
|
|
var result184 = null;
|
|
|
this._pos = savedPos33;
|
|
|
}
|
|
|
if (result184 !== null) {
|
|
|
if (this._input.length > this._pos) {
|
|
|
var result185 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result185 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed('any character');
|
|
|
}
|
|
|
}
|
|
|
if (result185 !== null) {
|
|
|
var result183 = [result184, result185];
|
|
|
} else {
|
|
|
var result183 = null;
|
|
|
this._pos = savedPos32;
|
|
|
}
|
|
|
} else {
|
|
|
var result183 = null;
|
|
|
this._pos = savedPos32;
|
|
|
}
|
|
|
var result182 = result183 !== null
|
|
|
? (function($1, $2) { return $2; }).apply(null, result183)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result182
|
|
|
};
|
|
|
return result182;
|
|
|
},
|
|
|
|
|
|
_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 savedPos34 = this._pos;
|
|
|
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) {
|
|
|
if (this._input.substr(this._pos, 1) === "^") {
|
|
|
var result200 = "^";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result200 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("^"));
|
|
|
}
|
|
|
}
|
|
|
var result193 = result200 !== null ? result200 : '';
|
|
|
if (result193 !== null) {
|
|
|
var result194 = [];
|
|
|
var result199 = this._parse_classCharacterRange(context);
|
|
|
if (result199 !== null) {
|
|
|
var result197 = result199;
|
|
|
} else {
|
|
|
var result198 = this._parse_classCharacter(context);
|
|
|
if (result198 !== null) {
|
|
|
var result197 = result198;
|
|
|
} else {
|
|
|
var result197 = null;;
|
|
|
};
|
|
|
}
|
|
|
while (result197 !== null) {
|
|
|
result194.push(result197);
|
|
|
var result199 = this._parse_classCharacterRange(context);
|
|
|
if (result199 !== null) {
|
|
|
var result197 = result199;
|
|
|
} else {
|
|
|
var result198 = this._parse_classCharacter(context);
|
|
|
if (result198 !== null) {
|
|
|
var result197 = result198;
|
|
|
} else {
|
|
|
var result197 = null;;
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
if (result194 !== null) {
|
|
|
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) {
|
|
|
var result196 = this._parse___(context);
|
|
|
if (result196 !== null) {
|
|
|
var result191 = [result192, result193, result194, result195, result196];
|
|
|
} else {
|
|
|
var result191 = null;
|
|
|
this._pos = savedPos34;
|
|
|
}
|
|
|
} else {
|
|
|
var result191 = null;
|
|
|
this._pos = savedPos34;
|
|
|
}
|
|
|
} else {
|
|
|
var result191 = null;
|
|
|
this._pos = savedPos34;
|
|
|
}
|
|
|
} else {
|
|
|
var result191 = null;
|
|
|
this._pos = savedPos34;
|
|
|
}
|
|
|
} else {
|
|
|
var result191 = null;
|
|
|
this._pos = savedPos34;
|
|
|
}
|
|
|
var result190 = result191 !== null
|
|
|
? (function($1, $2, $3, $4, $5) {
|
|
|
parts = PEG.ArrayUtils.map($3, function(part) { return part.data; });
|
|
|
rawText = "["
|
|
|
+ $2
|
|
|
+ PEG.ArrayUtils.map($3, function(part) { return part.rawText; }).join("")
|
|
|
+ "]";
|
|
|
|
|
|
return {
|
|
|
type: "class",
|
|
|
inverted: $2 === "^",
|
|
|
parts: parts,
|
|
|
// FIXME: Get the raw text from the input directly.
|
|
|
rawText: rawText
|
|
|
};
|
|
|
}).apply(null, result191)
|
|
|
: null;
|
|
|
context.reportMatchFailures = savedReportMatchFailures;
|
|
|
if (context.reportMatchFailures && result190 === null) {
|
|
|
this._matchFailed("character class");
|
|
|
}
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result190
|
|
|
};
|
|
|
return result190;
|
|
|
},
|
|
|
|
|
|
_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 savedPos35 = this._pos;
|
|
|
var result203 = this._parse_classCharacter(context);
|
|
|
if (result203 !== null) {
|
|
|
if (this._input.substr(this._pos, 1) === "-") {
|
|
|
var result204 = "-";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result204 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("-"));
|
|
|
}
|
|
|
}
|
|
|
if (result204 !== null) {
|
|
|
var result205 = this._parse_classCharacter(context);
|
|
|
if (result205 !== null) {
|
|
|
var result202 = [result203, result204, result205];
|
|
|
} else {
|
|
|
var result202 = null;
|
|
|
this._pos = savedPos35;
|
|
|
}
|
|
|
} else {
|
|
|
var result202 = null;
|
|
|
this._pos = savedPos35;
|
|
|
}
|
|
|
} else {
|
|
|
var result202 = null;
|
|
|
this._pos = savedPos35;
|
|
|
}
|
|
|
var result201 = result202 !== null
|
|
|
? (function($1, $2, $3) {
|
|
|
if ($1.data.charCodeAt(0) > $3.data.charCodeAt(0)) {
|
|
|
throw new this.SyntaxError(
|
|
|
"Invalid character range: " + $1.rawText + "-" + $2.rawText + "."
|
|
|
);
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
data: [$1.data, $3.data],
|
|
|
// FIXME: Get the raw text from the input directly.
|
|
|
rawText: $1.rawText + "-" + $3.rawText
|
|
|
}
|
|
|
}).apply(null, result202)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result201
|
|
|
};
|
|
|
return result201;
|
|
|
},
|
|
|
|
|
|
_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 result207 = this._parse_bracketDelimitedCharacter(context);
|
|
|
var result206 = result207 !== null
|
|
|
? (function($1) {
|
|
|
return {
|
|
|
data: $1,
|
|
|
// FIXME: Get the raw text from the input directly.
|
|
|
rawText: PEG.RegExpUtils.quoteForClass($1)
|
|
|
};
|
|
|
})(result207)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result206
|
|
|
};
|
|
|
return result206;
|
|
|
},
|
|
|
|
|
|
_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 result214 = this._parse_simpleBracketDelimitedCharacter(context);
|
|
|
if (result214 !== null) {
|
|
|
var result208 = result214;
|
|
|
} else {
|
|
|
var result213 = this._parse_simpleEscapeSequence(context);
|
|
|
if (result213 !== null) {
|
|
|
var result208 = result213;
|
|
|
} else {
|
|
|
var result212 = this._parse_zeroEscapeSequence(context);
|
|
|
if (result212 !== null) {
|
|
|
var result208 = result212;
|
|
|
} else {
|
|
|
var result211 = this._parse_hexEscapeSequence(context);
|
|
|
if (result211 !== null) {
|
|
|
var result208 = result211;
|
|
|
} else {
|
|
|
var result210 = this._parse_unicodeEscapeSequence(context);
|
|
|
if (result210 !== null) {
|
|
|
var result208 = result210;
|
|
|
} else {
|
|
|
var result209 = this._parse_eolEscapeSequence(context);
|
|
|
if (result209 !== null) {
|
|
|
var result208 = result209;
|
|
|
} else {
|
|
|
var result208 = null;;
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result208
|
|
|
};
|
|
|
return result208;
|
|
|
},
|
|
|
|
|
|
_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 savedPos36 = this._pos;
|
|
|
var savedPos37 = this._pos;
|
|
|
var savedReportMatchFailuresVar3 = context.reportMatchFailures;
|
|
|
context.reportMatchFailures = false;
|
|
|
if (this._input.substr(this._pos, 1) === "]") {
|
|
|
var result222 = "]";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result222 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("]"));
|
|
|
}
|
|
|
}
|
|
|
if (result222 !== null) {
|
|
|
var result219 = result222;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 1) === "\\") {
|
|
|
var result221 = "\\";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result221 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\\"));
|
|
|
}
|
|
|
}
|
|
|
if (result221 !== null) {
|
|
|
var result219 = result221;
|
|
|
} else {
|
|
|
var result220 = this._parse_eolChar(context);
|
|
|
if (result220 !== null) {
|
|
|
var result219 = result220;
|
|
|
} else {
|
|
|
var result219 = null;;
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
context.reportMatchFailures = savedReportMatchFailuresVar3;
|
|
|
if (result219 === null) {
|
|
|
var result217 = '';
|
|
|
} else {
|
|
|
var result217 = null;
|
|
|
this._pos = savedPos37;
|
|
|
}
|
|
|
if (result217 !== null) {
|
|
|
if (this._input.length > this._pos) {
|
|
|
var result218 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result218 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed('any character');
|
|
|
}
|
|
|
}
|
|
|
if (result218 !== null) {
|
|
|
var result216 = [result217, result218];
|
|
|
} else {
|
|
|
var result216 = null;
|
|
|
this._pos = savedPos36;
|
|
|
}
|
|
|
} else {
|
|
|
var result216 = null;
|
|
|
this._pos = savedPos36;
|
|
|
}
|
|
|
var result215 = result216 !== null
|
|
|
? (function($1, $2) { return $2; }).apply(null, result216)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result215
|
|
|
};
|
|
|
return result215;
|
|
|
},
|
|
|
|
|
|
_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 savedPos38 = this._pos;
|
|
|
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 savedPos39 = this._pos;
|
|
|
var savedReportMatchFailuresVar4 = context.reportMatchFailures;
|
|
|
context.reportMatchFailures = false;
|
|
|
var result232 = this._parse_digit(context);
|
|
|
if (result232 !== null) {
|
|
|
var result228 = result232;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 1) === "x") {
|
|
|
var result231 = "x";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result231 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("x"));
|
|
|
}
|
|
|
}
|
|
|
if (result231 !== null) {
|
|
|
var result228 = result231;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 1) === "u") {
|
|
|
var result230 = "u";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result230 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("u"));
|
|
|
}
|
|
|
}
|
|
|
if (result230 !== null) {
|
|
|
var result228 = result230;
|
|
|
} else {
|
|
|
var result229 = this._parse_eolChar(context);
|
|
|
if (result229 !== null) {
|
|
|
var result228 = result229;
|
|
|
} else {
|
|
|
var result228 = null;;
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
context.reportMatchFailures = savedReportMatchFailuresVar4;
|
|
|
if (result228 === null) {
|
|
|
var result226 = '';
|
|
|
} else {
|
|
|
var result226 = null;
|
|
|
this._pos = savedPos39;
|
|
|
}
|
|
|
if (result226 !== null) {
|
|
|
if (this._input.length > this._pos) {
|
|
|
var result227 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result227 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed('any character');
|
|
|
}
|
|
|
}
|
|
|
if (result227 !== null) {
|
|
|
var result224 = [result225, result226, result227];
|
|
|
} else {
|
|
|
var result224 = null;
|
|
|
this._pos = savedPos38;
|
|
|
}
|
|
|
} else {
|
|
|
var result224 = null;
|
|
|
this._pos = savedPos38;
|
|
|
}
|
|
|
} else {
|
|
|
var result224 = null;
|
|
|
this._pos = savedPos38;
|
|
|
}
|
|
|
var result223 = result224 !== 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, result224)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result223
|
|
|
};
|
|
|
return result223;
|
|
|
},
|
|
|
|
|
|
_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 savedPos40 = this._pos;
|
|
|
if (this._input.substr(this._pos, 2) === "\\0") {
|
|
|
var result235 = "\\0";
|
|
|
this._pos += 2;
|
|
|
} else {
|
|
|
var result235 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\\0"));
|
|
|
}
|
|
|
}
|
|
|
if (result235 !== null) {
|
|
|
var savedPos41 = this._pos;
|
|
|
var savedReportMatchFailuresVar5 = context.reportMatchFailures;
|
|
|
context.reportMatchFailures = false;
|
|
|
var result237 = this._parse_digit(context);
|
|
|
context.reportMatchFailures = savedReportMatchFailuresVar5;
|
|
|
if (result237 === null) {
|
|
|
var result236 = '';
|
|
|
} else {
|
|
|
var result236 = null;
|
|
|
this._pos = savedPos41;
|
|
|
}
|
|
|
if (result236 !== null) {
|
|
|
var result234 = [result235, result236];
|
|
|
} else {
|
|
|
var result234 = null;
|
|
|
this._pos = savedPos40;
|
|
|
}
|
|
|
} else {
|
|
|
var result234 = null;
|
|
|
this._pos = savedPos40;
|
|
|
}
|
|
|
var result233 = result234 !== null
|
|
|
? (function($1, $2) { return "\0"; }).apply(null, result234)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result233
|
|
|
};
|
|
|
return result233;
|
|
|
},
|
|
|
|
|
|
_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 savedPos42 = this._pos;
|
|
|
if (this._input.substr(this._pos, 2) === "\\x") {
|
|
|
var result240 = "\\x";
|
|
|
this._pos += 2;
|
|
|
} else {
|
|
|
var result240 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\\x"));
|
|
|
}
|
|
|
}
|
|
|
if (result240 !== null) {
|
|
|
var result241 = this._parse_hexDigit(context);
|
|
|
if (result241 !== null) {
|
|
|
var result242 = this._parse_hexDigit(context);
|
|
|
if (result242 !== null) {
|
|
|
var result239 = [result240, result241, result242];
|
|
|
} else {
|
|
|
var result239 = null;
|
|
|
this._pos = savedPos42;
|
|
|
}
|
|
|
} else {
|
|
|
var result239 = null;
|
|
|
this._pos = savedPos42;
|
|
|
}
|
|
|
} else {
|
|
|
var result239 = null;
|
|
|
this._pos = savedPos42;
|
|
|
}
|
|
|
var result238 = result239 !== null
|
|
|
? (function($1, $2, $3) {
|
|
|
return String.fromCharCode(parseInt("0x" + $2 + $3));
|
|
|
}).apply(null, result239)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result238
|
|
|
};
|
|
|
return result238;
|
|
|
},
|
|
|
|
|
|
_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 savedPos43 = this._pos;
|
|
|
if (this._input.substr(this._pos, 2) === "\\u") {
|
|
|
var result245 = "\\u";
|
|
|
this._pos += 2;
|
|
|
} else {
|
|
|
var result245 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\\u"));
|
|
|
}
|
|
|
}
|
|
|
if (result245 !== null) {
|
|
|
var result246 = this._parse_hexDigit(context);
|
|
|
if (result246 !== null) {
|
|
|
var result247 = this._parse_hexDigit(context);
|
|
|
if (result247 !== null) {
|
|
|
var result248 = this._parse_hexDigit(context);
|
|
|
if (result248 !== null) {
|
|
|
var result249 = this._parse_hexDigit(context);
|
|
|
if (result249 !== null) {
|
|
|
var result244 = [result245, result246, result247, result248, result249];
|
|
|
} else {
|
|
|
var result244 = null;
|
|
|
this._pos = savedPos43;
|
|
|
}
|
|
|
} else {
|
|
|
var result244 = null;
|
|
|
this._pos = savedPos43;
|
|
|
}
|
|
|
} else {
|
|
|
var result244 = null;
|
|
|
this._pos = savedPos43;
|
|
|
}
|
|
|
} else {
|
|
|
var result244 = null;
|
|
|
this._pos = savedPos43;
|
|
|
}
|
|
|
} else {
|
|
|
var result244 = null;
|
|
|
this._pos = savedPos43;
|
|
|
}
|
|
|
var result243 = result244 !== null
|
|
|
? (function($1, $2, $3, $4, $5) {
|
|
|
return String.fromCharCode(parseInt("0x" + $2 + $3 + $4 + $5));
|
|
|
}).apply(null, result244)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result243
|
|
|
};
|
|
|
return result243;
|
|
|
},
|
|
|
|
|
|
_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 savedPos44 = this._pos;
|
|
|
if (this._input.substr(this._pos, 1) === "\\") {
|
|
|
var result252 = "\\";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result252 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\\"));
|
|
|
}
|
|
|
}
|
|
|
if (result252 !== null) {
|
|
|
var result253 = this._parse_eol(context);
|
|
|
if (result253 !== null) {
|
|
|
var result251 = [result252, result253];
|
|
|
} else {
|
|
|
var result251 = null;
|
|
|
this._pos = savedPos44;
|
|
|
}
|
|
|
} else {
|
|
|
var result251 = null;
|
|
|
this._pos = savedPos44;
|
|
|
}
|
|
|
var result250 = result251 !== null
|
|
|
? (function($1, $2) { return $2; }).apply(null, result251)
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result250
|
|
|
};
|
|
|
return result250;
|
|
|
},
|
|
|
|
|
|
_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 result254 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result254 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed("[0-9]");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result254
|
|
|
};
|
|
|
return result254;
|
|
|
},
|
|
|
|
|
|
_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 result255 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result255 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed("[0-9a-fA-F]");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result255
|
|
|
};
|
|
|
return result255;
|
|
|
},
|
|
|
|
|
|
_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 result258 = this._parse_lowerCaseLetter(context);
|
|
|
if (result258 !== null) {
|
|
|
var result256 = result258;
|
|
|
} else {
|
|
|
var result257 = this._parse_upperCaseLetter(context);
|
|
|
if (result257 !== null) {
|
|
|
var result256 = result257;
|
|
|
} else {
|
|
|
var result256 = null;;
|
|
|
};
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result256
|
|
|
};
|
|
|
return result256;
|
|
|
},
|
|
|
|
|
|
_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 result259 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result259 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed("[a-z]");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result259
|
|
|
};
|
|
|
return result259;
|
|
|
},
|
|
|
|
|
|
_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 result260 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result260 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed("[A-Z]");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result260
|
|
|
};
|
|
|
return result260;
|
|
|
},
|
|
|
|
|
|
_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 result261 = [];
|
|
|
var result265 = this._parse_whitespace(context);
|
|
|
if (result265 !== null) {
|
|
|
var result262 = result265;
|
|
|
} else {
|
|
|
var result264 = this._parse_eol(context);
|
|
|
if (result264 !== null) {
|
|
|
var result262 = result264;
|
|
|
} else {
|
|
|
var result263 = this._parse_comment(context);
|
|
|
if (result263 !== null) {
|
|
|
var result262 = result263;
|
|
|
} else {
|
|
|
var result262 = null;;
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
while (result262 !== null) {
|
|
|
result261.push(result262);
|
|
|
var result265 = this._parse_whitespace(context);
|
|
|
if (result265 !== null) {
|
|
|
var result262 = result265;
|
|
|
} else {
|
|
|
var result264 = this._parse_eol(context);
|
|
|
if (result264 !== null) {
|
|
|
var result262 = result264;
|
|
|
} else {
|
|
|
var result263 = this._parse_comment(context);
|
|
|
if (result263 !== null) {
|
|
|
var result262 = result263;
|
|
|
} else {
|
|
|
var result262 = null;;
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result261
|
|
|
};
|
|
|
return result261;
|
|
|
},
|
|
|
|
|
|
_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 result268 = this._parse_singleLineComment(context);
|
|
|
if (result268 !== null) {
|
|
|
var result266 = result268;
|
|
|
} else {
|
|
|
var result267 = this._parse_multiLineComment(context);
|
|
|
if (result267 !== null) {
|
|
|
var result266 = result267;
|
|
|
} else {
|
|
|
var result266 = null;;
|
|
|
};
|
|
|
}
|
|
|
context.reportMatchFailures = savedReportMatchFailures;
|
|
|
if (context.reportMatchFailures && result266 === null) {
|
|
|
this._matchFailed("comment");
|
|
|
}
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result266
|
|
|
};
|
|
|
return result266;
|
|
|
},
|
|
|
|
|
|
_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 savedPos45 = this._pos;
|
|
|
if (this._input.substr(this._pos, 2) === "//") {
|
|
|
var result270 = "//";
|
|
|
this._pos += 2;
|
|
|
} else {
|
|
|
var result270 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("//"));
|
|
|
}
|
|
|
}
|
|
|
if (result270 !== null) {
|
|
|
var result271 = [];
|
|
|
var savedPos46 = this._pos;
|
|
|
var savedPos47 = this._pos;
|
|
|
var savedReportMatchFailuresVar6 = context.reportMatchFailures;
|
|
|
context.reportMatchFailures = false;
|
|
|
var result275 = this._parse_eolChar(context);
|
|
|
context.reportMatchFailures = savedReportMatchFailuresVar6;
|
|
|
if (result275 === null) {
|
|
|
var result273 = '';
|
|
|
} else {
|
|
|
var result273 = null;
|
|
|
this._pos = savedPos47;
|
|
|
}
|
|
|
if (result273 !== null) {
|
|
|
if (this._input.length > this._pos) {
|
|
|
var result274 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result274 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed('any character');
|
|
|
}
|
|
|
}
|
|
|
if (result274 !== null) {
|
|
|
var result272 = [result273, result274];
|
|
|
} else {
|
|
|
var result272 = null;
|
|
|
this._pos = savedPos46;
|
|
|
}
|
|
|
} else {
|
|
|
var result272 = null;
|
|
|
this._pos = savedPos46;
|
|
|
}
|
|
|
while (result272 !== null) {
|
|
|
result271.push(result272);
|
|
|
var savedPos46 = this._pos;
|
|
|
var savedPos47 = this._pos;
|
|
|
var savedReportMatchFailuresVar6 = context.reportMatchFailures;
|
|
|
context.reportMatchFailures = false;
|
|
|
var result275 = this._parse_eolChar(context);
|
|
|
context.reportMatchFailures = savedReportMatchFailuresVar6;
|
|
|
if (result275 === null) {
|
|
|
var result273 = '';
|
|
|
} else {
|
|
|
var result273 = null;
|
|
|
this._pos = savedPos47;
|
|
|
}
|
|
|
if (result273 !== null) {
|
|
|
if (this._input.length > this._pos) {
|
|
|
var result274 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result274 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed('any character');
|
|
|
}
|
|
|
}
|
|
|
if (result274 !== null) {
|
|
|
var result272 = [result273, result274];
|
|
|
} else {
|
|
|
var result272 = null;
|
|
|
this._pos = savedPos46;
|
|
|
}
|
|
|
} else {
|
|
|
var result272 = null;
|
|
|
this._pos = savedPos46;
|
|
|
}
|
|
|
}
|
|
|
if (result271 !== null) {
|
|
|
var result269 = [result270, result271];
|
|
|
} else {
|
|
|
var result269 = null;
|
|
|
this._pos = savedPos45;
|
|
|
}
|
|
|
} else {
|
|
|
var result269 = null;
|
|
|
this._pos = savedPos45;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result269
|
|
|
};
|
|
|
return result269;
|
|
|
},
|
|
|
|
|
|
_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 savedPos48 = this._pos;
|
|
|
if (this._input.substr(this._pos, 2) === "/*") {
|
|
|
var result277 = "/*";
|
|
|
this._pos += 2;
|
|
|
} else {
|
|
|
var result277 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("/*"));
|
|
|
}
|
|
|
}
|
|
|
if (result277 !== null) {
|
|
|
var result278 = [];
|
|
|
var savedPos49 = this._pos;
|
|
|
var savedPos50 = this._pos;
|
|
|
var savedReportMatchFailuresVar7 = context.reportMatchFailures;
|
|
|
context.reportMatchFailures = false;
|
|
|
if (this._input.substr(this._pos, 2) === "*/") {
|
|
|
var result283 = "*/";
|
|
|
this._pos += 2;
|
|
|
} else {
|
|
|
var result283 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("*/"));
|
|
|
}
|
|
|
}
|
|
|
context.reportMatchFailures = savedReportMatchFailuresVar7;
|
|
|
if (result283 === null) {
|
|
|
var result281 = '';
|
|
|
} else {
|
|
|
var result281 = null;
|
|
|
this._pos = savedPos50;
|
|
|
}
|
|
|
if (result281 !== null) {
|
|
|
if (this._input.length > this._pos) {
|
|
|
var result282 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result282 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed('any character');
|
|
|
}
|
|
|
}
|
|
|
if (result282 !== null) {
|
|
|
var result280 = [result281, result282];
|
|
|
} else {
|
|
|
var result280 = null;
|
|
|
this._pos = savedPos49;
|
|
|
}
|
|
|
} else {
|
|
|
var result280 = null;
|
|
|
this._pos = savedPos49;
|
|
|
}
|
|
|
while (result280 !== null) {
|
|
|
result278.push(result280);
|
|
|
var savedPos49 = this._pos;
|
|
|
var savedPos50 = this._pos;
|
|
|
var savedReportMatchFailuresVar7 = context.reportMatchFailures;
|
|
|
context.reportMatchFailures = false;
|
|
|
if (this._input.substr(this._pos, 2) === "*/") {
|
|
|
var result283 = "*/";
|
|
|
this._pos += 2;
|
|
|
} else {
|
|
|
var result283 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("*/"));
|
|
|
}
|
|
|
}
|
|
|
context.reportMatchFailures = savedReportMatchFailuresVar7;
|
|
|
if (result283 === null) {
|
|
|
var result281 = '';
|
|
|
} else {
|
|
|
var result281 = null;
|
|
|
this._pos = savedPos50;
|
|
|
}
|
|
|
if (result281 !== null) {
|
|
|
if (this._input.length > this._pos) {
|
|
|
var result282 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result282 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed('any character');
|
|
|
}
|
|
|
}
|
|
|
if (result282 !== null) {
|
|
|
var result280 = [result281, result282];
|
|
|
} else {
|
|
|
var result280 = null;
|
|
|
this._pos = savedPos49;
|
|
|
}
|
|
|
} else {
|
|
|
var result280 = null;
|
|
|
this._pos = savedPos49;
|
|
|
}
|
|
|
}
|
|
|
if (result278 !== null) {
|
|
|
if (this._input.substr(this._pos, 2) === "*/") {
|
|
|
var result279 = "*/";
|
|
|
this._pos += 2;
|
|
|
} else {
|
|
|
var result279 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("*/"));
|
|
|
}
|
|
|
}
|
|
|
if (result279 !== null) {
|
|
|
var result276 = [result277, result278, result279];
|
|
|
} else {
|
|
|
var result276 = null;
|
|
|
this._pos = savedPos48;
|
|
|
}
|
|
|
} else {
|
|
|
var result276 = null;
|
|
|
this._pos = savedPos48;
|
|
|
}
|
|
|
} else {
|
|
|
var result276 = null;
|
|
|
this._pos = savedPos48;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result276
|
|
|
};
|
|
|
return result276;
|
|
|
},
|
|
|
|
|
|
_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 result289 = "\n";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result289 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\n"));
|
|
|
}
|
|
|
}
|
|
|
if (result289 !== null) {
|
|
|
var result284 = result289;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 2) === "\r\n") {
|
|
|
var result288 = "\r\n";
|
|
|
this._pos += 2;
|
|
|
} else {
|
|
|
var result288 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\r\n"));
|
|
|
}
|
|
|
}
|
|
|
if (result288 !== null) {
|
|
|
var result284 = result288;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 1) === "\r") {
|
|
|
var result287 = "\r";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result287 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\r"));
|
|
|
}
|
|
|
}
|
|
|
if (result287 !== null) {
|
|
|
var result284 = result287;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 1) === "\u2028") {
|
|
|
var result286 = "\u2028";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result286 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\u2028"));
|
|
|
}
|
|
|
}
|
|
|
if (result286 !== null) {
|
|
|
var result284 = result286;
|
|
|
} else {
|
|
|
if (this._input.substr(this._pos, 1) === "\u2029") {
|
|
|
var result285 = "\u2029";
|
|
|
this._pos += 1;
|
|
|
} else {
|
|
|
var result285 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed(this._quoteString("\u2029"));
|
|
|
}
|
|
|
}
|
|
|
if (result285 !== null) {
|
|
|
var result284 = result285;
|
|
|
} else {
|
|
|
var result284 = null;;
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
};
|
|
|
}
|
|
|
context.reportMatchFailures = savedReportMatchFailures;
|
|
|
if (context.reportMatchFailures && result284 === null) {
|
|
|
this._matchFailed("end of line");
|
|
|
}
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result284
|
|
|
};
|
|
|
return result284;
|
|
|
},
|
|
|
|
|
|
_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 result290 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result290 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed("[\\n\\r\\u2028\\u2029]");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result290
|
|
|
};
|
|
|
return result290;
|
|
|
},
|
|
|
|
|
|
_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 result291 = this._input.charAt(this._pos);
|
|
|
this._pos++;
|
|
|
} else {
|
|
|
var result291 = null;
|
|
|
if (context.reportMatchFailures) {
|
|
|
this._matchFailed("[ - ]");
|
|
|
}
|
|
|
}
|
|
|
context.reportMatchFailures = savedReportMatchFailures;
|
|
|
if (context.reportMatchFailures && result291 === null) {
|
|
|
this._matchFailed("whitespace");
|
|
|
}
|
|
|
|
|
|
this._cache[cacheKey] = {
|
|
|
nextPos: this._pos,
|
|
|
result: result291
|
|
|
};
|
|
|
return result291;
|
|
|
},
|
|
|
|
|
|
/*
|
|
|
* 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;
|
|
|
})();
|