|
// /************************************************************
// *
// * Copyright (c) 2012 Matthew So So. All Rights Reserved
// *
// * Author: Matthew So
// *
// ************************************************************/
using System;
using bsn.GoldParser.Semantic;
using System.CodeDom;
namespace EntityMapper.Semantic
{
public class BinaryOperation : Expression{
private readonly Expression _left;
private readonly BinaryOperator _op;
private readonly Expression _right;
[Rule(@"<Expression> ::= <Expression> '>' <Add Exp>")]
[Rule(@"<Expression> ::= <Expression> '<' <Add Exp>")]
[Rule(@"<Expression> ::= <Expression> '<=' <Add Exp>")]
[Rule(@"<Expression> ::= <Expression> '>=' <Add Exp>")]
[Rule(@"<Expression> ::= <Expression> '==' <Add Exp>")]
[Rule(@"<Expression> ::= <Expression> '<>' <Add Exp>")]
[Rule(@"<Add Exp> ::= <Add Exp> '+' <Mult Exp>")]
[Rule(@"<Add Exp> ::= <Add Exp> '-' <Mult Exp>")]
[Rule(@"<Mult Exp> ::= <Mult Exp> '*' <Negate Exp>")]
[Rule(@"<Mult Exp> ::= <Mult Exp> '/' <Negate Exp>")]
public BinaryOperation(Expression left, BinaryOperator op, Expression right){
_left = left;
_op = op;
_right = right;
}
public override CodeExpression GetValue(ExecutionContext ctx)
{
CodeExpression lStart = _left.GetValue(ctx);
CodeExpression rStart = _right.GetValue(ctx);
return _op.Evaluate(lStart, rStart);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am always interested in finding innovative ways for building better applications and founded a technology company since 2003. Welcome to exchange any idea with you and if I am not too busy before deadline of projects, I will reply your emails. Also, if you willing to pay for consulting works and customized software development, you can leave me message.