-
Notifications
You must be signed in to change notification settings - Fork 0
/
mstparser.h
123 lines (106 loc) · 2.06 KB
/
mstparser.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
#include "hashtable.cpp"
#include "mightstone.h"
#include <string>
#include <vector>
#include <variant>
enum MSTP_Oprt {
MSTP_Set,
MSTP_Add,
MSTP_Sub,
MSTP_Mul,
MSTP_Div,
MSTP_Pow,
MSTP_BAnd,
MSTP_BOr,
MSTP_Xor,
MSTP_LAnd,
MSTP_LOr,
MSTP_BNot,
MSTP_LNot,
MSTP_Equal,
MSTP_NE,
MSTP_Greater,
MSTP_GE,
MSTP_Lesser,
MSTP_LE,
MSTP_ShiftL,
MSTP_ShiftR,
MSTP_BracketL,
MSTP_BracketR,
MSTP_ParenL,
MSTP_ParenR,
MSTP_Space,
MSTP_Tab,
MSTP_NL,
MSTP_Colon,
MSTP_Comma,
MSTP_Hex,
MSTP_Dollar,
MSTP_DollarEq,
MSTP_CurlyBracketL,
MSTP_CurlyBracketR,
MSTP_PlusColon,
MSTP_MinusColon,
MSTP_Piriod,
MSTP_Semicolon,
MSTP_ColonSemicolon,
MSTP_SetAdd,
MSTP_SetSub,
MSTP_SetMul,
MSTP_SetDiv,
MSTP_SetPow,
MSTP_SetBAnd,
MSTP_SetBOr,
MSTP_SetXor,
MSTP_SetLAnd,
MSTP_SetLOr
};
enum MSTP_ResWord {
MSTP_In,
MSTP_Out,
MSTP_IO,
MSTP_At,
MSTP_Pos,
MSTP_Neg,
MSTP_Defun,
MSTP_If,
MSTP_Else,
MSTP_Elif,
MSTP_For,
MSTP_Deftask,
MSTP_ClockWork
};
struct MSTP_TokenInfo;
typedef struct MSTP_TokenInfo MSTP_TokenInfo;
typedef struct MSTP_Token{
MSTP_TokenInfo* Info;
char* Pos;
int Len;
} MSTP_Token;
typedef struct MSTP_TokenInfo {
int OprtID;
int WordID;
} MSTP_TokenInfo;
class MST_Parser {
private:
HashTable<MSTP_TokenInfo*> OprtTable;
HashTable<MSTP_TokenInfo*> WordTable;
vector<MSTP_TokenInfo*> Operators;
vector<MSTP_TokenInfo*> Words;
int Error = 0;
int Mode = 0;
MST_Object* CwkCnt = NULL;
int nState = 0;
int CLFlag = 0;
vector<variant<MSTP_TokenInfo*, MST_Object*>> ParseExpr(vector<variant<MSTP_TokenInfo*, MST_Object*>> list, int mode);
public:
MST_Parser();
~MST_Parser();
vector<MST_Object*> Parse(char* src);
vector<MST_Object*> Read();
int SetMode(int m);
};
vector<MST_Object*> MSTP_Parse(char* src);
vector<MST_Object*> MSTP_Read();
MST_Object* TimingChart(int nargs, MST_Object** args);
int MSTP_SetMode(int m);