diff --git a/src/emitter.js b/src/emitter.js index 749be3a..bb93232 100644 --- a/src/emitter.js +++ b/src/emitter.js @@ -269,7 +269,7 @@ PEG.compiler.emitter = function(ast) { ' */', ' parse: function(input, startRule) {', ' var parseFunctions = {', - ' #block parseFunctionTableItems', + ' #block parseFunctionTableItems.join(",\\n")', ' };', ' ', ' if (startRule !== undefined) {', @@ -352,8 +352,10 @@ PEG.compiler.emitter = function(ast) { ' rightmostFailuresExpected.push(failure);', ' }', ' ', - ' #block parseFunctionDefinitions', - ' ', + ' #for definition in parseFunctionDefinitions', + ' #block definition', + ' ', + ' #end', ' function buildErrorMessage() {', ' function buildExpected(failuresExpected) {', ' failuresExpected.sort();', @@ -419,7 +421,9 @@ PEG.compiler.emitter = function(ast) { ' return { line: line, column: column };', ' }', ' ', - ' #block initializerCode', + ' #if initializerCode !== ""', + ' #block initializerCode', + ' #end', ' ', ' var result = parseFunctions[startRule]();', ' ', @@ -478,8 +482,8 @@ PEG.compiler.emitter = function(ast) { '})()', { initializerCode: initializerCode, - parseFunctionTableItems: parseFunctionTableItems.join(',\n'), - parseFunctionDefinitions: parseFunctionDefinitions.join('\n\n'), + parseFunctionTableItems: parseFunctionTableItems, + parseFunctionDefinitions: parseFunctionDefinitions, startRule: node.startRule } ); diff --git a/src/parser.js b/src/parser.js index 67aeb24..030f99c 100644 --- a/src/parser.js +++ b/src/parser.js @@ -3511,7 +3511,6 @@ PEG.parser = (function(){ } - var result = parseFunctions[startRule](); /*