public void Visit(BinaryExpr binaryExpr)
 {
     TreeLevel++;
     PrintNode("binaryExpr");
     PrintNode(binaryExpr.Op.ToString(), true);
     binaryExpr.Left.Accept(this);
     binaryExpr.Right.Accept(this);
     TreeLevel--;
 }
Exemple #2
0
 private BinaryExpr CreateBinaryExpr(Token token = null)
 {
     if (token == null)
     {
         token = AcceptedToken;
     }
     BinaryExpr expr = new BinaryExpr(token.Line, token.Column);
     switch(token.Type)
     {
         case Token.Types.OpPlus: expr.Op = Operator.Plus; break;
         case Token.Types.OpMinus: expr.Op = Operator.Minus; break;
         case Token.Types.OpMultiply: expr.Op = Operator.Times; break;
         case Token.Types.OpDivide: expr.Op = Operator.Divide; break;
         case Token.Types.OpLess: expr.Op = Operator.Less; break;
         case Token.Types.OpEquals: expr.Op = Operator.Equals; break;
         case Token.Types.OpAnd: expr.Op = Operator.And; break;
     }
     return expr;
 }
 public override void Visit(BinaryExpr binaryExpr)
 {
     binaryExpr.Left.Accept(this);
     binaryExpr.Right.Accept(this);
     binaryExpr.ExprValue = Evaluator.EvaluateExpression(binaryExpr.Left, binaryExpr.Right, binaryExpr.Op);
 }
 public override void Visit(BinaryExpr binaryExpr)
 {
     binaryExpr.Left.Accept(this);
     binaryExpr.Right.Accept(this);
     binaryExpr.Type = Checker.TypeCheck(binaryExpr.Left, binaryExpr.Right, binaryExpr.Op);
 }