Пример #1
0
        private Expression readExpression()
        {
            Console.WriteLine(" 1: Const Expression\n 2: Var Expression\n 3: Arith Expression");
            int c = Convert.ToInt32(Console.ReadLine());

            if (c == 1)
            {
                Console.WriteLine("Input constant expression");
                ConstExpression cx = new ConstExpression(Convert.ToInt32(Console.ReadLine()));
                return((Expression)cx);
            }
            else if (c == 2)
            {
                Console.WriteLine("Input variable expression");
                VarExpression ve = new VarExpression(Console.ReadLine());
                return((Expression)ve);
            }
            else if (c == 3)
            {
                ArithExpression ae = new ArithExpression();
                Console.WriteLine("Input left expression");
                ae.setL(readExpression());
                Console.WriteLine("Input operator");
                ae.setOp(Console.ReadLine()[0]);
                Console.WriteLine("Input right expression");
                ae.setR(readExpression());
                return((Expression)ae);
            }
            return(null);
        }
Пример #2
0
 public Iter(ArithExpression arith_begin, ArithExpression arith_end)
 {
     if (arith_begin == null || arith_end == null)
     {
         throw new Exception("Null ArithExpression inputted into new Iter");
     }
     this.arith_begin = arith_begin;
     this.arith_end   = arith_end;
 }
Пример #3
0
 public BoolExpression(BoolOperator op, ArithExpression arith1, ArithExpression arith2)
 {
     //Postcondition: Creates a new BoolExpression using op, arith1, and arith2
     if (arith1 == null || arith2 == null)
     {
         throw new Exception("Null ArithExpression inputted into new BoolExpression");
     }
     this.arith1 = arith1;
     this.arith2 = arith2;
     this.op     = op;
 }
Пример #4
0
        void ButtonSubmitArithmeticClick(object sender, EventArgs e)
        {
            String          operand = textBoxArithmeticOperand.Text;
            ArithExpression ae      = new ArithExpression();

            ae.setL(leftExpression);
            ae.setOp(operand[0]);
            ae.setR(rightExpression);
            expression = ae;
            finished();
        }
Пример #5
0
 public PrintStatement(ArithExpression arith)
 {
     this.arith = arith ?? throw new Exception("Null ArithExpression inputted to new PrintStatement");
 }
Пример #6
0
 public AssignStatement(Id id, ArithExpression arith)
 {
     this.id    = id ?? throw new Exception("Null Id inputted into new AssignStatement");
     this.arith = arith ?? throw new Exception("Null ArithExpression inputted into new AssignStatement");
 }