implement NOT

This commit is contained in:
Andy Grove 2018-12-16 14:03:03 -07:00
parent 2240dd09ff
commit 7aab880387
3 changed files with 17 additions and 0 deletions

View file

@ -108,6 +108,10 @@ impl Parser {
self.parse_sql_value()
}
"CASE" => self.parse_case_expression(),
"NOT" => Ok(ASTNode::SQLUnary {
operator: SQLOperator::Not,
rex: Box::new(self.parse_expr(0)?),
}),
_ => return parser_err!(format!("No prefix parser for keyword {}", k)),
},
Token::Mult => Ok(ASTNode::SQLWildcard),
@ -329,6 +333,7 @@ impl Parser {
&Token::Mod => Ok(SQLOperator::Modulus),
&Token::Keyword(ref k) if k == "AND" => Ok(SQLOperator::And),
&Token::Keyword(ref k) if k == "OR" => Ok(SQLOperator::Or),
&Token::Keyword(ref k) if k == "NOT" => Ok(SQLOperator::Not),
&Token::Keyword(ref k) if k == "LIKE" => Ok(SQLOperator::Like),
_ => parser_err!(format!("Unsupported SQL operator {:?}", tok)),
}