예제 #1
0
 public override ReturnValue Value(Binding b)
 {
     try {
         return b.ValueFor(name);
     } catch (KeyNotFoundException /* unused */) {
         return new ReturnValue();
     }
 }
예제 #2
0
 public override ReturnValue Value(Binding b)
 {
     if (expr != null) {
         if (b.Set (name, expr)) {
             ReturnValue ret = expr.Value (b);
             return new ReturnValue (name + " = " + ret);
         } else {
             return new ReturnValue (name + " = " + b.ValueFor (name));
         }
     }
     return new ReturnValue (name + " = undefined");
 }
예제 #3
0
        public override ReturnValue Value(Binding binding)
        {
            ReturnValue ra = a.Value(binding);
            ReturnValue rb = b.Value(binding);

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

            if (op == '+') {
                return new ReturnValue(ra.Value() + rb.Value());
            } else if (op == '-') {
                return new ReturnValue(ra.Value() - rb.Value());
            } else if (op == '*') {
                return new ReturnValue(ra.Value() * rb.Value());
            } else if (op == '/') {
                return new ReturnValue(ra.Value() / rb.Value());
            } else {
                throw new ParserException("Unknown operator: " + op);
            }
        }
예제 #4
0
 public abstract ReturnValue Value(Binding b);
예제 #5
0
 public override ReturnValue Value(Binding b)
 {
     return new ReturnValue(val);
 }
예제 #6
0
 public Calculator(Binding b)
 {
     this.binding = b;
 }