public StackFunction Parse(string input) { StackFunction result = null; var lexemList = input.Split(' '); foreach (var lexem in lexemList) { int number; var isNumber = int.TryParse(lexem, out number); if (isNumber) { var constant = new IntegerConstantFunction(number); result += constant.Execute; } else { var function = _nameManager.GetFunction(lexem); if (function != null) { result += function; } else { return(null); } } } return(result); }
private static ErrorHandler makeErrorHandler(ErrorHandler oldErrorHandler, StackFunction f) { // Report the "message" from the exception to the Lisp // error handling function. // Ensure that the original error handler is in scope before evaluating the error function - // otherwise we end up in an infinite loop if there's an error in the error function itself. return (c, ex) => f.Evaluate(c.PopTask().SetErrorHandler(oldErrorHandler), DatumHelpers.compound(ex.Message.ToAtom(), CallCC.MakeContinuationFunction(c))); }
private static ErrorHandler makeErrorHandler(ErrorHandler oldErrorHandler, StackFunction f) { // Report the "message" from the exception to the Lisp // error handling function. // Ensure that the original error handler is in scope before evaluating the error function - // otherwise we end up in an infinite loop if there's an error in the error function itself. return((c, ex) => f.Evaluate(c.PopTask().SetErrorHandler(oldErrorHandler), DatumHelpers.compound(ex.Message.ToAtom(), CallCC.MakeContinuationFunction(c)))); }
public void AddDelegate(string name, StackFunction function) { _functions[name] = function; }
public InvokeFunction(StackFunction function, int argCount) { this.function = function; this.argCount = argCount; }
public FunctionExpression(StackFunction function) { this.function = function; }
public virtual T visit(StackFunction s) { return(defaultCase(s)); }
public MacroClosure(StackFunction argFunction) { this.argFunction = argFunction; }
public static FExpression ToMacro(StackFunction function) { return new MacroClosure(function); }
public override FExpression visit(StackFunction f) { return(new FunctionExpression(f)); }
public static FExpression ToMacro(StackFunction function) { return(new MacroClosure(function)); }