code beautification
This commit is contained in:
12
Readme.md
12
Readme.md
@@ -5,18 +5,12 @@ compare in row.cpp shoud take into account m_visible
|
||||
- create local_install.sh
|
||||
|
||||
- set xxx - without value to reset to default value
|
||||
- escape " in save csv
|
||||
- is null | is not null
|
||||
- coalesce, date functions now, add_date; string functions rtrim, ltrim, rpad, lpad; math function round
|
||||
- coalesce, date functions now; string functions rtrim, ltrim, rpad, lpad; math function round
|
||||
- add pipe | concatenation
|
||||
- add support for 1_000_000 numbers
|
||||
- expand_asterix_char should support multiple and everywhere *
|
||||
|
||||
- support for reusing space of deleted rows
|
||||
- support for uniqueue indexes (primary key)
|
||||
- support for indexes
|
||||
- add drop m_index
|
||||
- add drop m_index
|
||||
- support for joining
|
||||
|
||||
- add const wherever should be
|
||||
- use static methods where posible
|
||||
- use references where pointer cannot be nullptr
|
||||
|
||||
50
parser.cpp
50
parser.cpp
@@ -3,7 +3,7 @@
|
||||
|
||||
namespace usql {
|
||||
|
||||
// TOOD handle premature eof
|
||||
// TOOD handle premature eof
|
||||
|
||||
std::string column_type_name(const ColumnType type) {
|
||||
if (type == ColumnType::integer_type) return "integer_type";
|
||||
@@ -64,11 +64,11 @@ namespace usql {
|
||||
|
||||
// create as select
|
||||
if (m_lexer.tokenType() == TokenType::keyword_as) {
|
||||
m_lexer.skipToken(TokenType::keyword_as);
|
||||
m_lexer.skipToken(TokenType::keyword_as);
|
||||
|
||||
std::unique_ptr<Node> select = parse_select_from_table();
|
||||
std::unique_ptr<Node> select = parse_select_from_table();
|
||||
|
||||
return std::make_unique<CreateTableAsSelectNode>(table_name, std::move(select));
|
||||
return std::make_unique<CreateTableAsSelectNode>(table_name, std::move(select));
|
||||
} else {
|
||||
m_lexer.skipToken(TokenType::open_paren);
|
||||
int column_order = 0;
|
||||
@@ -80,30 +80,30 @@ namespace usql {
|
||||
|
||||
// column name
|
||||
if (m_lexer.tokenType() != TokenType::identifier) {
|
||||
throw Exception("syntax error, expected identifier");
|
||||
throw Exception("syntax error, expected identifier");
|
||||
}
|
||||
database_value = m_lexer.consumeToken().token_string;
|
||||
database_value = m_lexer.consumeToken().token_string;
|
||||
|
||||
// column type and optionally len
|
||||
if (m_lexer.tokenType() == TokenType::keyword_integer) {
|
||||
column_type = ColumnType::integer_type;
|
||||
m_lexer.nextToken();
|
||||
} else if (m_lexer.tokenType() == TokenType::keyword_float) {
|
||||
column_type = ColumnType::float_type;
|
||||
m_lexer.nextToken();
|
||||
} else if (m_lexer.tokenType() == TokenType::keyword_varchar) {
|
||||
column_type = ColumnType::varchar_type;
|
||||
m_lexer.nextToken();
|
||||
m_lexer.skipToken(TokenType::open_paren);
|
||||
column_len = std::stoi(m_lexer.consumeToken(TokenType::int_number).token_string);
|
||||
m_lexer.skipToken(TokenType::close_paren);
|
||||
// column type and optionally len
|
||||
if (m_lexer.tokenType() == TokenType::keyword_integer) {
|
||||
column_type = ColumnType::integer_type;
|
||||
m_lexer.nextToken();
|
||||
} else if (m_lexer.tokenType() == TokenType::keyword_float) {
|
||||
column_type = ColumnType::float_type;
|
||||
m_lexer.nextToken();
|
||||
} else if (m_lexer.tokenType() == TokenType::keyword_varchar) {
|
||||
column_type = ColumnType::varchar_type;
|
||||
m_lexer.nextToken();
|
||||
m_lexer.skipToken(TokenType::open_paren);
|
||||
column_len = std::stoi(m_lexer.consumeToken(TokenType::int_number).token_string);
|
||||
m_lexer.skipToken(TokenType::close_paren);
|
||||
} else if (m_lexer.tokenType() == TokenType::keyword_date) {
|
||||
column_type = ColumnType::date_type;
|
||||
m_lexer.nextToken();
|
||||
} else if (m_lexer.tokenType() == TokenType::keyword_bool) {
|
||||
column_type = ColumnType::bool_type;
|
||||
m_lexer.nextToken();
|
||||
} else {
|
||||
} else if (m_lexer.tokenType() == TokenType::keyword_bool) {
|
||||
column_type = ColumnType::bool_type;
|
||||
m_lexer.nextToken();
|
||||
} else {
|
||||
throw Exception("syntax error, column type expected, found " + m_lexer.currentToken().token_string);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace usql {
|
||||
m_lexer.skipTokenOptional(TokenType::comma);
|
||||
|
||||
//constraints
|
||||
//defaults
|
||||
//defaults
|
||||
} while (m_lexer.tokenType() != TokenType::close_paren);
|
||||
|
||||
return std::make_unique<CreateTableNode>(table_name, cols_def);
|
||||
@@ -502,7 +502,7 @@ namespace usql {
|
||||
return RelationalOperatorType::lesser_equal;
|
||||
case TokenType::is:
|
||||
if (m_lexer.tokenType() == TokenType::keyword_not) {
|
||||
m_lexer.skipToken(TokenType::keyword_not);
|
||||
m_lexer.skipToken(TokenType::keyword_not);
|
||||
return RelationalOperatorType::is_not;
|
||||
}
|
||||
return RelationalOperatorType::is;
|
||||
|
||||
Reference in New Issue
Block a user