Renamed |characters| -> |chars| (shorter, no loss of expressivity)
This commit is contained in:
parent
4e968892be
commit
137a4b4f53
|
@ -727,12 +727,12 @@ PEG.Compiler = {
|
|||
* Stupid IE considers regexps /[]/ and /[^]/ syntactically invalid, so we
|
||||
* translate them into euqivalents it can handle.
|
||||
*/
|
||||
if (node.characters === "") {
|
||||
if (node.chars === "") {
|
||||
var regexp = "/^(?!)/";
|
||||
} else if (node.characters === "^") {
|
||||
} else if (node.chars === "^") {
|
||||
var regexp = "/^[\\S\\s]/";
|
||||
} else {
|
||||
var regexp = "/^[" + node.characters + "]/";
|
||||
var regexp = "/^[" + node.chars + "]/";
|
||||
}
|
||||
|
||||
return PEG.Compiler.formatCode(
|
||||
|
@ -742,13 +742,13 @@ PEG.Compiler = {
|
|||
"} else {",
|
||||
" var ${resultVar} = null;",
|
||||
" if (context.reportMatchFailures) {",
|
||||
" this._matchFailed('[' + ${characters|string} + ']');",
|
||||
" this._matchFailed('[' + ${chars|string} + ']');",
|
||||
" }",
|
||||
"}",
|
||||
{
|
||||
characters: node.characters,
|
||||
regexp: regexp,
|
||||
resultVar: resultVar
|
||||
chars: node.chars,
|
||||
regexp: regexp,
|
||||
resultVar: resultVar
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -582,28 +582,28 @@ PEG.grammarParser = (function(){
|
|||
this._pos = savedPos11;
|
||||
}
|
||||
var result66 = result67 !== null
|
||||
? (function($1, $2) { return { type: "rule_ref", name: $1 }; }).apply(null, result67)
|
||||
? (function($1, $2) { return { type: "rule_ref", name: $1 }; }).apply(null, result67)
|
||||
: null;
|
||||
if (result66 !== null) {
|
||||
var result54 = result66;
|
||||
} else {
|
||||
var result65 = this._parse_literal(context);
|
||||
var result64 = result65 !== null
|
||||
? (function($1) { return { type: "literal", value: $1 }; })(result65)
|
||||
? (function($1) { return { type: "literal", value: $1 }; })(result65)
|
||||
: null;
|
||||
if (result64 !== null) {
|
||||
var result54 = result64;
|
||||
} else {
|
||||
var result63 = this._parse_dot(context);
|
||||
var result62 = result63 !== null
|
||||
? (function($1) { return { type: "any" }; })(result63)
|
||||
? (function($1) { return { type: "any" }; })(result63)
|
||||
: null;
|
||||
if (result62 !== null) {
|
||||
var result54 = result62;
|
||||
} else {
|
||||
var result61 = this._parse_class(context);
|
||||
var result60 = result61 !== null
|
||||
? (function($1) { return { type: "class", characters: $1 }; })(result61)
|
||||
? (function($1) { return { type: "class", chars: $1 }; })(result61)
|
||||
: null;
|
||||
if (result60 !== null) {
|
||||
var result54 = result60;
|
||||
|
|
|
@ -65,10 +65,10 @@ suffixed
|
|||
/ primary
|
||||
|
||||
primary
|
||||
: identifier !(( literal / "") colon) { return { type: "rule_ref", name: $1 }; }
|
||||
/ literal { return { type: "literal", value: $1 }; }
|
||||
/ dot { return { type: "any" }; }
|
||||
/ class { return { type: "class", characters: $1 }; }
|
||||
: identifier !(( literal / "") colon) { return { type: "rule_ref", name: $1 }; }
|
||||
/ literal { return { type: "literal", value: $1 }; }
|
||||
/ dot { return { type: "any" }; }
|
||||
/ class { return { type: "class", chars: $1 }; }
|
||||
/ lparen expression rparen { return $2; }
|
||||
|
||||
/* "Lexical" elements */
|
||||
|
|
|
@ -81,10 +81,10 @@ function any() {
|
|||
return { type: "any" };
|
||||
}
|
||||
|
||||
function klass(characters) {
|
||||
function klass(chars) {
|
||||
return {
|
||||
type: "class",
|
||||
characters: characters
|
||||
type: "class",
|
||||
chars: chars
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue