usql updates, lexer changes

This commit is contained in:
2021-09-15 21:22:24 +02:00
parent 7e4a4b5583
commit 1e0506e6cd
21 changed files with 986 additions and 777 deletions

View File

@@ -191,8 +191,10 @@ namespace usql {
// column values
m_lexer.skipToken(TokenType::open_paren);
do {
auto col_value = parse_expression();
column_values.push_back(std::move(col_value));
// TODO here it is problem when exception from parse_expression<-parse_value is thrown
// it makes double free
auto value = parse_expression();
column_values.emplace_back(std::move(value));
m_lexer.skipTokenOptional(TokenType::comma);
} while (m_lexer.tokenType() != TokenType::close_paren);
@@ -408,7 +410,6 @@ namespace usql {
// parenthesised expression
if (token_type == TokenType::open_paren) {
m_lexer.skipToken(TokenType::open_paren);
auto left = parse_expression();
do {
left = parse_expression(std::move(left));
@@ -450,6 +451,14 @@ namespace usql {
if (token_type == TokenType::keyword_null)
return std::make_unique<NullValueNode>();
// true / false
if (token_type == TokenType::keyword_true || token_type == TokenType::keyword_false)
return std::make_unique<BooleanValueNode>(token_type == TokenType::keyword_true);
// token * for count(*)
if (token_type == TokenType::multiply)
return std::make_unique<StringValueNode>(tokenString);
throw Exception("Unknown operand node " + tokenString);
}
@@ -468,6 +477,12 @@ namespace usql {
return RelationalOperatorType::lesser;
case TokenType::lesser_equal:
return RelationalOperatorType::lesser_equal;
case TokenType::is:
if (m_lexer.tokenType() == TokenType::keyword_not) {
m_lexer.skipToken(TokenType::keyword_not);
return RelationalOperatorType::is_not;
}
return RelationalOperatorType::is;
default:
throw Exception("Unknown relational operator " + op.token_string);
}