From 137a4b4f533d10a5e48d0e2ac3b2a84b823c6ba0 Mon Sep 17 00:00:00 2001 From: David Majda Date: Fri, 21 May 2010 21:18:33 +0200 Subject: [PATCH] Renamed |characters| -> |chars| (shorter, no loss of expressivity) --- lib/compiler.js | 14 +++++++------- lib/metagrammar.js | 8 ++++---- lib/metagrammar.pegjs | 8 ++++---- test/metagrammar-test.js | 6 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index 7823a9b..5244299 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -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 } ); } diff --git a/lib/metagrammar.js b/lib/metagrammar.js index 2a8520b..e177585 100644 --- a/lib/metagrammar.js +++ b/lib/metagrammar.js @@ -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; diff --git a/lib/metagrammar.pegjs b/lib/metagrammar.pegjs index 6903414..6fb251e 100644 --- a/lib/metagrammar.pegjs +++ b/lib/metagrammar.pegjs @@ -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 */ diff --git a/test/metagrammar-test.js b/test/metagrammar-test.js index c0318c7..5d5b804 100644 --- a/test/metagrammar-test.js +++ b/test/metagrammar-test.js @@ -81,10 +81,10 @@ function any() { return { type: "any" }; } -function klass(characters) { +function klass(chars) { return { - type: "class", - characters: characters + type: "class", + chars: chars }; }