-
Notifications
You must be signed in to change notification settings - Fork 0
/
AbstractSyntaxTree.hpp
50 lines (39 loc) · 1.14 KB
/
AbstractSyntaxTree.hpp
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
#ifndef ABSTRACTSYNTAXTREE_HPP
#define ABSTRACTSYNTAXTREE_HPP
#include "ProgramLanguage.hpp"
#include <cstdio>
class AbstractSyntaxTree {
public:
struct Node {
enum class Type {
FunctionDeclaration,
FunctionImplementation,
FunctionImplementationParameter,
Variable,
Concatenation,
If,
While,
AssignmentOperator,
FunctionCallOperator,
FunctionCallParameter,
ReturnOperator,
MathematicalOperator,
Number
} type;
union {
const char *identifier;
char mathematicalOperator[3];
double number;
} data;
Node *left;
Node *right;
} *root;
AbstractSyntaxTree();
void AbstractSyntaxTreeDtor();
static void deleteRecursively(Node **node);
void dumpToText(const char *outputFileName) const;
static void dumpToTextRecursively(std::FILE *outputFile, Node *node);
static Node *copySubtreeRecursively(const Node *node);
Node *createNumberNode(double number);
};
#endif /* ABSTRACTSYNTAXTREE_HPP */