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
|
- create local_install.sh
|
||||||
|
|
||||||
- set xxx - without value to reset to default value
|
- set xxx - without value to reset to default value
|
||||||
- escape " in save csv
|
- coalesce, date functions now; string functions rtrim, ltrim, rpad, lpad; math function round
|
||||||
- is null | is not null
|
|
||||||
- coalesce, date functions now, add_date; string functions rtrim, ltrim, rpad, lpad; math function round
|
|
||||||
- add pipe | concatenation
|
- add pipe | concatenation
|
||||||
- add support for 1_000_000 numbers
|
- add support for 1_000_000 numbers
|
||||||
- expand_asterix_char should support multiple and everywhere *
|
- expand_asterix_char should support multiple and everywhere *
|
||||||
|
|
||||||
|
- support for reusing space of deleted rows
|
||||||
- support for uniqueue indexes (primary key)
|
- support for uniqueue indexes (primary key)
|
||||||
- support for indexes
|
- add drop m_index
|
||||||
- add drop m_index
|
|
||||||
- support for joining
|
- 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 {
|
namespace usql {
|
||||||
|
|
||||||
// TOOD handle premature eof
|
// TOOD handle premature eof
|
||||||
|
|
||||||
std::string column_type_name(const ColumnType type) {
|
std::string column_type_name(const ColumnType type) {
|
||||||
if (type == ColumnType::integer_type) return "integer_type";
|
if (type == ColumnType::integer_type) return "integer_type";
|
||||||
@@ -64,11 +64,11 @@ namespace usql {
|
|||||||
|
|
||||||
// create as select
|
// create as select
|
||||||
if (m_lexer.tokenType() == TokenType::keyword_as) {
|
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 {
|
} else {
|
||||||
m_lexer.skipToken(TokenType::open_paren);
|
m_lexer.skipToken(TokenType::open_paren);
|
||||||
int column_order = 0;
|
int column_order = 0;
|
||||||
@@ -80,30 +80,30 @@ namespace usql {
|
|||||||
|
|
||||||
// column name
|
// column name
|
||||||
if (m_lexer.tokenType() != TokenType::identifier) {
|
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
|
// column type and optionally len
|
||||||
if (m_lexer.tokenType() == TokenType::keyword_integer) {
|
if (m_lexer.tokenType() == TokenType::keyword_integer) {
|
||||||
column_type = ColumnType::integer_type;
|
column_type = ColumnType::integer_type;
|
||||||
m_lexer.nextToken();
|
m_lexer.nextToken();
|
||||||
} else if (m_lexer.tokenType() == TokenType::keyword_float) {
|
} else if (m_lexer.tokenType() == TokenType::keyword_float) {
|
||||||
column_type = ColumnType::float_type;
|
column_type = ColumnType::float_type;
|
||||||
m_lexer.nextToken();
|
m_lexer.nextToken();
|
||||||
} else if (m_lexer.tokenType() == TokenType::keyword_varchar) {
|
} else if (m_lexer.tokenType() == TokenType::keyword_varchar) {
|
||||||
column_type = ColumnType::varchar_type;
|
column_type = ColumnType::varchar_type;
|
||||||
m_lexer.nextToken();
|
m_lexer.nextToken();
|
||||||
m_lexer.skipToken(TokenType::open_paren);
|
m_lexer.skipToken(TokenType::open_paren);
|
||||||
column_len = std::stoi(m_lexer.consumeToken(TokenType::int_number).token_string);
|
column_len = std::stoi(m_lexer.consumeToken(TokenType::int_number).token_string);
|
||||||
m_lexer.skipToken(TokenType::close_paren);
|
m_lexer.skipToken(TokenType::close_paren);
|
||||||
} else if (m_lexer.tokenType() == TokenType::keyword_date) {
|
} else if (m_lexer.tokenType() == TokenType::keyword_date) {
|
||||||
column_type = ColumnType::date_type;
|
column_type = ColumnType::date_type;
|
||||||
m_lexer.nextToken();
|
m_lexer.nextToken();
|
||||||
} else if (m_lexer.tokenType() == TokenType::keyword_bool) {
|
} else if (m_lexer.tokenType() == TokenType::keyword_bool) {
|
||||||
column_type = ColumnType::bool_type;
|
column_type = ColumnType::bool_type;
|
||||||
m_lexer.nextToken();
|
m_lexer.nextToken();
|
||||||
} else {
|
} else {
|
||||||
throw Exception("syntax error, column type expected, found " + m_lexer.currentToken().token_string);
|
throw Exception("syntax error, column type expected, found " + m_lexer.currentToken().token_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ namespace usql {
|
|||||||
m_lexer.skipTokenOptional(TokenType::comma);
|
m_lexer.skipTokenOptional(TokenType::comma);
|
||||||
|
|
||||||
//constraints
|
//constraints
|
||||||
//defaults
|
//defaults
|
||||||
} while (m_lexer.tokenType() != TokenType::close_paren);
|
} while (m_lexer.tokenType() != TokenType::close_paren);
|
||||||
|
|
||||||
return std::make_unique<CreateTableNode>(table_name, cols_def);
|
return std::make_unique<CreateTableNode>(table_name, cols_def);
|
||||||
@@ -502,7 +502,7 @@ namespace usql {
|
|||||||
return RelationalOperatorType::lesser_equal;
|
return RelationalOperatorType::lesser_equal;
|
||||||
case TokenType::is:
|
case TokenType::is:
|
||||||
if (m_lexer.tokenType() == TokenType::keyword_not) {
|
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_not;
|
||||||
}
|
}
|
||||||
return RelationalOperatorType::is;
|
return RelationalOperatorType::is;
|
||||||
|
|||||||
Reference in New Issue
Block a user