This commit is contained in:
Pedro 2014-10-08 19:09:47 -07:00
parent 592d427f7a
commit 0e5477f916
5 changed files with 25 additions and 25 deletions

View File

@ -42,10 +42,10 @@ typedef void* yyscan_t;
Statement* statement; Statement* statement;
SelectStatement* select_statement; SelectStatement* select_statement;
TableRef* table; TableRef* table;
Expression* expr; Expr* expr;
List<char*>* slist; List<char*>* slist;
List<Expression*>* explist; List<Expr*>* explist;
} }
%token SELECT FROM GROUP BY WHERE NOT AND OR %token SELECT FROM GROUP BY WHERE NOT AND OR
@ -131,15 +131,15 @@ comparison_predicate:
expr: expr:
column_name { $$ = new Expression($1); } column_name { $$ = new Expr($1); }
| NAME '(' column_name ')' { $$ = new Expression($3, $1); } | NAME '(' column_name ')' { $$ = new Expr($3, $1); }
; ;
/* Lists */ /* Lists */
expr_list: expr_list:
expr { $$ = new List<Expression*>($1); } expr { $$ = new List<Expr*>($1); }
| expr_list ',' expr { $1->push_back($3); $$ = $1; } | expr_list ',' expr { $1->push_back($3); $$ = $1; }
; ;

17
src/lib/Expr.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef __EXPRESSION_H__
#define __EXPRESSION_H__
#include <cstdlib>
class Expr {
public:
Expr(char* name) : name(name), func_name(NULL) {};
Expr(char* name, char* func_name) : name(name), func_name(func_name) {};
char* name;
char* func_name;
};
#endif

View File

@ -1,17 +0,0 @@
#ifndef __EXPRESSION_H__
#define __EXPRESSION_H__
#include <cstdlib>
class Expression {
public:
Expression(char* name) : name(name), func_name(NULL) {};
Expression(char* name, char* func_name) : name(name), func_name(func_name) {};
char* name;
char* func_name;
};
#endif

View File

@ -5,7 +5,7 @@
#ifndef __STATEMENT_H__ #ifndef __STATEMENT_H__
#define __STATEMENT_H__ #define __STATEMENT_H__
#include "Expression.h" #include "Expr.h"
#include "List.h" #include "List.h"
class TableRef; class TableRef;
@ -32,8 +32,8 @@ public:
SelectStatement(); SelectStatement();
TableRef* _from_table; TableRef* _from_table;
List<Expression*>* _select_list; List<Expr*>* _select_list;
List<Expression*>* _group_by; List<Expr*>* _group_by;
}; };