public BinaryExprAST(TokenType op, ExprAST lhs, ExprAST rhs) { switch (op) { case TokenType.PLUS: NodeType = ExprType.AddExpr; break; case TokenType.MINUS: NodeType = ExprType.SubtractExpr; break; case TokenType.STAR: NodeType = ExprType.MultiplyExpr; break; case TokenType.LESS_THAN: NodeType = ExprType.LessThanExpr; break; default: throw new ArgumentException("op " + op + " is not a valid operator"); } Lhs = lhs; Rhs = rhs; }
public BinaryExprAST(char op, ExprAST lhs, ExprAST rhs) { switch (op) { case '+': this.NodeType = ExprType.AddExpr; break; case '-': this.NodeType = ExprType.SubtractExpr; break; case '*': this.NodeType = ExprType.MultiplyExpr; break; case '<': this.NodeType = ExprType.LessThanExpr; break; default: throw new ArgumentException("op " + op + " is not a valid operator"); } this.Lhs = lhs; this.Rhs = rhs; }