public TreeNode Execute(string func, params string[] declarations) { var functionDeclarationsFactory = new FunctionDeclarationsFactory(); var parser = new AstParser(functionDeclarationsFactory); foreach (var declaration in declarations) { var spl = declaration.Split(" = "); var funcName = spl[0]; var funcBody = spl[1]; var functionDeclaration = functionDeclarationsFactory.GetOrCreate(funcName); var body = parser.Parse(funcBody); functionDeclaration.Body = body; } var parsedFunc = parser.Parse(func); functionDeclarationsFactory.ValidateFullness(); return(AstReducer.Reduce(parsedFunc)); }
public AstParser(FunctionDeclarationsFactory functionDeclarationsFactory) { myFunctionDeclarationsFactory = functionDeclarationsFactory; }