-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflattenst.hpp
More file actions
77 lines (70 loc) · 2.54 KB
/
flattenst.hpp
File metadata and controls
77 lines (70 loc) · 2.54 KB
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
#ifndef FLATTENST_HPP
#define FLATTENST_HPP
#include <cstring>
#include <fstream>
#include <iostream>
#include <stack>
#include <list>
#include <vector>
using namespace std;
struct CSEMachineNode { // Node abstraction for the CSE machine for both the control and stack
string nameValue;
bool isName; //whether it's an identifier
bool isString;
string stringValue;
bool isGamma;
bool isLambda;
std::vector<string> boundVariables;
int indexOfBodyOfLambda; //index of the controlStructure of this lambda expression
bool isTau; //refers to the control stack variable which will convert stack elements to tuple
int numberOfElementsInTauTuple;
bool isTuple; //refers to the CSE stack structure variable containing variables
std::vector<CSEMachineNode> tupleElements; //can be either int/bool/string
bool isComma;
bool isEnvironmentMarker;
int environmentMarkerIndex; //for a lambda, it means the environment in which it was placed on the stack.
bool isInt;
int intValue;
bool isConditional;
bool isUnaryOperator;
bool isBinaryOperator;
string operatorStringValue;
string defaultLabel;
bool isBoolean;
bool isBuiltInFunction;
bool isY;
bool isYF;
bool isDummy;
CSEMachineNode() {
isName = false;
isString = false;
isGamma = false;
isLambda = false;
isTau = false;
isEnvironmentMarker = false;
isInt = false;
isConditional = false;
isUnaryOperator = false;
isBinaryOperator = false;
isComma = false;
isBoolean = false;
isBuiltInFunction = false;
isTuple = false;
isY = false;
isYF = false;
isDummy = false;
}
};
struct EnvironmentNode { //Node abstraction for an environment marker in the CSE machine
EnvironmentNode *parentEnvironment;
EnvironmentNode *previousEnvironment;
CSEMachineNode boundedValuesNode;
//the bounded values node will have the bounded variable mappings from the boundedVariables string vector to the tupleElements CSEMachineNode vector.
// boundedVariables (string) -> tupleElements (CSEMachineNode) [the tupleElement could be int/string/Lambda]
int environmentIndex;
};
extern vector<list<CSEMachineNode>> controlStructures; // Declaration of the 'controlStructures' vector
extern int numberOfControlStructures;
void recursivelyFlattenTree(Node *treeNode, list<CSEMachineNode> *controlStructure, int controlStructureIndex,bool processKid, bool processSiblings);
void flattenStandardizedTree();
#endif