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

@ -89,7 +89,7 @@ PEG.grammarParser = (function(){
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;
@ -164,7 +164,7 @@ PEG.grammarParser = (function(){
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;
@ -246,7 +246,7 @@ PEG.grammarParser = (function(){
} else { } else {
return head; return head;
} }
})(result14[0], result14[1]) })(result14[0], result14[1])
: null; : null;
@ -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;
@ -320,7 +320,7 @@ PEG.grammarParser = (function(){
elements: elements elements: elements
} }
: elements[0]; : elements[0];
})(result22) })(result22)
: null; : null;
if (result21 !== null) { if (result21 !== null) {
var result20 = result21; var result20 = result21;
@ -376,7 +376,7 @@ PEG.grammarParser = (function(){
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;
@ -429,7 +429,7 @@ PEG.grammarParser = (function(){
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;
@ -454,7 +454,7 @@ PEG.grammarParser = (function(){
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;
@ -508,7 +508,7 @@ PEG.grammarParser = (function(){
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;
@ -533,7 +533,7 @@ PEG.grammarParser = (function(){
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;
@ -558,7 +558,7 @@ PEG.grammarParser = (function(){
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;
@ -654,7 +654,7 @@ PEG.grammarParser = (function(){
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;
@ -666,14 +666,14 @@ PEG.grammarParser = (function(){
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) {
@ -840,7 +840,7 @@ PEG.grammarParser = (function(){
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;
@ -1565,7 +1565,7 @@ PEG.grammarParser = (function(){
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;
@ -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) {
@ -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;
@ -2248,7 +2248,7 @@ PEG.grammarParser = (function(){
// 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;
@ -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;
@ -2611,7 +2611,7 @@ PEG.grammarParser = (function(){
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;
@ -2677,7 +2677,7 @@ PEG.grammarParser = (function(){
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;