示例#1
0
        public BinaryOpExprAST(char op, ExprAST lhs, ExprAST rhs)
        {
            switch (op)
            {
            case '+':
                this.NodeType = ExprType.AddExpr;
                break;

            case '-':
                this.NodeType = ExprType.SubtractExpr;
                break;

            case '*':
                this.NodeType = ExprType.MultExpr;
                break;

            case '/':
                this.NodeType = ExprType.DivideExpr;
                break;

            case '<':
                this.NodeType = ExprType.LessThanExpr;
                break;

            default:
                throw new ArgumentException("op " + op + " is not a valid operator");
            }
            this.Lhs = lhs;
            this.Rhs = rhs;
        }
示例#2
0
 public FunctionAST(ExprAST proto, ExprAST body)
 {
     this.Proto    = (PrototypeAST)proto;
     this.Body     = body;
     this.NodeType = ExprType.FunctionExpr;
 }