Formatting

redux
David Majda 10 years ago
parent f03ba4bf4f
commit 85c8f386c1

@ -205,7 +205,7 @@ function generateBytecode(ast) {
} }
function buildCall(functionIndex, delta, env, sp) { function buildCall(functionIndex, delta, env, sp) {
var params = arrays.map( objects.values(env), function(p) { return sp - p; }); var params = arrays.map(objects.values(env), function(p) { return sp - p; });
return [op.CALL, functionIndex, delta, params.length].concat(params); return [op.CALL, functionIndex, delta, params.length].concat(params);
} }

@ -19,17 +19,14 @@ function generateJavascript(ast, options) {
'],', '],',
'', '',
'peg$bytecode = [', 'peg$bytecode = [',
indent2(arrays.map( indent2(arrays.map(ast.rules, function(rule) {
ast.rules, return 'peg$decode("'
function(rule) { + js.stringEscape(arrays.map(
return 'peg$decode("' rule.bytecode,
+ js.stringEscape(arrays.map( function(b) { return String.fromCharCode(b + 32); }
rule.bytecode, ).join(''))
function(b) { return String.fromCharCode(b + 32); } + '")';
).join('')) }).join(',\n')),
+ '")';
}
).join(',\n')),
'],' '],'
].join('\n'); ].join('\n');
} else { } else {

@ -18,9 +18,7 @@ function removeProxyRules(ast, options) {
function replaceInSubnodes(propertyName) { function replaceInSubnodes(propertyName) {
return function(node, from, to) { return function(node, from, to) {
arrays.each(node[propertyName], function(subnode) { arrays.each(node[propertyName], function(n) { replace(n, from, to); });
replace(subnode, from, to);
});
}; };
} }
@ -69,9 +67,7 @@ function removeProxyRules(ast, options) {
indices.reverse(); indices.reverse();
arrays.each(indices, function(index) { arrays.each(indices, function(i) { ast.rules.splice(i, 1); });
ast.rules.splice(index, 1);
});
} }
module.exports = removeProxyRules; module.exports = removeProxyRules;

@ -13,9 +13,7 @@ function reportLeftRecursion(ast) {
function checkSubnodes(propertyName) { function checkSubnodes(propertyName) {
return function(node, appliedRules) { return function(node, appliedRules) {
arrays.each(node[propertyName], function(subnode) { arrays.each(node[propertyName], function(n) { check(n, appliedRules); });
check(subnode, appliedRules);
});
}; };
} }

Loading…
Cancel
Save