Simplify code which generates parser wrappers

redux
David Majda 9 years ago
parent f390c7cf45
commit f934199fba

@ -1171,17 +1171,15 @@ function generateJS(ast, options) {
var generators = {
bare: function() {
var parts = [];
parts.push('(function() {');
parts.push(indent2(generateIntro()));
parts.push('');
parts.push(indent2(toplevelCode));
parts.push('');
parts.push(indent2('return ' + generateParserObject() + ';'));
parts.push('})()');
return parts.join('\n');
return [
'(function() {',
indent2(generateIntro()),
'',
indent2(toplevelCode),
'',
indent2('return ' + generateParserObject() + ';'),
'})()'
].join('\n');
},
umd: function() {
@ -1217,16 +1215,12 @@ function generateJS(ast, options) {
parts.push([
' }',
'})(this, function(' + params + ') {'
].join('\n'));
parts.push(indent2(generateIntro()));
parts.push('');
parts.push(indent2(toplevelCode));
parts.push('');
parts.push(indent2('return ' + generateParserObject() + ';'));
parts.push([
'})(this, function(' + params + ') {',
indent2(generateIntro()),
'',
indent2(toplevelCode),
'',
indent2('return ' + generateParserObject() + ';'),
'});',
''
].join('\n'));

Loading…
Cancel
Save