use more consistent types
This commit is contained in:
88
parser.cpp
88
parser.cpp
@@ -318,58 +318,58 @@ namespace usql {
|
||||
}
|
||||
|
||||
std::vector<ColOrderNode> Parser::parse_order_by_clause() {
|
||||
std::vector<ColOrderNode> order_cols;
|
||||
|
||||
if (m_lexer.tokenType() == TokenType::keyword_order) {
|
||||
m_lexer.skipToken(TokenType::keyword_order);
|
||||
m_lexer.skipToken(TokenType::keyword_by);
|
||||
std::vector<ColOrderNode> order_cols;
|
||||
|
||||
if (m_lexer.tokenType() == TokenType::keyword_order) {
|
||||
m_lexer.skipToken(TokenType::keyword_order);
|
||||
m_lexer.skipToken(TokenType::keyword_by);
|
||||
|
||||
do {
|
||||
bool asc = true;
|
||||
do {
|
||||
bool asc = true;
|
||||
|
||||
auto cspec_token_type = m_lexer.tokenType();
|
||||
std::string cspec_token = m_lexer.consumeToken().token_string;
|
||||
|
||||
if (m_lexer.tokenType() == TokenType::keyword_asc) {
|
||||
m_lexer.skipToken(TokenType::keyword_asc);
|
||||
} else if (m_lexer.tokenType() == TokenType::keyword_desc) {
|
||||
m_lexer.skipToken(TokenType::keyword_desc);
|
||||
asc = false;
|
||||
}
|
||||
|
||||
switch (cspec_token_type) {
|
||||
case TokenType::int_number:
|
||||
order_cols.emplace_back(std::stoi(cspec_token), asc);
|
||||
break;
|
||||
case TokenType::identifier:
|
||||
order_cols.emplace_back(cspec_token, asc);
|
||||
break;
|
||||
default:
|
||||
throw Exception("order by column can be either column m_index or identifier");
|
||||
}
|
||||
|
||||
m_lexer.skipTokenOptional(TokenType::comma);
|
||||
} while (m_lexer.tokenType() != TokenType::eof && m_lexer.tokenType() != TokenType::keyword_offset && m_lexer.tokenType() != TokenType::keyword_limit);
|
||||
}
|
||||
|
||||
auto cspec_token_type = m_lexer.tokenType();
|
||||
std::string cspec_token = m_lexer.consumeToken().token_string;
|
||||
|
||||
if (m_lexer.tokenType() == TokenType::keyword_asc) {
|
||||
m_lexer.skipToken(TokenType::keyword_asc);
|
||||
} else if (m_lexer.tokenType() == TokenType::keyword_desc) {
|
||||
m_lexer.skipToken(TokenType::keyword_desc);
|
||||
asc = false;
|
||||
}
|
||||
|
||||
switch (cspec_token_type) {
|
||||
case TokenType::int_number:
|
||||
order_cols.emplace_back(std::stoi(cspec_token), asc);
|
||||
break;
|
||||
case TokenType::identifier:
|
||||
order_cols.emplace_back(cspec_token, asc);
|
||||
break;
|
||||
default:
|
||||
throw Exception("order by column can be either column m_index or identifier");
|
||||
}
|
||||
|
||||
m_lexer.skipTokenOptional(TokenType::comma);
|
||||
} while (m_lexer.tokenType() != TokenType::eof && m_lexer.tokenType() != TokenType::keyword_offset && m_lexer.tokenType() != TokenType::keyword_limit);
|
||||
}
|
||||
|
||||
return order_cols;
|
||||
return order_cols;
|
||||
}
|
||||
|
||||
OffsetLimitNode Parser::parse_offset_limit_clause() {
|
||||
int offset = 0;
|
||||
int limit = 999999999;
|
||||
size_t offset = 0;
|
||||
size_t limit = 999999999;
|
||||
|
||||
if (m_lexer.tokenType() == TokenType::keyword_offset) {
|
||||
m_lexer.skipToken(TokenType::keyword_offset);
|
||||
offset = std::stoi(m_lexer.consumeToken(TokenType::int_number).token_string);
|
||||
}
|
||||
if (m_lexer.tokenType() == TokenType::keyword_offset) {
|
||||
m_lexer.skipToken(TokenType::keyword_offset);
|
||||
offset = std::stoi(m_lexer.consumeToken(TokenType::int_number).token_string);
|
||||
}
|
||||
|
||||
if (m_lexer.tokenType() == TokenType::keyword_limit) {
|
||||
m_lexer.skipToken(TokenType::keyword_limit);
|
||||
limit = std::stoi(m_lexer.consumeToken(TokenType::int_number).token_string);
|
||||
}
|
||||
if (m_lexer.tokenType() == TokenType::keyword_limit) {
|
||||
m_lexer.skipToken(TokenType::keyword_limit);
|
||||
limit = std::stoi(m_lexer.consumeToken(TokenType::int_number).token_string);
|
||||
}
|
||||
|
||||
return OffsetLimitNode{offset, limit};
|
||||
return OffsetLimitNode{offset, limit};
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user