naming changes

This commit is contained in:
Pedro 2014-10-27 11:23:31 +01:00
parent 0b9d10f726
commit f319a02a85
7 changed files with 44 additions and 44 deletions

View File

@ -246,7 +246,7 @@ literal:
;
star_expr:
'*' { $$ = new Expr(eExprStar); }
'*' { $$ = new Expr(kExprStar); }
;
@ -257,7 +257,7 @@ table_ref:
table_ref_atomic
| table_ref_atomic ',' table_ref_commalist {
$3->push_back($1);
auto tbl = new TableRef(eTableCrossProduct);
auto tbl = new TableRef(kTableCrossProduct);
tbl->list = $3;
$$ = tbl;
}
@ -265,12 +265,12 @@ table_ref:
table_ref_atomic:
table_name {
auto tbl = new TableRef(eTableName);
auto tbl = new TableRef(kTableName);
tbl->name = $1;
$$ = tbl;
}
| '(' select_statement ')' {
auto tbl = new TableRef(eTableSelect);
auto tbl = new TableRef(kTableSelect);
tbl->stmt = $2;
$$ = tbl;
}

View File

@ -12,26 +12,26 @@ char* substr(const char* source, int from, int to) {
}
Expr* makeColumnRef(char* name) {
ALLOC_EXPR(e, eExprColumnRef);
ALLOC_EXPR(e, kExprColumnRef);
e->name = name;
return e;
}
Expr* makeFunctionRef(char* func_name, Expr* expr) {
ALLOC_EXPR(e, eExprFunctionRef);
ALLOC_EXPR(e, kExprFunctionRef);
e->name = func_name;
e->expr = expr;
return e;
}
Expr* makeFloatLiteral(float value) {
ALLOC_EXPR(e, eExprLiteralFloat);
ALLOC_EXPR(e, kExprLiteralFloat);
e->float_literal = value;
return e;
}
Expr* makeStringLiteral(char* string) {
ALLOC_EXPR(e, eExprLiteralString);
ALLOC_EXPR(e, kExprLiteralString);
e->name = substr(string, 1, strlen(string)-1);
delete string;
return e;
@ -39,7 +39,7 @@ Expr* makeStringLiteral(char* string) {
Expr* Expr::makeOpUnary(OperatorType op, Expr* expr) {
ALLOC_EXPR(e, eExprOperator);
ALLOC_EXPR(e, kExprOperator);
e->op_type = op;
e->expr = expr;
e->expr2 = NULL;
@ -47,7 +47,7 @@ Expr* Expr::makeOpUnary(OperatorType op, Expr* expr) {
}
Expr* Expr::makeOpBinary(Expr* expr1, OperatorType op, Expr* expr2) {
ALLOC_EXPR(e, eExprOperator);
ALLOC_EXPR(e, kExprOperator);
e->op_type = op;
e->op_char = 0;
e->expr = expr1;
@ -56,8 +56,8 @@ Expr* Expr::makeOpBinary(Expr* expr1, OperatorType op, Expr* expr2) {
}
Expr* Expr::makeOpBinary(Expr* expr1, char op, Expr* expr2) {
ALLOC_EXPR(e, eExprOperator);
e->op_type = TRIVIAL_OP;
ALLOC_EXPR(e, kExprOperator);
e->op_type = SIMPLE_OP;
e->op_char = op;
e->expr = expr1;
e->expr2 = expr2;

View File

@ -6,12 +6,12 @@
typedef enum {
eExprLiteralFloat,
eExprLiteralString,
eExprStar,
eExprColumnRef,
eExprFunctionRef,
eExprOperator
kExprLiteralFloat,
kExprLiteralString,
kExprStar,
kExprColumnRef,
kExprFunctionRef,
kExprOperator
} ExprType;
@ -22,7 +22,7 @@ typedef enum {
* <> <= >= LIKE ISNULL NOT
*/
typedef enum {
TRIVIAL_OP,
SIMPLE_OP,
// Binary
NOT_EQUALS,
LESS_EQ,

View File

@ -10,22 +10,22 @@
#include "Table.h"
typedef enum {
eSelect,
eDelete,
eInsert,
eCreate
} EStatementType;
kStmtSelect,
kStmtDelete,
kStmtInsert,
kStmtCreate
} StatementType;
struct Statement {
Statement(EStatementType type) : type(type) {};
Statement(StatementType type) : type(type) {};
EStatementType type;
StatementType type;
};
struct SelectStatement : Statement {
SelectStatement() : Statement(eSelect) {};
SelectStatement() : Statement(kStmtSelect) {};
TableRef* from_table;
List<Expr*>* select_list;

View File

@ -8,17 +8,17 @@ class SelectStatement;
* Holds reference to tables. Can be either table names or a select statement.
*/
typedef enum {
eTableName,
eTableSelect,
eTableCrossProduct
} ETableRefType;
kTableName,
kTableSelect,
kTableCrossProduct
} TableRefType;
typedef struct TableRef TableRef;
struct TableRef {
TableRef(ETableRefType type) : type(type) {}
TableRef(TableRefType type) : type(type) {}
ETableRefType type;
TableRefType type;
char* name;
SelectStatement* stmt;

View File

@ -14,13 +14,13 @@ void inprint(char val, uint num_indent) { printf("%s%c\n", indent(num_indent), v
void printTableRefInfo(TableRef* table, uint num_indent) {
switch (table->type) {
case eTableName:
case kTableName:
inprint(table->name, num_indent);
break;
case eTableSelect:
case kTableSelect:
printSelectStatementInfo(table->stmt, num_indent);
break;
case eTableCrossProduct:
case kTableCrossProduct:
for (TableRef* tbl : table->list->_vector) printTableRefInfo(tbl, num_indent);
break;
}
@ -30,7 +30,7 @@ void printOperatorExpression(Expr* expr, uint num_indent) {
if (expr == NULL) { inprint("null", num_indent); return; }
switch (expr->op_type) {
case TRIVIAL_OP: inprint(expr->op_char, num_indent); break;
case SIMPLE_OP: inprint(expr->op_char, num_indent); break;
case AND: inprint("AND", num_indent); break;
case OR: inprint("OR", num_indent); break;
case NOT: inprint("NOT", num_indent); break;
@ -42,12 +42,12 @@ void printOperatorExpression(Expr* expr, uint num_indent) {
void printExpression(Expr* expr, uint num_indent) {
switch (expr->type) {
case eExprStar: inprint("*", num_indent); break;
case eExprColumnRef: inprint(expr->name, num_indent); break;
case eExprLiteralFloat: inprint(expr->float_literal, num_indent); break;
case eExprLiteralString: inprint(expr->name, num_indent); break;
case eExprFunctionRef: /* todo */ break;
case eExprOperator: printOperatorExpression(expr, num_indent); break;
case kExprStar: inprint("*", num_indent); break;
case kExprColumnRef: inprint(expr->name, num_indent); break;
case kExprLiteralFloat: inprint(expr->float_literal, num_indent); break;
case kExprLiteralString: inprint(expr->name, num_indent); break;
case kExprFunctionRef: /* todo */ break;
case kExprOperator: printOperatorExpression(expr, num_indent); break;
default: fprintf(stderr, "Unrecognized expression type %d\n", expr->type); break;
}
}

View File

@ -21,7 +21,7 @@ int main(int argc, char *argv[]) {
continue;
}
if (stmt->type == eSelect) {
if (stmt->type == kStmtSelect) {
printSelectStatementInfo((SelectStatement*) stmt, 0);
} else {
fprintf(stderr, "Only Supporting Select Statements!\n");