some clean up

This commit is contained in:
Pedro 2014-10-20 23:19:27 +02:00
parent 23cdcd5613
commit b92bbd9157
6 changed files with 12 additions and 64 deletions

View File

@ -8,7 +8,6 @@ Expr* makeColumnRef(char* name) {
return e; return e;
} }
Expr* makeFunctionRef(char* func_name, Expr* expr) { Expr* makeFunctionRef(char* func_name, Expr* expr) {
ALLOC_EXPR(e, eExprFunctionRef); ALLOC_EXPR(e, eExprFunctionRef);
e->name = func_name; e->name = func_name;

View File

@ -1,7 +1,8 @@
#ifndef __EXPRESSION_H__ #ifndef __EXPRESSION_H__
#define __EXPRESSION_H__ #define __EXPRESSION_H__
#include <cstdlib> #include <stdlib.h>
typedef enum { typedef enum {
eExprLiteralFloat, eExprLiteralFloat,
@ -11,6 +12,7 @@ typedef enum {
eExprPredicate eExprPredicate
} EExprType; } EExprType;
typedef struct Expr Expr;
struct Expr { struct Expr {
EExprType type; EExprType type;

View File

@ -2,7 +2,7 @@
#define __LIST_H__ #define __LIST_H__
#include <vector> #include <vector>
#include <cstdlib> #include <stdlib.h>
template <typename _T> template <typename _T>
class List { class List {

View File

@ -4,10 +4,8 @@
*/ */
#include "Statement.h" #include "Statement.h"
#include <stdlib.h> #include <stdlib.h>
Statement::Statement(EStatementType type) : type(type) {}; Statement::Statement(EStatementType type) : type(type) {};
SelectStatement::SelectStatement() : Statement(eSelect) {}; SelectStatement::SelectStatement() : Statement(eSelect) {};

View File

@ -1,5 +1,5 @@
#include "lib/SQLParser.h" #include "SQLParser.h"
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
return -1; return -1;
} }
Statement *stmt = NULL; // Statement *stmt = NULL;
for (int n = 1; n < argc; ++n) { for (int n = 1; n < argc; ++n) {
char* sql = argv[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("col2") == 0) return getValue(1, row);
if (col_name.compare("col3") == 0) return getValue(2, row); if (col_name.compare("col3") == 0) return getValue(2, row);
if (col_name.compare("col4") == 0) return getValue(3, row); if (col_name.compare("col4") == 0) return getValue(3, row);
return 0;
} }

View File

@ -1,52 +0,0 @@
/*
* sql_parser.cpp
*/
#include "sql_interface.h"
#include <stdio.h>
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;
}
}