initial support for aggregate functions
This commit is contained in:
11
parser.cpp
11
parser.cpp
@@ -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));
|
||||
@@ -454,6 +455,10 @@ namespace usql {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user