Code style: Fix ESLint "indent" errors

Part of #407.
redux
David Majda 8 years ago
parent e61ae59681
commit fd07f64637

@ -14,11 +14,11 @@ function generateJS(ast, options) {
if (options.optimize === "size") { if (options.optimize === "size") {
return [ return [
"var peg$consts = [", "var peg$consts = [",
indent2(ast.consts.join(",\n")), indent2(ast.consts.join(",\n")),
"];", "];",
"", "",
"var peg$bytecode = [", "var peg$bytecode = [",
indent2(ast.rules.map(rule => indent2(ast.rules.map(rule =>
"peg$decode(\"" "peg$decode(\""
+ js.stringEscape(rule.bytecode.map( + js.stringEscape(rule.bytecode.map(
b => String.fromCharCode(b + 32) b => String.fromCharCode(b + 32)
@ -296,40 +296,40 @@ function generateJS(ast, options) {
" break;", " break;",
"", "",
" case " + op.IF + ":", // IF t, f " case " + op.IF + ":", // IF t, f
indent10(generateCondition("stack[stack.length - 1]", 0)), indent10(generateCondition("stack[stack.length - 1]", 0)),
"", "",
" case " + op.IF_ERROR + ":", // IF_ERROR t, f " case " + op.IF_ERROR + ":", // IF_ERROR t, f
indent10(generateCondition( indent10(generateCondition(
"stack[stack.length - 1] === peg$FAILED", "stack[stack.length - 1] === peg$FAILED",
0 0
)), )),
"", "",
" case " + op.IF_NOT_ERROR + ":", // IF_NOT_ERROR t, f " case " + op.IF_NOT_ERROR + ":", // IF_NOT_ERROR t, f
indent10( indent10(
generateCondition("stack[stack.length - 1] !== peg$FAILED", generateCondition("stack[stack.length - 1] !== peg$FAILED",
0 0
)), )),
"", "",
" case " + op.WHILE_NOT_ERROR + ":", // WHILE_NOT_ERROR b " case " + op.WHILE_NOT_ERROR + ":", // WHILE_NOT_ERROR b
indent10(generateLoop("stack[stack.length - 1] !== peg$FAILED")), indent10(generateLoop("stack[stack.length - 1] !== peg$FAILED")),
"", "",
" case " + op.MATCH_ANY + ":", // MATCH_ANY a, f, ... " case " + op.MATCH_ANY + ":", // MATCH_ANY a, f, ...
indent10(generateCondition("input.length > peg$currPos", 0)), indent10(generateCondition("input.length > peg$currPos", 0)),
"", "",
" case " + op.MATCH_STRING + ":", // MATCH_STRING s, a, f, ... " case " + op.MATCH_STRING + ":", // MATCH_STRING s, a, f, ...
indent10(generateCondition( indent10(generateCondition(
"input.substr(peg$currPos, peg$consts[bc[ip + 1]].length) === peg$consts[bc[ip + 1]]", "input.substr(peg$currPos, peg$consts[bc[ip + 1]].length) === peg$consts[bc[ip + 1]]",
1 1
)), )),
"", "",
" case " + op.MATCH_STRING_IC + ":", // MATCH_STRING_IC s, a, f, ... " case " + op.MATCH_STRING_IC + ":", // MATCH_STRING_IC s, a, f, ...
indent10(generateCondition( indent10(generateCondition(
"input.substr(peg$currPos, peg$consts[bc[ip + 1]].length).toLowerCase() === peg$consts[bc[ip + 1]]", "input.substr(peg$currPos, peg$consts[bc[ip + 1]].length).toLowerCase() === peg$consts[bc[ip + 1]]",
1 1
)), )),
"", "",
" case " + op.MATCH_REGEXP + ":", // MATCH_REGEXP r, a, f, ... " case " + op.MATCH_REGEXP + ":", // MATCH_REGEXP r, a, f, ...
indent10(generateCondition( indent10(generateCondition(
"peg$consts[bc[ip + 1]].test(input.charAt(peg$currPos))", "peg$consts[bc[ip + 1]].test(input.charAt(peg$currPos))",
1 1
)), )),
@ -365,7 +365,7 @@ function generateJS(ast, options) {
" break;", " break;",
"", "",
" case " + op.CALL + ":", // CALL f, n, pc, p1, p2, ..., pN " case " + op.CALL + ":", // CALL f, n, pc, p1, p2, ..., pN
indent10(generateCall()), indent10(generateCall()),
"", "",
" case " + op.RULE + ":", // RULE r " case " + op.RULE + ":", // RULE r
" stack.push(peg$parseRule(bc[ip + 1]));", " stack.push(peg$parseRule(bc[ip + 1]));",
@ -1208,18 +1208,18 @@ function generateJS(ast, options) {
function generateParserObject() { function generateParserObject() {
return options.trace return options.trace
? [ ? [
"{", "{",
" SyntaxError: peg$SyntaxError,", " SyntaxError: peg$SyntaxError,",
" DefaultTracer: peg$DefaultTracer,", " DefaultTracer: peg$DefaultTracer,",
" parse: peg$parse", " parse: peg$parse",
"}" "}"
].join("\n") ].join("\n")
: [ : [
"{", "{",
" SyntaxError: peg$SyntaxError,", " SyntaxError: peg$SyntaxError,",
" parse: peg$parse", " parse: peg$parse",
"}" "}"
].join("\n"); ].join("\n");
} }
let generators = { let generators = {
@ -1229,9 +1229,9 @@ function generateJS(ast, options) {
"(function() {", "(function() {",
" \"use strict\";", " \"use strict\";",
"", "",
indent2(toplevelCode), indent2(toplevelCode),
"", "",
indent2("return " + generateParserObject() + ";"), indent2("return " + generateParserObject() + ";"),
"})()" "})()"
].join("\n"); ].join("\n");
}, },
@ -1283,9 +1283,9 @@ function generateJS(ast, options) {
"define(" + dependencies + ", function(" + params + ") {", "define(" + dependencies + ", function(" + params + ") {",
" \"use strict\";", " \"use strict\";",
"", "",
indent2(toplevelCode), indent2(toplevelCode),
"", "",
indent2("return " + generateParserObject() + ";"), indent2("return " + generateParserObject() + ";"),
"});", "});",
"" ""
].join("\n"); ].join("\n");
@ -1297,9 +1297,9 @@ function generateJS(ast, options) {
"(function(root) {", "(function(root) {",
" \"use strict\";", " \"use strict\";",
"", "",
indent2(toplevelCode), indent2(toplevelCode),
"", "",
indent2("root." + options.exportVar + " = " + generateParserObject() + ";"), indent2("root." + options.exportVar + " = " + generateParserObject() + ";"),
"})(this);", "})(this);",
"" ""
].join("\n"); ].join("\n");
@ -1340,9 +1340,9 @@ function generateJS(ast, options) {
"})(this, function(" + params + ") {", "})(this, function(" + params + ") {",
" \"use strict\";", " \"use strict\";",
"", "",
indent2(toplevelCode), indent2(toplevelCode),
"", "",
indent2("return " + generateParserObject() + ";"), indent2("return " + generateParserObject() + ";"),
"});", "});",
"" ""
].join("\n")); ].join("\n"));

Loading…
Cancel
Save