Skip to content
Snippets Groups Projects
Commit ab6a1af8 authored by expan's avatar expan
Browse files

Change naming for table assignments and select

parent fe17b66a
No related branches found
No related tags found
No related merge requests found
...@@ -62,11 +62,11 @@ Body ...@@ -62,11 +62,11 @@ Body
TablePath TablePath
: TableIdentifier VarIdentifier : TableIdentifier VarIdentifier
{ printf("last table path\n"); { printf("last table path\n");
$$ = create_atom_operator($1, $2); $$ = create_assign_operator($1, $2);
} }
| TableIdentifier VarIdentifier ',' TablePath | TableIdentifier VarIdentifier ',' TablePath
{ printf("table path2\n"); { printf("table path2\n");
$$ = create_cross_operator(create_atom_operator($1, $2), $4); $$ = create_cross_operator(create_assign_operator($1, $2), $4);
} }
; ;
...@@ -89,11 +89,11 @@ Select_List ...@@ -89,11 +89,11 @@ Select_List
} }
| Col | Col
{ printf("select list attr path\n"); { printf("select list attr path\n");
$$ = create_assign_operator($1, NULL); $$ = create_rename_operator($1, NULL);
} }
| Col ',' Select_List | Col ',' Select_List
{ printf("Select list\n"); { printf("Select list\n");
$$ = create_assign_operator($1, $2); $$ = create_rename_operator($1, $2);
} }
; ;
......
...@@ -122,29 +122,24 @@ cons_cell* create_cross_operator(cons_cell* ra1, cons_cell* ra2) { ...@@ -122,29 +122,24 @@ cons_cell* create_cross_operator(cons_cell* ra1, cons_cell* ra2) {
// For when you want to assign column names to another name // For when you want to assign column names to another name
// THIS DOESN"T WORK FOR JASON"S COMPILER SO REVERTING BACK BUT LEFT HERE IN CASE WE NEED IT LATER XD // THIS DOESN"T WORK FOR JASON"S COMPILER SO REVERTING BACK BUT LEFT HERE IN CASE WE NEED IT LATER XD
//cons_cell* create_rename_operator(cons_cell* column, cons_cell* var, cons_cell* next) { cons_cell* create_rename_operator(cons_cell* col, cons_cell* next) {
// cons_cell* new_name_cons = create_cons_cell(var, next); cons_cell* original_cons = create_cons_cell(col, next);
// cons_cell* original_cons = create_cons_cell(column, new_name_cons); char operator[7] = "RENAME\0";
// char operator[7] = "RENAME\0"; cons_cell* operator_cons = create_cons_cell_w_atom(operator, original_cons);
// cons_cell* operator_cons = create_cons_cell_w_atom(operator, original_cons); return operator_cons;
// return operator_cons; }
//}
// For when you want to assign a var to a table // For when you want to assign a var to a table
cons_cell* create_assign_operator(cons_cell* spcol, cons_cell* next) { cons_cell* create_assign_operator(cons_cell* table, cons_cell* var) {
// cdr to get to cons atom, car to get atom itself // cdr to get to cons atom, car to get atom itself
// cons_cell* new_name_cons = create_cons_cell(var, NULL); cons_cell* var_cons = create_cons_cell(var, NULL);
// cons_cell* original_cons = create_cons_cell(table, new_name_cons); cons_cell* assign_cons = create_cons_cell(table, var);
cons_cell* sp_col_cons = create_cons_cell(spcol, next);
char operator[3] = "AS\0"; char operator[3] = "AS\0";
cons_cell* operator_cons = create_cons_cell_w_atom(operator, sp_col_cons); cons_cell* operator_cons = create_cons_cell_w_atom(operator, assign_cons);
return operator_cons; return operator_cons;
} }
cons_cell* create_proj_operator(cons_cell* assign, cons_cell* ra) { cons_cell* create_proj_operator(cons_cell* assign, cons_cell* ra) {
if (ra == NULL) {
printf("WTF");
}
cons_cell* ra_cons = create_cons_cell(ra, NULL); cons_cell* ra_cons = create_cons_cell(ra, NULL);
cons_cell* assign_cons = create_cons_cell(assign, ra_cons); cons_cell* assign_cons = create_cons_cell(assign, ra_cons);
char operator[5] = "PROJ\0"; char operator[5] = "PROJ\0";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment