-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParseTree.h
121 lines (84 loc) · 2.61 KB
/
ParseTree.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef ParseFunc
#define ParseFunc
// these are the types of operands that can appear in a CNF expression
#define DOUBLE 1
#define INT 2
#define NAME 3
#define STRING 4
#define LESS_THAN 5
#define GREATER_THAN 6
#define EQUALS 7
// used in computational (funcional) expressions
struct FuncOperand {
// this tells us the type of the operand: FLOAT, INT, STRING...
int code;
// this is the actual operand
char *value;
};
struct FuncOperator {
// this tells us which operator to use: '+', '-', ...
int code;
// these are the operators on the left and on the right
struct FuncOperator *leftOperator;
struct FuncOperand *leftOperand;
struct FuncOperator *right;
};
struct TableList {
// this is the original table name
char *tableName;
// this is the value it is aliased to
char *aliasAs;
// and this the next alias
struct TableList *next;
};
struct SchemaList {
// this is the original attribute name
char *attName;
// this is the type
char *type;
// and this the next alias
struct SchemaList *next;
};
struct CreateTableType{
char* heapOrSorted; // "HEAP": create the database as a heap dbfile
// "SORTED": create the database as a sorted dbfile
struct AndList *sortingAtts; // the set of attributes in CREATE TABLE that we are sorting on (if sorted file;
// if heap, this is NULL)
};
struct NameList {
// this is the name
char *name;
// and this is the next name in the list
struct NameList *next;
};
// used in boolean expressions... there's no reason to have both this
// and FuncOperand, but both are here for legacy reasons!!
struct Operand {
// this tells us the type of the operand: FLOAT, INT, STRING...
int code;
// this is the actual operand
char *value;
};
struct ComparisonOp {
// this corresponds to one of the codes describing what type
// of literal value we have in this nodes: LESS_THAN, EQUALS...
int code;
// these are the operands on the left and on the right
struct Operand *left;
struct Operand *right;
};
struct OrList {
// this is the comparison to the left of the OR
struct ComparisonOp *left;
// this is the OrList to the right of the OR; again,
// this might be NULL if the right is a simple comparison
struct OrList *rightOr;
};
struct AndList {
// this is the disjunction to the left of the AND
struct OrList *left;
// this is the AndList to the right of the AND
// note that this can be NULL if the right is a disjunction
struct AndList *rightAnd;
};
#endif