/// <inheritdoc/> public Func <Complex> Build(Node expression) { var instance = new ComplexILState(this); instance.FunctionFound += (sender, args) => FunctionFound?.Invoke(sender, args); instance.VariableFound += (sender, args) => VariableFound?.Invoke(sender, args); instance.Push(expression); return(instance.CreateFunction()); }
/// <inheritdoc/> public Func <double> Build(Node expression) { // Create a new instance that will be used to build the function var instance = new RealILState(this); instance.FunctionFound += (sender, args) => FunctionFound?.Invoke(sender, args); instance.VariableFound += (sender, args) => VariableFound?.Invoke(sender, args); instance.Push(expression); return(instance.CreateFunction()); }
/// <summary> /// Pushes a variable value on the value stack. /// </summary> /// <param name="name">The variable name.</param> protected override void PushVariable(string name) { var args = new VariableFoundEventArgs <Expression>(name, null); VariableFound?.Invoke(this, args); if (args.Result == null) { throw new ParserException("Unrecognized variable '{0}'".FormatString(name), Input, Index); } _stack.Push(args.Result); }
/// <summary> /// Call when a variable has been encountered. /// </summary> /// <param name="args">The event arguments.</param> protected void OnVariableFound(VariableFoundEventArgs <T> args) => VariableFound?.Invoke(this, args);
/// <summary> /// Called when a variable was found. /// </summary> /// <param name="args">The event arguments.</param> protected virtual void OnVariableFound(VariableFoundEventArgs <Complex> args) => VariableFound?.Invoke(this, args);