-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompiler.h
60 lines (52 loc) · 1.49 KB
/
compiler.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
#ifndef COMPILER_H
#define COMPILER_H
#include <stack>
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <sstream>
#include <algorithm>
#include <fstream>
typedef struct{
long long int memoryStart;
long long int elementIndexAddres;
} VarType;
typedef struct{
std::string name;
long long int memoryAdress;
bool isInit;
bool isIterator;
bool isArray;
} CustomVariable;
typedef struct{
int placeInVector;
std::string name;
int memoryAdress;
int iterationsToFinishAddr;
} CustomIterator;
extern std::vector<CustomVariable> variables;
extern std::vector<std::string> ASMCode;
extern std::stack<long long int> jumpPlaces;
extern long long int memoryPointer;
extern std::stack<CustomIterator> iterators;
void yyerror(std::string s);
int yylex();
int yyparse();
void appendASMCode(std::string code);
void showASMCode();
void declareVariable(std::string var);
void declareArray(std::string array, long long int size);
bool isVariableDeclared(std::string var);
void setRegister(int registerNumber, long long int value);
std::string intToString(long long int value);
std::string binary(long long int x);
void saveCodeToFile();
void loadVarToRegister(VarType var, int registerNumber);
CustomVariable findVarByName(std::string name);
bool isIterator(long long int addr);
void setInitialized(long long int var);
bool isVariableInitialized(long long int var);
std::string findVariableNameByAddr(long long int var);
bool isArray(std::string name);
#endif