예제 #1
0
        internal static Container Interpret(ICodeBlock context, MultiTreeNode <Value> line)
        {
            switch (line.Data.Type)
            {
            case ValueType.Function when line.Data.Val is string fname:
                if (fname == "=" && line.PeekChild().Data.Type == ValueType.Variable)
                {
                    context.SetVariable(line.PeekChild().Data.Val as string,
                                        Interpret(context, line.PeekChild().PeekSibling()).value);
                    return(null);
                }
                else
                {
                    return(Library.Functions[fname]
                               (line.GetChildren().Select(v => Interpret(context, v)).ToList()));
                }

            case ValueType.Value:
                return(new Container(line.Data.Val));

            case ValueType.Variable when line.Data.Val is string vname:
                return(context.GetVariable(vname));

            default:
                return(null);
            }
        }