some TODOs removed..
This commit is contained in:
24
parser.cpp
24
parser.cpp
@@ -47,7 +47,9 @@ namespace usql {
|
||||
m_lexer.skipToken(TokenType::keyword_create);
|
||||
m_lexer.skipToken(TokenType::keyword_table);
|
||||
|
||||
if (m_lexer.tokenType() != TokenType::identifier) { /* TODO handle error */ }
|
||||
if (m_lexer.tokenType() != TokenType::identifier)
|
||||
throw Exception("syntax error, expecting identifier but found " + m_lexer.currentToken().token_string);
|
||||
|
||||
std::string table_name = m_lexer.consumeCurrentToken().token_string;
|
||||
|
||||
// create as select
|
||||
@@ -111,7 +113,8 @@ namespace usql {
|
||||
|
||||
m_lexer.skipTokenOptional(TokenType::comma);
|
||||
|
||||
// TODO in future constraints
|
||||
//constraints
|
||||
//defaults
|
||||
} while (m_lexer.tokenType() != TokenType::close_paren);
|
||||
|
||||
return std::make_unique<CreateTableNode>(table_name, cols_def);
|
||||
@@ -155,9 +158,13 @@ namespace usql {
|
||||
|
||||
std::unique_ptr<Node> Parser::parse_set() {
|
||||
m_lexer.skipToken(TokenType::keyword_set);
|
||||
// TODO check these are string literals
|
||||
|
||||
if (m_lexer.currentToken().type!=TokenType::string_literal) throw Exception("Expecting literal in set name");
|
||||
std::string name = m_lexer.consumeCurrentToken().token_string;
|
||||
|
||||
m_lexer.skipTokenOptional(TokenType::equal);
|
||||
|
||||
if (m_lexer.currentToken().type!=TokenType::string_literal) throw Exception("Expecting literal in set value");
|
||||
std::string value = m_lexer.consumeCurrentToken().token_string;
|
||||
|
||||
return std::make_unique<SetNode>(name, value);
|
||||
@@ -165,7 +172,8 @@ namespace usql {
|
||||
|
||||
std::unique_ptr<Node> Parser::parse_show() {
|
||||
m_lexer.skipToken(TokenType::keyword_show);
|
||||
// TODO check these are string literals
|
||||
|
||||
if (m_lexer.currentToken().type!=TokenType::string_literal) throw Exception("Expecting literal on show parameter name");
|
||||
std::string name = m_lexer.consumeCurrentToken().token_string;
|
||||
|
||||
return std::make_unique<ShowNode>(name);
|
||||
@@ -179,13 +187,17 @@ namespace usql {
|
||||
m_lexer.skipToken(TokenType::keyword_into);
|
||||
|
||||
// table name
|
||||
if (m_lexer.tokenType() != TokenType::identifier) { /* TODO handle error */ }
|
||||
if (m_lexer.tokenType() != TokenType::identifier)
|
||||
throw Exception("syntax error, expecting identifier but found " + m_lexer.currentToken().token_string);
|
||||
|
||||
std::string table_name = m_lexer.consumeCurrentToken().token_string;
|
||||
|
||||
// column names
|
||||
m_lexer.skipToken(TokenType::open_paren);
|
||||
do {
|
||||
if (m_lexer.tokenType() != TokenType::identifier) { /* TODO handle error */ }
|
||||
if (m_lexer.tokenType() != TokenType::identifier)
|
||||
throw Exception("syntax error, expecting identifier but found " + m_lexer.currentToken().token_string);
|
||||
|
||||
database_values.emplace_back(m_lexer.consumeCurrentToken().token_string);
|
||||
|
||||
m_lexer.skipTokenOptional(TokenType::comma);
|
||||
|
||||
Reference in New Issue
Block a user