-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParserbase.h
195 lines (167 loc) · 3.9 KB
/
Parserbase.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
// Generated by Bisonc++ V5.02.00 on Wed, 15 Jan 2020 17:40:01 +0100
#ifndef ParserBase_h_included
#define ParserBase_h_included
#include <exception>
#include <vector>
#include <iostream>
// $insert preincludes
#include "semantics.h"
namespace // anonymous
{
struct PI__;
}
class ParserBase
{
public:
enum DebugMode__
{
OFF = 0,
ON = 1 << 0,
ACTIONCASES = 1 << 1
};
// $insert tokens
// Symbolic tokens:
enum Tokens__
{
VALOS_SZAMKONSTANS = 257,
SZAMKONSTANS,
PROGRAM,
VALTOZOK,
UTASITASOK,
PROGRAM_VEGE,
HA,
AKKOR,
KULONBEN,
HA_VEGE,
CIKLUS,
AMIG,
CIKLUS_VEGE,
BE,
KI,
EGESZ,
VALOS,
LOGIKAI,
ERTEKADAS,
BALZAROJEL,
JOBBZAROJEL,
AZONOSITO,
IGAZ,
HAMIS,
SKIP,
EGESZRESZ,
TORTRESZ,
VAGY,
ES,
NEM,
EGYENLO,
KISEBB,
NAGYOBB,
KISEBBEGYENLO,
NAGYOBBEGYENLO,
PLUSZ,
MINUSZ,
SZORZAS,
OSZTAS,
MARADEK,
};
// $insert LTYPE
struct LTYPE__
{
int timestamp;
int first_line;
int first_column;
int last_line;
int last_column;
char *text;
};
// $insert STYPE
union STYPE__
{
std::string *szoveg;
kifejezes_leiro *kif;
utasitas_leiro *utasitas;
};
private:
int d_stackIdx__ = -1;
std::vector<size_t> d_stateStack__;
std::vector<STYPE__> d_valueStack__;
// $insert LTYPEstack
std::vector<LTYPE__> d_locationStack__;
protected:
enum Return__
{
PARSE_ACCEPT__ = 0, // values used as parse()'s return values
PARSE_ABORT__ = 1
};
enum ErrorRecovery__
{
DEFAULT_RECOVERY_MODE__,
UNEXPECTED_TOKEN__,
};
bool d_actionCases__ = false;
bool d_debug__ = true;
size_t d_nErrors__ = 0;
size_t d_requiredTokens__;
size_t d_acceptedTokens__;
int d_token__;
int d_nextToken__;
size_t d_state__;
STYPE__ *d_vsp__;
STYPE__ d_val__;
STYPE__ d_nextVal__;
// $insert LTYPEdata
LTYPE__ d_loc__;
LTYPE__ *d_lsp__;
ParserBase();
void ABORT() const;
void ACCEPT() const;
void ERROR() const;
void clearin();
bool actionCases() const;
bool debug() const;
void pop__(size_t count = 1);
void push__(size_t nextState);
void popToken__();
void pushToken__(int token);
void reduce__(PI__ const &productionInfo);
void errorVerbose__();
size_t top__() const;
public:
void setDebug(bool mode);
void setDebug(DebugMode__ mode);
};
inline ParserBase::DebugMode__ operator|(ParserBase::DebugMode__ lhs,
ParserBase::DebugMode__ rhs)
{
return static_cast<ParserBase::DebugMode__>(static_cast<int>(lhs) | rhs);
};
inline bool ParserBase::debug() const
{
return d_debug__;
}
inline bool ParserBase::actionCases() const
{
return d_actionCases__;
}
inline void ParserBase::ABORT() const
{
throw PARSE_ABORT__;
}
inline void ParserBase::ACCEPT() const
{
throw PARSE_ACCEPT__;
}
inline void ParserBase::ERROR() const
{
throw UNEXPECTED_TOKEN__;
}
inline ParserBase::DebugMode__ operator&(ParserBase::DebugMode__ lhs,
ParserBase::DebugMode__ rhs)
{
return static_cast<ParserBase::DebugMode__>(
static_cast<int>(lhs) & rhs);
}
// For convenience, when including ParserBase.h its symbols are available as
// symbols in the class Parser, too.
#define Parser ParserBase
#endif