-
Notifications
You must be signed in to change notification settings - Fork 15
/
LjasParser.h
211 lines (185 loc) · 3.33 KB
/
LjasParser.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
// This file was automatically generated by Coco/R; don't modify it.
#if !defined(Ljas_COCO_PARSER_H__)
#define Ljas_COCO_PARSER_H__
#include <QStack>
#include <LjTools/LjasSynTree.h>
#define PARSER_NS Ljas
#include <LjTools/LjasLexer.h>
namespace Ljas {
class Parser {
private:
enum {
_EOF=0,
_T_Literals_=1,
_T_Lpar=2,
_T_Rpar=3,
_T_2Minus=4,
_T_2MinusLbrack=5,
_T_Dot=6,
_T_Colon=7,
_T_Eq=8,
_T_Rbrack2Minus=9,
_T_Lbrace=10,
_T_Rbrace=11,
_T_Keywords_=12,
_T_ADD=13,
_T_CALL=14,
_T_CALLT=15,
_T_CAT=16,
_T_DIV=17,
_T_FNEW=18,
_T_FORI=19,
_T_FORL=20,
_T_GGET=21,
_T_GSET=22,
_T_ISEQ=23,
_T_ISF=24,
_T_ISFC=25,
_T_ISGE=26,
_T_ISGT=27,
_T_ISLE=28,
_T_ISLT=29,
_T_ISNE=30,
_T_IST=31,
_T_ISTC=32,
_T_JMP=33,
_T_KNIL=34,
_T_KSET=35,
_T_LEN=36,
_T_LOOP=37,
_T_MOD=38,
_T_MOV=39,
_T_MUL=40,
_T_NOT=41,
_T_POW=42,
_T_RET=43,
_T_SUB=44,
_T_TDUP=45,
_T_TGET=46,
_T_TNEW=47,
_T_TSET=48,
_T_UCLO=49,
_T_UGET=50,
_T_UNM=51,
_T_USET=52,
_T_begin=53,
_T_const=54,
_T_end=55,
_T_false=56,
_T_function=57,
_T_nil=58,
_T_true=59,
_T_var=60,
_T_Specials_=61,
_T_ident=62,
_T_string=63,
_T_real=64,
_T_posint=65,
_T_negint=66,
_T_Comment=67,
_T_Eof=68,
_T_MaxToken_=69
};
int maxT;
int errDist;
int minErrDist;
void SynErr(int n, const char* ctx = 0);
void Get();
void Expect(int n, const char* ctx = 0);
bool StartOf(int s);
void ExpectWeak(int n, int follow);
bool WeakSeparator(int n, int syFol, int repFol);
void SynErr(const QString& sourcePath, int line, int col, int n, PARSER_NS::Errors* err, const char* ctx, const QString& = QString() );
public:
PARSER_NS::Lexer *scanner;
PARSER_NS::Errors *errors;
PARSER_NS::Token d_cur;
PARSER_NS::Token d_next;
QList<PARSER_NS::Token> d_comments;
struct TokDummy
{
int kind;
};
TokDummy d_dummy;
TokDummy *la; // lookahead token
int peek( quint8 la = 1 );
void RunParser()
{
d_stack.push(&d_root);
Parse();
d_stack.pop();
}
Ljas::SynTree d_root;
QStack<Ljas::SynTree*> d_stack;
void addTerminal() {
Ljas::SynTree* n = new Ljas::SynTree( d_cur ); d_stack.top()->d_children.append(n);
}
Parser(PARSER_NS::Lexer *scanner,PARSER_NS::Errors*);
~Parser();
void SemErr(const char* msg);
void LjAsm();
void function_decl();
void fname();
void function_header();
void function_body();
void formal_params();
void const_decls();
void var_decls();
void labelDef();
void statement();
void label();
void vname();
void var_decl();
void record();
void nameWithPreset();
void cname();
void const_val();
void number();
void primitive();
void table_literal();
void desig();
void ISLT_();
void ISGE_();
void ISLE_();
void ISGT_();
void ISEQ_();
void ISNE_();
void ISTC_();
void ISFC_();
void IST_();
void ISF_();
void MOV_();
void NOT_();
void UNM_();
void LEN_();
void ADD_();
void SUB_();
void MUL_();
void DIV_();
void MOD_();
void POW_();
void CAT_();
void KSET_();
void KNIL_();
void UGET_();
void USET_();
void UCLO_();
void FNEW_();
void TNEW_();
void TDUP_();
void GGET_();
void GSET_();
void TGET_();
void TSET_();
void CALL_();
void CALLT_();
void RET_();
void FORI_();
void FORL_();
void LOOP_();
void JMP_();
void integer();
void Parse();
}; // end Parser
} // namespace
#endif