예제 #1
0
        public override ReturnValue Value(Binding binding)
        {
            ReturnValue ra = Left.Value(binding);
            ReturnValue rb = Right.Value(binding);

            if (!ra.Defined() || !rb.Defined())
            {
                return(new ReturnValue());
            }

            if (op == "+")
            {
                return(new ReturnValue(ra.Value() + rb.Value()));
            }

            if (op == "-")
            {
                return(new ReturnValue(ra.Value() - rb.Value()));
            }

            if (op == "*")
            {
                return(new ReturnValue(ra.Value() * rb.Value()));
            }

            if (op == "/")
            {
                return(new ReturnValue(ra.Value() / rb.Value()));
            }

            if (op == "//")
            {
                return(new ReturnValue((int)(ra.Value() / rb.Value())));
            }

            throw new ParserException("Unknown operator: " + op);
        }