forked from VastlyBlank/5300-Ocelot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParseTreeToString.h
executable file
·44 lines (39 loc) · 1.44 KB
/
ParseTreeToString.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @file ParseTreeToString.h - SQL unparsing class
* @author Kevin Lundeen
* @see "Seattle University, CPSC5300, Summer 2018"
*/
#pragma once
#include <string>
#include <vector>
#include "SQLParser.h"
/**
* @class ParseTreeToString - class for unparsing a Hyrise Abstract Syntax Tree
*/
class ParseTreeToString {
public:
/**
* Unparse a Hyrise AST into an SQL statement.
* @param statement Hyrise AST pointer
* @returns string of the SQL statement equivalent to what was parsed
*/
static std::string statement(const hsql::SQLStatement* statement);
/**
* Check if a given word is a reserved word in our version of SQL.
*/
static bool is_reserved_word(std::string word);
private:
// reserved words
static const std::vector<std::string> reserved_words;
// sub-expressions
static std::string operator_expression(const hsql::Expr *expr);
static std::string expression(const hsql::Expr *expr);
static std::string table_ref(const hsql::TableRef *table);
static std::string column_definition(const hsql::ColumnDefinition *col);
static std::string select(const hsql::SelectStatement *stmt);
static std::string insert(const hsql::InsertStatement *stmt);
static std::string del(const hsql::DeleteStatement *stmt);
static std::string create(const hsql::CreateStatement *stmt);
static std::string drop(const hsql::DropStatement *stmt);
static std::string show(const hsql::ShowStatement *stmt);
};