basic skeletons of update and delete added
This commit is contained in:
27
lexer.cpp
27
lexer.cpp
@@ -13,7 +13,7 @@ void Lexer::parse(const std::string &code) {
|
||||
// TODO handle empty code
|
||||
m_tokens.clear();
|
||||
|
||||
// PERF something like this to prealocate ??
|
||||
// PERF something like this to preallocate ??
|
||||
if (code.size() > 100) {
|
||||
m_tokens.reserve(code.size() / 10);
|
||||
}
|
||||
@@ -36,7 +36,8 @@ void Lexer::parse(const std::string &code) {
|
||||
if (token_type == TokenType::string_literal)
|
||||
match_str = stringLiteral(match_str);
|
||||
|
||||
m_tokens.push_back(Token{match_str, token_type});
|
||||
if (token_type != TokenType::newline)
|
||||
m_tokens.push_back(Token{match_str, token_type});
|
||||
}
|
||||
|
||||
// DEBUG IT
|
||||
@@ -92,6 +93,14 @@ bool Lexer::isRelationalOperator(TokenType token_type) {
|
||||
token_type == TokenType::lesser || token_type == TokenType::lesser_equal);
|
||||
}
|
||||
|
||||
bool Lexer::isLogicalOperator(TokenType token_type) {
|
||||
return (token_type == TokenType::logical_and || token_type == TokenType::logical_or);
|
||||
}
|
||||
|
||||
bool Lexer::isArithmeticalOperator(TokenType token_type) {
|
||||
return (token_type == TokenType::plus || token_type == TokenType::minus || token_type == TokenType::multiply || token_type == TokenType::divide);
|
||||
}
|
||||
|
||||
TokenType Lexer::type(const std::string &token) {
|
||||
// TODO move it to class level not to reinit it again and again
|
||||
std::regex int_regex("[0-9]+");
|
||||
@@ -145,8 +154,11 @@ TokenType Lexer::type(const std::string &token) {
|
||||
if (token == "where")
|
||||
return TokenType::keyword_where;
|
||||
|
||||
if (token == "from")
|
||||
return TokenType::keyword_from;
|
||||
if (token == "from")
|
||||
return TokenType::keyword_from;
|
||||
|
||||
if (token == "delete")
|
||||
return TokenType::keyword_delete;
|
||||
|
||||
if (token == "table")
|
||||
return TokenType::keyword_table;
|
||||
@@ -166,8 +178,11 @@ TokenType Lexer::type(const std::string &token) {
|
||||
if (token == "set")
|
||||
return TokenType::keyword_set;
|
||||
|
||||
if (token == "copy")
|
||||
return TokenType::keyword_copy;
|
||||
if (token == "copy")
|
||||
return TokenType::keyword_copy;
|
||||
|
||||
if (token == "update")
|
||||
return TokenType::keyword_update;
|
||||
|
||||
if (token == "not")
|
||||
return TokenType::keyword_not;
|
||||
|
||||
Reference in New Issue
Block a user