From b92bbd915788e10fbad64f52d4b3c31727036877 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 20 Oct 2014 23:19:27 +0200 Subject: [PATCH] some clean up --- src/lib/Expr.cpp | 3 +-- src/lib/Expr.h | 6 +++-- src/lib/List.h | 6 ++--- src/lib/Statement.cpp | 4 +--- src/sql_execution.cpp | 5 ++-- src/sql_parser_cli.cpp | 52 ------------------------------------------ 6 files changed, 12 insertions(+), 64 deletions(-) delete mode 100644 src/sql_parser_cli.cpp diff --git a/src/lib/Expr.cpp b/src/lib/Expr.cpp index 0dd2867..05d9ab5 100644 --- a/src/lib/Expr.cpp +++ b/src/lib/Expr.cpp @@ -8,7 +8,6 @@ Expr* makeColumnRef(char* name) { return e; } - Expr* makeFunctionRef(char* func_name, Expr* expr) { ALLOC_EXPR(e, eExprFunctionRef); e->name = func_name; @@ -34,4 +33,4 @@ Expr* makeStringLiteral(char* string) { ALLOC_EXPR(e, eExprLiteralString); e->name = string; return e; -} \ No newline at end of file +} diff --git a/src/lib/Expr.h b/src/lib/Expr.h index 1a285ac..dc3f812 100644 --- a/src/lib/Expr.h +++ b/src/lib/Expr.h @@ -1,7 +1,8 @@ #ifndef __EXPRESSION_H__ #define __EXPRESSION_H__ -#include +#include + typedef enum { eExprLiteralFloat, @@ -11,6 +12,7 @@ typedef enum { eExprPredicate } EExprType; +typedef struct Expr Expr; struct Expr { EExprType type; @@ -39,4 +41,4 @@ Expr* makeFloatLiteral(float value); Expr* makeStringLiteral(char* string); -#endif \ No newline at end of file +#endif diff --git a/src/lib/List.h b/src/lib/List.h index e9309ec..9138a5c 100644 --- a/src/lib/List.h +++ b/src/lib/List.h @@ -2,7 +2,7 @@ #define __LIST_H__ #include -#include +#include template class List { @@ -10,7 +10,7 @@ public: std::vector<_T> _vector; List() {} - + List(_T first_value) { _vector.push_back(first_value); } @@ -23,4 +23,4 @@ public: }; -#endif \ No newline at end of file +#endif diff --git a/src/lib/Statement.cpp b/src/lib/Statement.cpp index 8578522..9ca28de 100644 --- a/src/lib/Statement.cpp +++ b/src/lib/Statement.cpp @@ -2,11 +2,9 @@ * Statement.c * Implementation of functions used to build the syntax tree. */ - + #include "Statement.h" - #include - Statement::Statement(EStatementType type) : type(type) {}; diff --git a/src/sql_execution.cpp b/src/sql_execution.cpp index 0841303..68b69e0 100644 --- a/src/sql_execution.cpp +++ b/src/sql_execution.cpp @@ -1,5 +1,5 @@ -#include "lib/SQLParser.h" +#include "SQLParser.h" #include #include @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) { return -1; } - Statement *stmt = NULL; + // Statement *stmt = NULL; for (int n = 1; n < argc; ++n) { char* sql = argv[n]; @@ -50,6 +50,7 @@ int getValue(std::string col_name, int row) { if (col_name.compare("col2") == 0) return getValue(1, row); if (col_name.compare("col3") == 0) return getValue(2, row); if (col_name.compare("col4") == 0) return getValue(3, row); + return 0; } diff --git a/src/sql_parser_cli.cpp b/src/sql_parser_cli.cpp deleted file mode 100644 index 2f72af2..0000000 --- a/src/sql_parser_cli.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * sql_parser.cpp - */ - -#include "sql_interface.h" -#include - -void evaluate_statement(Statement* stmt); - - -int main(int argc, char *argv[]) { - if (argc <= 1) { - fprintf(stderr, "No SQL-Statement given!\n"); - return -1; - } - - Statement *stmt = NULL; - - for (int n = 1; n < argc; ++n) { - char* sql = argv[n]; - - printf("\nEvaluating Statement \"%s\"\n", sql); - Statement* stmt = parse_sql(sql); - evaluate_statement(stmt); - } - - return 0; -} - - - -void evaluate_select_statement(SelectStatement* stmt) { - // printf("Selecting %s from %s\n", stmt->_targets->toString(), stmt->_from_clause); -} - - - -void evaluate_statement(Statement* stmt) { - printf("Statement at %p\n", stmt); - if (stmt == NULL) return; - - switch (stmt->type) { - case eSelect: - evaluate_select_statement((SelectStatement*) stmt); - break; - case eInsert: - printf("Insert Statment found!\n"); - break; - default: - break; - } -}