Beispiel #1
0
 public override ReturnValue Value(Binding b)
 {
     try {
         return b.ValueFor(name);
     } catch (KeyNotFoundException /* unused */) {
         return new ReturnValue();
     }
 }
Beispiel #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");
 }
Beispiel #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);
            }
        }
Beispiel #4
0
 public abstract ReturnValue Value(Binding b);
Beispiel #5
0
 public override ReturnValue Value(Binding b)
 {
     return new ReturnValue(val);
 }
Beispiel #6
0
 public Calculator(Binding b)
 {
     this.binding = b;
 }