예제 #1
0
        public override object exec(Node <object> args)
        {
            Node <Object> scope = Node <Object> .kvs_extend("args", args, parentScope);

            scope = Node <Object> .kvs_extend("this", this, scope);

            QueueRun run = new QueueRun(scope);

            return(run.exec(exp));
        }
예제 #2
0
        public void shell()
        {
            String   cache = "";
            bool     come  = true;
            QueueRun qr    = new QueueRun(scope);

            while (come)
            {
                String tmp = "";
                Console.Write("<=");
                tmp = Console.ReadLine();
                if (tmp == "``")
                {
                    bool will = true;
                    while (will)
                    {
                        tmp = Console.ReadLine();
                        if (tmp == "``")
                        {
                            will = false;
                        }
                        else
                        {
                            cache = cache + tmp + lineSplit;
                        }
                    }
                }
                else
                {
                    cache = tmp;
                }
                if (cache == "exit")
                {
                    come = false;
                }
                else
                {
                    Node <Token> tokens = Token.run(cache, lineSplit);
                    if (tokens != null)
                    {
                        Exp    exp = Exp.Parse(tokens);
                        Object r   = null;
                        try
                        {
                            r = qr.exec(exp);
                        }
                        catch (Exception e)
                        {
                            Util.logException(e);
                        }
                        Console.Write("=>");
                        if (r == null)
                        {
                            Console.WriteLine("[]");
                        }
                        else
                        {
                            StringBuilder sb = new StringBuilder();
                            Node <Object> .toString(sb, r, false);

                            Console.WriteLine(sb.ToString());
                        }
                        Console.WriteLine();
                    }
                }
            }
        }