From 46ac1bf1716df461f1fc4f99540f8e9b26155e76 Mon Sep 17 00:00:00 2001 From: David Majda Date: Tue, 22 Apr 2014 07:37:08 +0200 Subject: [PATCH] Wrap initializer code in generated parsers into |{...}| Initializer code is usually indented and this indentation is carried over to generated code. This resulted in a piece of indented code in the middle of the parser. This commit wraps initializer code in |{...}|, which makes indentation in generated parsers look a bit more natural. --- .jshintrc | 3 ++- lib/compiler/passes/generate-javascript.js | 2 +- lib/parser.js | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.jshintrc b/.jshintrc index 10a6bfc..fab2850 100644 --- a/.jshintrc +++ b/.jshintrc @@ -10,5 +10,6 @@ "noarg": true, "noempty": true, "nonew": true, - "trailing": true + "trailing": true, + "-W082": false } diff --git a/lib/compiler/passes/generate-javascript.js b/lib/compiler/passes/generate-javascript.js index 3e68abc..ad6de1d 100644 --- a/lib/compiler/passes/generate-javascript.js +++ b/lib/compiler/passes/generate-javascript.js @@ -951,7 +951,7 @@ module.exports = function(ast, options) { } if (ast.initializer) { - parts.push(indent4(ast.initializer.code)); + parts.push(indent4("{" + ast.initializer.code + "}")); parts.push(''); } diff --git a/lib/parser.js b/lib/parser.js index de84adf..72dfcfe 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -4836,7 +4836,7 @@ module.exports = (function() { return s0; } - + { var OPS_TO_PREFIXED_TYPES = { "$": "text", "&": "simple_and", @@ -4883,7 +4883,7 @@ module.exports = (function() { function buildList(first, rest, index) { return [first].concat(extractList(rest, index)); } - + } peg$result = peg$startRuleFunction();