some clean up
This commit is contained in:
parent
23cdcd5613
commit
b92bbd9157
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#ifndef __EXPRESSION_H__
|
||||
#define __EXPRESSION_H__
|
||||
|
||||
#include <cstdlib>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
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
|
||||
#endif
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define __LIST_H__
|
||||
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
#include <stdlib.h>
|
||||
|
||||
template <typename _T>
|
||||
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
|
||||
#endif
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
* Statement.c
|
||||
* Implementation of functions used to build the syntax tree.
|
||||
*/
|
||||
|
||||
|
||||
#include "Statement.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
Statement::Statement(EStatementType type) : type(type) {};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
#include "lib/SQLParser.h"
|
||||
#include "SQLParser.h"
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue