-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.h
124 lines (111 loc) · 2.06 KB
/
common.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
122
123
124
#ifndef COMMON
#define COMMON
#include <cstddef>
#include <cstdlib>
#include <stdio.h>
const size_t MAXCMDSIZE = 100;
extern const size_t NUMOFNAMES;
struct Configuration
{
size_t sizeOfScanf;
size_t sizeOfPrintf;
};
enum OP
{
UnknownOp = 0,
OP_ADD = 1,
OP_SUB = 2, // skkpped on purpose to split
OP_MUL = 4,
OP_DIV = 5,
OP_POW = 6,
OP_COS = 7,
OP_SIN = 8,
OP_LOG = 9,
OP_LN = 10,
OP_LBR = 11,
OP_RBR = 12,
OP_FRB = 13,
OP_FLB = 14,
OP_TER = 15,
OP_EQ = 16,
OP_COM = 17,
OP_BLW = 18,
OP_ABV = 19,
OP_IN = 20,
OP_OUT = 21,
// This is extension for bin translator
OP_IF = 22,
OP_RET = 23,
OP_VAR = 24,
OP_JMP = 25,
OP_PARIN = 26,
OP_PAROUT = 27,
OP_CALL = 28,
};
extern const char* ShortOpArray;
extern const char* FullOpArray[];
enum Type
{
Unknown = 0,
OP_t = 1,
Var_t = 2,
Num_t = 3,
Key_t = 4,
Func_t = 5,
BuiltIn_t = 6,
Pointer_t = 7,
};
enum VarType
{
global = 1,
local = 2,
};
struct Var
{
char* varName;
VarType varType;
};
enum NameType
{
KEY_TYPE = 1,
VAR_TYPE = 2,
FUNC_TYPE = 3,
};
struct Node
{
Type type;
OP opValue;
double numValue;
char* Name;
Var var;
Node* left;
Node* right;
};
struct Name
{
char* name;
NameType type;
size_t position;
};
struct NameTable
{
int numOfVars;
Name* data;
};
struct Utility
{
Node** tokenArray;
NameTable nameTable;
};
//Table Of Names
Name* tableAdd (char* name, Name* table);
Name* findInTable (char* name, Name* table);
void includeStdLib (Name* data, FILE* asmFile);
void initAsmFile (FILE* asmFile);
//Working with standart
void treePrint (const Node* node, FILE* DBFileptr);
Node* treeParse (Node* node, FILE* DBFileptr, NameTable* nameTable, Type type);
Node* getTreeFromStandart (const char* FileName);
Node* makeTreeStandartIn (Node* node);
Node* makeTreeStandartOut (Node* node);
#endif