HyriseSQLParser/src/lib/Statement.h

82 lines
1.2 KiB
C
Raw Normal View History

2014-10-09 01:30:22 +02:00
/*
* Statement.h
* Definition of the structure used to build the syntax tree.
*/
#ifndef __STATEMENT_H__
#define __STATEMENT_H__
2014-10-20 22:33:36 +02:00
2014-10-09 04:09:47 +02:00
#include "Expr.h"
2014-10-09 01:30:22 +02:00
#include "List.h"
#include "Table.h"
2014-10-09 01:30:22 +02:00
namespace hsql {
2014-10-09 01:30:22 +02:00
typedef enum {
2014-11-04 00:02:40 +01:00
kStmtError,
2014-10-27 11:23:31 +01:00
kStmtSelect,
kStmtDelete,
kStmtInsert,
kStmtCreate
} StatementType;
2014-10-09 01:30:22 +02:00
typedef enum {
kOrderAsc,
kOrderDesc
} OrderType;
struct OrderDescription {
2014-10-27 14:54:15 +01:00
OrderDescription(OrderType type, Expr* expr) : type(type), expr(expr) {}
OrderType type;
Expr* expr;
};
2014-10-27 14:54:15 +01:00
const int64_t kNoLimit = -1;
const int64_t kNoOffset = -1;
struct LimitDescription {
LimitDescription(int64_t limit, int64_t offset) : limit(limit), offset(offset) {}
int64_t limit;
int64_t offset;
};
2014-10-27 14:54:15 +01:00
struct Statement {
2014-10-27 11:23:31 +01:00
Statement(StatementType type) : type(type) {};
2014-11-04 00:02:40 +01:00
2014-10-27 11:23:31 +01:00
StatementType type;
2014-11-04 00:02:40 +01:00
const char* parser_msg;
2014-10-09 01:30:22 +02:00
};
struct SelectStatement : Statement {
2014-10-27 11:23:31 +01:00
SelectStatement() : Statement(kStmtSelect) {};
2014-10-09 01:30:22 +02:00
2014-10-20 22:33:36 +02:00
TableRef* from_table;
List<Expr*>* select_list;
Expr* where_clause;
List<Expr*>* group_by;
2014-10-27 14:54:15 +01:00
OrderDescription* order;
LimitDescription* limit;
2014-10-09 01:30:22 +02:00
};
struct DeleteStatement : Statement {
// TODO
};
2014-10-09 01:30:22 +02:00
struct InsertStatement : Statement {
// TODO
};
2014-10-09 01:30:22 +02:00
struct CreateStatement : Statement {
// TODO
2014-10-09 01:30:22 +02:00
};
2014-10-20 22:33:36 +02:00
} // namespace hsql
2014-10-20 22:33:36 +02:00
#endif // __STATEMENT_H__