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
|
* Stupid IE considers regexps /[]/ and /[^]/ syntactically invalid, so we
|
||||||
* translate them into euqivalents it can handle.
|
* translate them into euqivalents it can handle.
|
||||||
*/
|
*/
|
||||||
if (node.characters === "") {
|
if (node.chars === "") {
|
||||||
var regexp = "/^(?!)/";
|
var regexp = "/^(?!)/";
|
||||||
} else if (node.characters === "^") {
|
} else if (node.chars === "^") {
|
||||||
var regexp = "/^[\\S\\s]/";
|
var regexp = "/^[\\S\\s]/";
|
||||||
} else {
|
} else {
|
||||||
var regexp = "/^[" + node.characters + "]/";
|
var regexp = "/^[" + node.chars + "]/";
|
||||||
}
|
}
|
||||||
|
|
||||||
return PEG.Compiler.formatCode(
|
return PEG.Compiler.formatCode(
|
||||||
|
@ -742,11 +742,11 @@ PEG.Compiler = {
|
||||||
"} else {",
|
"} else {",
|
||||||
" var ${resultVar} = null;",
|
" var ${resultVar} = null;",
|
||||||
" if (context.reportMatchFailures) {",
|
" if (context.reportMatchFailures) {",
|
||||||
" this._matchFailed('[' + ${characters|string} + ']');",
|
" this._matchFailed('[' + ${chars|string} + ']');",
|
||||||
" }",
|
" }",
|
||||||
"}",
|
"}",
|
||||||
{
|
{
|
||||||
characters: node.characters,
|
chars: node.chars,
|
||||||
regexp: regexp,
|
regexp: regexp,
|
||||||
resultVar: resultVar
|
resultVar: resultVar
|
||||||
}
|
}
|
||||||
|
|
|
@ -603,7 +603,7 @@ PEG.grammarParser = (function(){
|
||||||
} else {
|
} else {
|
||||||
var result61 = this._parse_class(context);
|
var result61 = this._parse_class(context);
|
||||||
var result60 = result61 !== null
|
var result60 = result61 !== null
|
||||||
? (function($1) { return { type: "class", characters: $1 }; })(result61)
|
? (function($1) { return { type: "class", chars: $1 }; })(result61)
|
||||||
: null;
|
: null;
|
||||||
if (result60 !== null) {
|
if (result60 !== null) {
|
||||||
var result54 = result60;
|
var result54 = result60;
|
||||||
|
|
|
@ -68,7 +68,7 @@ primary
|
||||||
: identifier !(( literal / "") colon) { return { type: "rule_ref", name: $1 }; }
|
: identifier !(( literal / "") colon) { return { type: "rule_ref", name: $1 }; }
|
||||||
/ literal { return { type: "literal", value: $1 }; }
|
/ literal { return { type: "literal", value: $1 }; }
|
||||||
/ dot { return { type: "any" }; }
|
/ dot { return { type: "any" }; }
|
||||||
/ class { return { type: "class", characters: $1 }; }
|
/ class { return { type: "class", chars: $1 }; }
|
||||||
/ lparen expression rparen { return $2; }
|
/ lparen expression rparen { return $2; }
|
||||||
|
|
||||||
/* "Lexical" elements */
|
/* "Lexical" elements */
|
||||||
|
|
|
@ -81,10 +81,10 @@ function any() {
|
||||||
return { type: "any" };
|
return { type: "any" };
|
||||||
}
|
}
|
||||||
|
|
||||||
function klass(characters) {
|
function klass(chars) {
|
||||||
return {
|
return {
|
||||||
type: "class",
|
type: "class",
|
||||||
characters: characters
|
chars: chars
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue