34 lines
1016 B
C++
34 lines
1016 B
C++
#include "parser.h"
|
|
#include "executor.h"
|
|
|
|
// https://dev.to/joaoh82/what-would-sqlite-look-like-if-written-in-rust-part-1-2np4
|
|
|
|
// parser should get lexer as param and table executor to be able translate * or get types or so
|
|
// podporovat create as select
|
|
// drop table
|
|
|
|
int main(int argc, char *argv[]) {
|
|
Parser parser{};
|
|
Executor executor{};
|
|
|
|
std::vector<std::string> sql_commands {
|
|
"create table a (i integer not null, s varchar(64), f float null)",
|
|
"insert into a (i, s) values(1, 'one')",
|
|
"insert into a (i, s) values(2, 'two')",
|
|
"insert into a (i, s) values(3, 'two')",
|
|
"insert into a (i, s) values(4, 'four')",
|
|
"select i, s from a where i > 2"
|
|
// "update a set s = 'three' where i = 3"
|
|
// "delete from a where i = 3"
|
|
// "select i, s from a where i > 0"
|
|
};
|
|
|
|
|
|
for(auto command : sql_commands) {
|
|
auto node = parser.parse(command);
|
|
executor.execute(*node);
|
|
}
|
|
|
|
return 0;
|
|
}
|