-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAST.h
More file actions
34 lines (26 loc) · 738 Bytes
/
AST.h
File metadata and controls
34 lines (26 loc) · 738 Bytes
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
#ifndef AST_H
#define AST_H
#include <string>
#include <vector>
#include <iostream>
#include <cmath>
#include "SymTable.h"
using namespace std;
class SymTable;
class ASTNode {
public:
ASTNode *left, *right;
string root;
string type;
Value val;
bool isLiteral;
ASTNode(string op, ASTNode* l, ASTNode* r) : root(op), left(l), right(r), isLiteral(false) {}
ASTNode(Value v) : root(""), left(nullptr), right(nullptr), val(v), type(v.type), isLiteral(true) {}
ASTNode(string name, string t) : root(name), left(nullptr), right(nullptr), type(t), isLiteral(false) {}
virtual ~ASTNode() {
if (left) delete left;
if (right) delete right;
}
Value eval(SymTable* table);
};
#endif