Esempio n. 1
0
        public override Operator nud()
        {
            MethodTracer.Enter();
            ParseTreeNode n = null;
            int           i = 0;

            while (parser.Token != null && parser.Token.value != Closing)
            {
                n         = parser.Expression(0);
                this[i++] = n;
                if (parser.Token.type == TokenType.Symbol && parser.Token.value == "|")
                {
                    parser.Advance();
                    BuildComprehension();
                    break;
                }
                if (parser.Token != null && parser.Token.value == Separator)
                {
                    parser.Advance(TokenType.Symbol, Separator);
                }
            }
            if (parser.Token != null)
            {
                parser.Advance(TokenType.Symbol, Closing);
            }
            MethodTracer.Exit();
            return(this);
        }
Esempio n. 2
0
        public object Evaluate(ParseTreeNode x)
        {
            object result = null;

            MethodTracer.Enter();

            if (_treefun.ContainsKey(x.Name))
            {
                MethodTracer.LogMessage("FUN:{0}", x.Name);
                result = _treefun[x.Name](x);
            }
            else
            {
                try
                {
                    result = this[x.Name];
                }
                catch (KeyNotFoundException)
                {
                    result = null;
                }
            }
            TraceExpression(x, result);
            MethodTracer.Exit();
            return(result);
        }
Esempio n. 3
0
 void BuildComprehension()
 {
     MethodTracer.Enter();
     while (true)
     {
         MethodTracer.LogMessage("{0}", parser.Token);
         if (parser.Token.type != TokenType.Identifier)
         {
             MethodTracer.LogWarning("First part in comprehension must be an identifier.");
             break;
         }
         Name    = "LISTCOMPREHENSION";
         this[1] = new Operator()
         {
             Name = parser.Token.value
         };
         parser.Advance();
         parser.Advance(TokenType.Symbol, ":");
         this[2] = parser.Expression(0);
     }
     MethodTracer.Exit();
 }
Esempio n. 4
0
        public override Operator nud()
        {
            MethodTracer.Enter();
            ParseTreeNode n = null;
            int           i = 0;

            while (parser.Token != null && parser.Token.value != Closing)
            {
                n = parser.Expression(0);
                MethodTracer.LogMessage("Expression in List:{0}", n);
                this[i++] = n;
                if (parser.Token != null && parser.Token.value == Separator)
                {
                    parser.Advance(TokenType.Symbol, Separator);
                }
            }
            if (parser.Token != null)
            {
                parser.Advance(TokenType.Symbol, Closing);
            }
            MethodTracer.Exit();
            return(this);
        }