|
|
|
@ -734,6 +734,18 @@ PEG.Grammar.Literal.prototype.compile = function(resultVar) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PEG.Grammar.Class.prototype.compile = function(resultVar) {
|
|
|
|
|
/*
|
|
|
|
|
* Stupid IE considers regexps /[]/ and /[^]/ syntactically invalid, so we
|
|
|
|
|
* translate them into euqivalents it can handle.
|
|
|
|
|
*/
|
|
|
|
|
if (this._characters === "") {
|
|
|
|
|
var regexp = "/^(?!)/";
|
|
|
|
|
} else if (this._characters === "^") {
|
|
|
|
|
var regexp = "/^[\\S\\s]/";
|
|
|
|
|
} else {
|
|
|
|
|
var regexp = "/^[" + this._characters + "]/";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return PEG.Compiler.formatCode(
|
|
|
|
|
"if (this._input.substr(this._pos).match(${regexp}) !== null) {",
|
|
|
|
|
" var ${resultVar} = this._input[this._pos];",
|
|
|
|
@ -746,7 +758,7 @@ PEG.Grammar.Class.prototype.compile = function(resultVar) {
|
|
|
|
|
"}",
|
|
|
|
|
{
|
|
|
|
|
characters: this._characters,
|
|
|
|
|
regexp: "/^[" + this._characters + "]/",
|
|
|
|
|
regexp: regexp,
|
|
|
|
|
resultVar: resultVar
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|