コード例 #1
0
        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);
        }
コード例 #2
0
 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)));
 }
コード例 #3
0
 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))));
 }
コード例 #4
0
 public void AddDelegate(string name, StackFunction function)
 {
     _functions[name] = function;
 }
コード例 #5
0
 public InvokeFunction(StackFunction function, int argCount)
 {
     this.function = function;
     this.argCount = argCount;
 }
コード例 #6
0
 public FunctionExpression(StackFunction function)
 {
     this.function = function;
 }
コード例 #7
0
 public virtual T visit(StackFunction s)
 {
     return(defaultCase(s));
 }
コード例 #8
0
 public InvokeFunction(StackFunction function, int argCount)
 {
     this.function = function;
     this.argCount = argCount;
 }
コード例 #9
0
 public FunctionExpression(StackFunction function)
 {
     this.function = function;
 }
コード例 #10
0
ファイル: Macro.cs プロジェクト: 1tgr/FirstClassLisp
 public MacroClosure(StackFunction argFunction)
 {
     this.argFunction = argFunction;
 }
コード例 #11
0
ファイル: Macro.cs プロジェクト: 1tgr/FirstClassLisp
 public static FExpression ToMacro(StackFunction function)
 {
     return new MacroClosure(function);
 }
コード例 #12
0
 public override FExpression visit(StackFunction f)
 {
     return(new FunctionExpression(f));
 }
コード例 #13
0
ファイル: Macro.cs プロジェクト: 1tgr/FirstClassLisp
 public static FExpression ToMacro(StackFunction function)
 {
     return(new MacroClosure(function));
 }
コード例 #14
0
ファイル: Macro.cs プロジェクト: 1tgr/FirstClassLisp
 public MacroClosure(StackFunction argFunction)
 {
     this.argFunction = argFunction;
 }