Emit little bit less whitespace in actions

This commit is contained in:
David Majda 2010-06-07 10:45:26 +02:00
parent ee8c121676
commit 7d4911ec53
2 changed files with 66 additions and 66 deletions

View file

@ -746,7 +746,7 @@ PEG.Compiler = {
return PEG.Compiler.formatCode( return PEG.Compiler.formatCode(
"${expressionCode}", "${expressionCode}",
"var ${resultVar} = ${expressionResultVar} !== null", "var ${resultVar} = ${expressionResultVar} !== null",
" ? (function(${formalParams}) { ${action} })(${actualParams})", " ? (function(${formalParams}) {${action}})(${actualParams})",
" : null;", " : null;",
{ {
expressionCode: PEG.Compiler.compileNode(node.expression, expressionResultVar), expressionCode: PEG.Compiler.compileNode(node.expression, expressionResultVar),

View file

@ -85,11 +85,11 @@ PEG.grammarParser = (function(){
this._pos = savedPos0; this._pos = savedPos0;
} }
var result0 = result1 !== null var result0 = result1 !== null
? (function(rules) { ? (function(rules) {
var result = {}; var result = {};
PEG.ArrayUtils.each(rules, function(rule) { result[rule.name] = rule; }); PEG.ArrayUtils.each(rules, function(rule) { result[rule.name] = rule; });
return result; return result;
})(result1[1]) })(result1[1])
: null; : null;
@ -157,14 +157,14 @@ PEG.grammarParser = (function(){
this._pos = savedPos1; this._pos = savedPos1;
} }
var result5 = result6 !== null var result5 = result6 !== null
? (function(name, displayName, expression) { ? (function(name, displayName, expression) {
return { return {
type: "rule", type: "rule",
name: name, name: name,
displayName: displayName !== "" ? displayName : null, displayName: displayName !== "" ? displayName : null,
expression: expression expression: expression
}; };
})(result6[0], result6[1], result6[3]) })(result6[0], result6[1], result6[3])
: null; : null;
@ -233,7 +233,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos2; this._pos = savedPos2;
} }
var result13 = result14 !== null var result13 = result14 !== null
? (function(head, tail) { ? (function(head, tail) {
if (tail.length > 0) { if (tail.length > 0) {
var alternatives = [head].concat(PEG.ArrayUtils.map( var alternatives = [head].concat(PEG.ArrayUtils.map(
tail, tail,
@ -246,7 +246,7 @@ PEG.grammarParser = (function(){
} else { } else {
return head; return head;
} }
})(result14[0], result14[1]) })(result14[0], result14[1])
: null; : null;
@ -289,7 +289,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos4; this._pos = savedPos4;
} }
var result24 = result25 !== null var result24 = result25 !== null
? (function(elements, action) { ? (function(elements, action) {
var expression = elements.length != 1 var expression = elements.length != 1
? { ? {
type: "sequence", type: "sequence",
@ -301,7 +301,7 @@ PEG.grammarParser = (function(){
expression: expression, expression: expression,
action: action action: action
}; };
})(result25[0], result25[1]) })(result25[0], result25[1])
: null; : null;
if (result24 !== null) { if (result24 !== null) {
var result20 = result24; var result20 = result24;
@ -313,14 +313,14 @@ PEG.grammarParser = (function(){
var result23 = this._parse_labeled(context); var result23 = this._parse_labeled(context);
} }
var result21 = result22 !== null var result21 = result22 !== null
? (function(elements) { ? (function(elements) {
return elements.length != 1 return elements.length != 1
? { ? {
type: "sequence", type: "sequence",
elements: elements elements: elements
} }
: elements[0]; : elements[0];
})(result22) })(result22)
: null; : null;
if (result21 !== null) { if (result21 !== null) {
var result20 = result21; var result20 = result21;
@ -370,13 +370,13 @@ PEG.grammarParser = (function(){
this._pos = savedPos5; this._pos = savedPos5;
} }
var result31 = result32 !== null var result31 = result32 !== null
? (function(label, expression) { ? (function(label, expression) {
return { return {
type: "labeled", type: "labeled",
label: label, label: label,
expression: expression expression: expression
}; };
})(result32[0], result32[2]) })(result32[0], result32[2])
: null; : null;
if (result31 !== null) { if (result31 !== null) {
var result29 = result31; var result29 = result31;
@ -424,12 +424,12 @@ PEG.grammarParser = (function(){
this._pos = savedPos7; this._pos = savedPos7;
} }
var result42 = result43 !== null var result42 = result43 !== null
? (function(expression) { ? (function(expression) {
return { return {
type: "and_predicate", type: "and_predicate",
expression: expression expression: expression
}; };
})(result43[1]) })(result43[1])
: null; : null;
if (result42 !== null) { if (result42 !== null) {
var result36 = result42; var result36 = result42;
@ -449,12 +449,12 @@ PEG.grammarParser = (function(){
this._pos = savedPos6; this._pos = savedPos6;
} }
var result38 = result39 !== null var result38 = result39 !== null
? (function(expression) { ? (function(expression) {
return { return {
type: "not_predicate", type: "not_predicate",
expression: expression expression: expression
}; };
})(result39[1]) })(result39[1])
: null; : null;
if (result38 !== null) { if (result38 !== null) {
var result36 = result38; var result36 = result38;
@ -503,12 +503,12 @@ PEG.grammarParser = (function(){
this._pos = savedPos10; this._pos = savedPos10;
} }
var result56 = result57 !== null var result56 = result57 !== null
? (function(expression) { ? (function(expression) {
return { return {
type: "optional", type: "optional",
expression: expression expression: expression
}; };
})(result57[0]) })(result57[0])
: null; : null;
if (result56 !== null) { if (result56 !== null) {
var result46 = result56; var result46 = result56;
@ -528,12 +528,12 @@ PEG.grammarParser = (function(){
this._pos = savedPos9; this._pos = savedPos9;
} }
var result52 = result53 !== null var result52 = result53 !== null
? (function(expression) { ? (function(expression) {
return { return {
type: "zero_or_more", type: "zero_or_more",
expression: expression expression: expression
}; };
})(result53[0]) })(result53[0])
: null; : null;
if (result52 !== null) { if (result52 !== null) {
var result46 = result52; var result46 = result52;
@ -553,12 +553,12 @@ PEG.grammarParser = (function(){
this._pos = savedPos8; this._pos = savedPos8;
} }
var result48 = result49 !== null var result48 = result49 !== null
? (function(expression) { ? (function(expression) {
return { return {
type: "one_or_more", type: "one_or_more",
expression: expression expression: expression
}; };
})(result49[0]) })(result49[0])
: null; : null;
if (result48 !== null) { if (result48 !== null) {
var result46 = result48; var result46 = result48;
@ -649,31 +649,31 @@ PEG.grammarParser = (function(){
this._pos = savedPos12; this._pos = savedPos12;
} }
var result71 = result72 !== null var result71 = result72 !== null
? (function(name) { ? (function(name) {
return { return {
type: "rule_ref", type: "rule_ref",
name: name name: name
}; };
})(result72[0]) })(result72[0])
: null; : null;
if (result71 !== null) { if (result71 !== null) {
var result60 = result71; var result60 = result71;
} else { } else {
var result70 = this._parse_literal(context); var result70 = this._parse_literal(context);
var result69 = result70 !== null var result69 = result70 !== null
? (function(value) { ? (function(value) {
return { return {
type: "literal", type: "literal",
value: value value: value
}; };
})(result70) })(result70)
: null; : null;
if (result69 !== null) { if (result69 !== null) {
var result60 = result69; var result60 = result69;
} else { } else {
var result68 = this._parse_dot(context); var result68 = this._parse_dot(context);
var result67 = result68 !== null var result67 = result68 !== null
? (function() { return { type: "any" }; })() ? (function() { return { type: "any" }; })()
: null; : null;
if (result67 !== null) { if (result67 !== null) {
var result60 = result67; var result60 = result67;
@ -703,7 +703,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos11; this._pos = savedPos11;
} }
var result61 = result62 !== null var result61 = result62 !== null
? (function(expression) { return expression; })(result62[1]) ? (function(expression) { return expression; })(result62[1])
: null; : null;
if (result61 !== null) { if (result61 !== null) {
var result60 = result61; var result60 = result61;
@ -751,7 +751,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos15; this._pos = savedPos15;
} }
var result80 = result81 !== null var result80 = result81 !== null
? (function(braced) { return braced.substr(1, braced.length - 2); })(result81[0]) ? (function(braced) { return braced.substr(1, braced.length - 2); })(result81[0])
: null; : null;
context.reportMatchFailures = savedReportMatchFailures; context.reportMatchFailures = savedReportMatchFailures;
if (context.reportMatchFailures && result80 === null) { if (context.reportMatchFailures && result80 === null) {
@ -838,9 +838,9 @@ PEG.grammarParser = (function(){
this._pos = savedPos16; this._pos = savedPos16;
} }
var result84 = result85 !== null var result84 = result85 !== null
? (function(parts) { ? (function(parts) {
return "{" + parts.join("") + "}"; return "{" + parts.join("") + "}";
})(result85[1]) })(result85[1])
: null; : null;
@ -874,7 +874,7 @@ PEG.grammarParser = (function(){
var result93 = null; var result93 = null;
} }
var result92 = result93 !== null var result92 = result93 !== null
? (function(chars) { return chars.join(""); })(result93) ? (function(chars) { return chars.join(""); })(result93)
: null; : null;
@ -950,7 +950,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos17; this._pos = savedPos17;
} }
var result96 = result97 !== null var result96 = result97 !== null
? (function() { return "="; })() ? (function() { return "="; })()
: null; : null;
@ -996,7 +996,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos18; this._pos = savedPos18;
} }
var result100 = result101 !== null var result100 = result101 !== null
? (function() { return ":"; })() ? (function() { return ":"; })()
: null; : null;
@ -1042,7 +1042,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos19; this._pos = savedPos19;
} }
var result104 = result105 !== null var result104 = result105 !== null
? (function() { return "/"; })() ? (function() { return "/"; })()
: null; : null;
@ -1088,7 +1088,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos20; this._pos = savedPos20;
} }
var result108 = result109 !== null var result108 = result109 !== null
? (function() { return "&"; })() ? (function() { return "&"; })()
: null; : null;
@ -1134,7 +1134,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos21; this._pos = savedPos21;
} }
var result112 = result113 !== null var result112 = result113 !== null
? (function() { return "!"; })() ? (function() { return "!"; })()
: null; : null;
@ -1180,7 +1180,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos22; this._pos = savedPos22;
} }
var result116 = result117 !== null var result116 = result117 !== null
? (function() { return "?"; })() ? (function() { return "?"; })()
: null; : null;
@ -1226,7 +1226,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos23; this._pos = savedPos23;
} }
var result120 = result121 !== null var result120 = result121 !== null
? (function() { return "*"; })() ? (function() { return "*"; })()
: null; : null;
@ -1272,7 +1272,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos24; this._pos = savedPos24;
} }
var result124 = result125 !== null var result124 = result125 !== null
? (function() { return "+"; })() ? (function() { return "+"; })()
: null; : null;
@ -1318,7 +1318,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos25; this._pos = savedPos25;
} }
var result128 = result129 !== null var result128 = result129 !== null
? (function() { return "("; })() ? (function() { return "("; })()
: null; : null;
@ -1364,7 +1364,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos26; this._pos = savedPos26;
} }
var result132 = result133 !== null var result132 = result133 !== null
? (function() { return ")"; })() ? (function() { return ")"; })()
: null; : null;
@ -1410,7 +1410,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos27; this._pos = savedPos27;
} }
var result136 = result137 !== null var result136 = result137 !== null
? (function() { return "."; })() ? (function() { return "."; })()
: null; : null;
@ -1563,9 +1563,9 @@ PEG.grammarParser = (function(){
this._pos = savedPos28; this._pos = savedPos28;
} }
var result140 = result141 !== null var result140 = result141 !== null
? (function(head, tail) { ? (function(head, tail) {
return head + tail.join(""); return head + tail.join("");
})(result141[0], result141[1]) })(result141[0], result141[1])
: null; : null;
context.reportMatchFailures = savedReportMatchFailures; context.reportMatchFailures = savedReportMatchFailures;
if (context.reportMatchFailures && result140 === null) { if (context.reportMatchFailures && result140 === null) {
@ -1616,7 +1616,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos29; this._pos = savedPos29;
} }
var result153 = result154 !== null var result153 = result154 !== null
? (function(literal) { return literal; })(result154[0]) ? (function(literal) { return literal; })(result154[0])
: null; : null;
context.reportMatchFailures = savedReportMatchFailures; context.reportMatchFailures = savedReportMatchFailures;
if (context.reportMatchFailures && result153 === null) { if (context.reportMatchFailures && result153 === null) {
@ -1683,7 +1683,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos30; this._pos = savedPos30;
} }
var result159 = result160 !== null var result159 = result160 !== null
? (function(chars) { return chars.join(""); })(result160[1]) ? (function(chars) { return chars.join(""); })(result160[1])
: null; : null;
@ -1822,7 +1822,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos31; this._pos = savedPos31;
} }
var result172 = result173 !== null var result172 = result173 !== null
? (function(char_) { return char_; })(result173[1]) ? (function(char_) { return char_; })(result173[1])
: null; : null;
@ -1887,7 +1887,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos33; this._pos = savedPos33;
} }
var result180 = result181 !== null var result180 = result181 !== null
? (function(chars) { return chars.join(""); })(result181[1]) ? (function(chars) { return chars.join(""); })(result181[1])
: null; : null;
@ -2026,7 +2026,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos34; this._pos = savedPos34;
} }
var result193 = result194 !== null var result193 = result194 !== null
? (function(char_) { return char_; })(result194[1]) ? (function(char_) { return char_; })(result194[1])
: null; : null;
@ -2133,7 +2133,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos36; this._pos = savedPos36;
} }
var result201 = result202 !== null var result201 = result202 !== null
? (function(inverted, parts) { ? (function(inverted, parts) {
partsConverted = PEG.ArrayUtils.map(parts, function(part) { partsConverted = PEG.ArrayUtils.map(parts, function(part) {
return part.data; return part.data;
}); });
@ -2151,7 +2151,7 @@ PEG.grammarParser = (function(){
// FIXME: Get the raw text from the input directly. // FIXME: Get the raw text from the input directly.
rawText: rawText rawText: rawText
}; };
})(result202[1], result202[2]) })(result202[1], result202[2])
: null; : null;
context.reportMatchFailures = savedReportMatchFailures; context.reportMatchFailures = savedReportMatchFailures;
if (context.reportMatchFailures && result201 === null) { if (context.reportMatchFailures && result201 === null) {
@ -2205,7 +2205,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos37; this._pos = savedPos37;
} }
var result212 = result213 !== null var result212 = result213 !== null
? (function(begin, end) { ? (function(begin, end) {
if (begin.data.charCodeAt(0) > end.data.charCodeAt(0)) { if (begin.data.charCodeAt(0) > end.data.charCodeAt(0)) {
throw new this.SyntaxError( throw new this.SyntaxError(
"Invalid character range: " + begin.rawText + "-" + end.rawText + "." "Invalid character range: " + begin.rawText + "-" + end.rawText + "."
@ -2217,7 +2217,7 @@ PEG.grammarParser = (function(){
// FIXME: Get the raw text from the input directly. // FIXME: Get the raw text from the input directly.
rawText: begin.rawText + "-" + end.rawText rawText: begin.rawText + "-" + end.rawText
} }
})(result213[0], result213[2]) })(result213[0], result213[2])
: null; : null;
@ -2242,13 +2242,13 @@ PEG.grammarParser = (function(){
var result218 = this._parse_bracketDelimitedCharacter(context); var result218 = this._parse_bracketDelimitedCharacter(context);
var result217 = result218 !== null var result217 = result218 !== null
? (function(char_) { ? (function(char_) {
return { return {
data: char_, data: char_,
// FIXME: Get the raw text from the input directly. // FIXME: Get the raw text from the input directly.
rawText: PEG.RegExpUtils.quoteForClass(char_) rawText: PEG.RegExpUtils.quoteForClass(char_)
}; };
})(result218) })(result218)
: null; : null;
@ -2387,7 +2387,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos38; this._pos = savedPos38;
} }
var result226 = result227 !== null var result226 = result227 !== null
? (function(char_) { return char_; })(result227[1]) ? (function(char_) { return char_; })(result227[1])
: null; : null;
@ -2493,7 +2493,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos40; this._pos = savedPos40;
} }
var result234 = result235 !== null var result234 = result235 !== null
? (function(char_) { ? (function(char_) {
return char_ return char_
.replace("b", "\b") .replace("b", "\b")
.replace("f", "\f") .replace("f", "\f")
@ -2501,7 +2501,7 @@ PEG.grammarParser = (function(){
.replace("r", "\r") .replace("r", "\r")
.replace("t", "\t") .replace("t", "\t")
.replace("v", "\x0B") // IE does not recognize "\v". .replace("v", "\x0B") // IE does not recognize "\v".
})(result235[2]) })(result235[2])
: null; : null;
@ -2557,7 +2557,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos42; this._pos = savedPos42;
} }
var result244 = result245 !== null var result244 = result245 !== null
? (function() { return "\0"; })() ? (function() { return "\0"; })()
: null; : null;
@ -2609,9 +2609,9 @@ PEG.grammarParser = (function(){
this._pos = savedPos44; this._pos = savedPos44;
} }
var result249 = result250 !== null var result249 = result250 !== null
? (function(h1, h2) { ? (function(h1, h2) {
return String.fromCharCode(parseInt("0x" + h1 + h2)); return String.fromCharCode(parseInt("0x" + h1 + h2));
})(result250[1], result250[2]) })(result250[1], result250[2])
: null; : null;
@ -2675,9 +2675,9 @@ PEG.grammarParser = (function(){
this._pos = savedPos45; this._pos = savedPos45;
} }
var result254 = result255 !== null var result254 = result255 !== null
? (function(h1, h2, h3, h4) { ? (function(h1, h2, h3, h4) {
return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4));
})(result255[1], result255[2], result255[3], result255[4]) })(result255[1], result255[2], result255[3], result255[4])
: null; : null;
@ -2723,7 +2723,7 @@ PEG.grammarParser = (function(){
this._pos = savedPos46; this._pos = savedPos46;
} }
var result261 = result262 !== null var result261 = result262 !== null
? (function(eol) { return eol; })(result262[1]) ? (function(eol) { return eol; })(result262[1])
: null; : null;