Utility functions cleanup: Cleanup lib/compiler/visitor.js

redux
David Majda 10 years ago
parent bfaad70899
commit c1e1502d43

@ -268,7 +268,7 @@ function generateBytecode(ast) {
);
}
var generate = visitor.buildNodeVisitor({
var generate = visitor.build({
grammar: function(node) {
arrays.each(node.rules, generate);

@ -24,7 +24,7 @@ function removeProxyRules(ast, options) {
};
}
var replace = visitor.buildNodeVisitor({
var replace = visitor.build({
grammar: replaceInSubnodes("rules"),
rule: replaceInExpression,
named: replaceInExpression,

@ -19,7 +19,7 @@ function reportLeftRecursion(ast) {
};
}
var check = visitor.buildNodeVisitor({
var check = visitor.build({
grammar: checkSubnodes("rules"),
rule:

@ -13,7 +13,7 @@ function reportMissingRules(ast) {
return function(node) { arrays.each(node[propertyName], check); };
}
var check = visitor.buildNodeVisitor({
var check = visitor.build({
grammar: checkSubnodes("rules"),
rule: checkExpression,
named: checkExpression,

@ -1,13 +1,6 @@
/* Simple AST node visitor builder. */
var visitor = {
/*
* Builds a node visitor -- a function which takes a node and any number of
* other parameters, calls an appropriate function according to the node type,
* passes it all its parameters and returns its value. The functions for
* various node types are passed in a parameter to |buildNodeVisitor| as a
* hash.
*/
buildNodeVisitor: function(functions) {
build: function(functions) {
return function(node) {
return functions[node.type].apply(null, arguments);
};

Loading…
Cancel
Save