-
Notifications
You must be signed in to change notification settings - Fork 32
/
ObParser.h
232 lines (205 loc) · 3.98 KB
/
ObParser.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// This file was automatically generated by Coco/R; don't modify it.
#if !defined(Ob_COCO_PARSER_H__)
#define Ob_COCO_PARSER_H__
#include <QStack>
#include <Oberon/ObSynTree.h>
#include "ObLexer.h"
namespace Ob {
class Parser {
private:
enum {
_EOF=0,
_T_Literals_=1,
_T_Hash=2,
_T_Dlr=3,
_T_Amp=4,
_T_Lpar=5,
_T_Latt=6,
_T_Rpar=7,
_T_Star=8,
_T_Ratt=9,
_T_StarGt=10,
_T_Plus=11,
_T_Comma=12,
_T_Minus=13,
_T_Dot=14,
_T_2Dot=15,
_T_Slash=16,
_T_2Slash=17,
_T_Colon=18,
_T_ColonEq=19,
_T_Semi=20,
_T_Lt=21,
_T_LtStar=22,
_T_Leq=23,
_T_Eq=24,
_T_Gt=25,
_T_Geq=26,
_T_Lbrack=27,
_T_Rbrack=28,
_T_Hat=29,
_T_Lbrace=30,
_T_Bar=31,
_T_Rbrace=32,
_T_Tilde=33,
_T_Keywords_=34,
_T_ARRAY=35,
_T_BEGIN=36,
_T_BY=37,
_T_CARRAY=38,
_T_CASE=39,
_T_CONST=40,
_T_CPOINTER=41,
_T_CSTRUCT=42,
_T_CUNION=43,
_T_DEFINITION=44,
_T_DIV=45,
_T_DO=46,
_T_ELSE=47,
_T_ELSIF=48,
_T_END=49,
_T_EXIT=50,
_T_FALSE=51,
_T_FOR=52,
_T_IF=53,
_T_IMPORT=54,
_T_IN=55,
_T_IS=56,
_T_LOOP=57,
_T_MOD=58,
_T_MODULE=59,
_T_NIL=60,
_T_OF=61,
_T_OR=62,
_T_POINTER=63,
_T_PROC=64,
_T_PROCEDURE=65,
_T_RECORD=66,
_T_REPEAT=67,
_T_RETURN=68,
_T_THEN=69,
_T_TO=70,
_T_TRUE=71,
_T_TYPE=72,
_T_UNSAFE=73,
_T_UNTIL=74,
_T_VAR=75,
_T_WEAK=76,
_T_WHILE=77,
_T_WITH=78,
_T_Specials_=79,
_T_ident=80,
_T_integer=81,
_T_real=82,
_T_string=83,
_T_hexchar=84,
_T_hexstring=85,
_T_Comment=86,
_T_Eof=87,
_T_MaxToken_=88
};
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, Ob::Errors* err, const char* ctx, const QString& = QString() );
public:
Ob::Lexer *scanner;
Ob::Errors *errors;
Ob::Token d_cur;
Ob::Token d_next;
QList<Ob::Token> d_comments;
struct TokDummy
{
int kind;
};
TokDummy d_dummy;
TokDummy *la; // lookahead token
int peek( quint8 la = 1 );
void RunParser();
Ob::SynTree d_root;
QStack<Ob::SynTree*> d_stack;
void addTerminal() {
if( d_cur.d_type != Ob::Tok_Semi && d_cur.d_type != Ob::Tok_Comma && d_cur.d_type != Ob::Tok_Dot && d_cur.d_type != Ob::Tok_Colon ){
Ob::SynTree* n = new Ob::SynTree( d_cur ); d_stack.top()->d_children.append(n);
}
}
Parser(Ob::Lexer *scanner,Ob::Errors*);
~Parser();
void SemErr(const char* msg);
void Oberon();
void module();
void definition();
void number();
void qualident();
void identdef();
void ConstDeclaration();
void ConstExpression();
void expression();
void TypeDeclaration();
void type();
void NamedType();
void ArrayType();
void RecordType();
void PointerType();
void ProcedureType();
void LengthList();
void length();
void BaseType();
void FieldListSequence();
void FieldList();
void IdentList();
void FormalParameters();
void VariableDeclaration();
void designator();
void selector();
void ExpList();
void SimpleExpression();
void relation();
void term();
void AddOperator();
void factor();
void MulOperator();
void literal();
void set();
void variableOrFunctionCall();
void element();
void statement();
void assignmentOrProcedureCall();
void IfStatement();
void CaseStatement();
void WithStatement();
void LoopStatement();
void ExitStatement();
void ReturnStatement();
void WhileStatement();
void RepeatStatement();
void ForStatement();
void StatementSequence();
void ElsifStatement();
void ElseStatement();
void Case();
void CaseLabelList();
void LabelRange();
void label();
void ElsifStatement2();
void Guard();
void ProcedureDeclaration();
void Receiver();
void ProcedureHeading();
void ProcedureBody();
void DeclarationSequence();
void DeclarationSequence2();
void FPSection();
void FormalType();
void ImportList();
void import();
void Parse();
}; // end Parser
} // namespace
#endif