4
|
1 /* A Bison parser, made by GNU Bison 2.3. */
|
|
2
|
|
3 /* Skeleton interface for Bison LALR(1) parsers in C++
|
|
4
|
|
5 Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
|
6
|
|
7 This program is free software; you can redistribute it and/or modify
|
|
8 it under the terms of the GNU General Public License as published by
|
|
9 the Free Software Foundation; either version 2, or (at your option)
|
|
10 any later version.
|
|
11
|
|
12 This program is distributed in the hope that it will be useful,
|
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 GNU General Public License for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with this program; if not, write to the Free Software
|
|
19 Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
20 Boston, MA 02110-1301, USA. */
|
|
21
|
|
22 /* As a special exception, you may create a larger work that contains
|
|
23 part or all of the Bison parser skeleton and distribute that work
|
|
24 under terms of your choice, so long as that work isn't itself a
|
|
25 parser generator using the skeleton or a modified version thereof
|
|
26 as a parser skeleton. Alternatively, if you modify or redistribute
|
|
27 the parser skeleton itself, you may (at your option) remove this
|
|
28 special exception, which will cause the skeleton and the resulting
|
|
29 Bison output files to be licensed under the GNU General Public
|
|
30 License without this special exception.
|
|
31
|
|
32 This special exception was added by the Free Software Foundation in
|
|
33 version 2.2 of Bison. */
|
|
34
|
|
35 /* C++ LALR(1) parser skeleton written by Akim Demaille. */
|
|
36
|
|
37 #ifndef PARSER_HEADER_H
|
|
38 # define PARSER_HEADER_H
|
|
39
|
|
40 #include <string>
|
|
41 #include <iostream>
|
|
42 #include "stack.hh"
|
|
43
|
|
44 namespace yy
|
|
45 {
|
|
46 class position;
|
|
47 class location;
|
|
48 }
|
|
49
|
|
50 /* First part of user declarations. */
|
|
51 #line 4 "script-parser.yy"
|
|
52
|
|
53 #ifdef _MSC_VER
|
|
54 #pragma warning(disable: 4800)
|
|
55 #pragma warning(disable: 4267)
|
|
56 #endif
|
|
57
|
|
58 #include <string>
|
|
59 #include "node.h"
|
|
60 class compiler;
|
|
61
|
|
62
|
5
|
63 /* Line 303 of lalr1.cc. */
|
4
|
64 #line 65 "script-parser.hh"
|
|
65
|
|
66 #include "location.hh"
|
|
67
|
|
68 /* Enabling traces. */
|
|
69 #ifndef YYDEBUG
|
|
70 # define YYDEBUG 0
|
|
71 #endif
|
|
72
|
|
73 /* Enabling verbose error messages. */
|
|
74 #ifdef YYERROR_VERBOSE
|
|
75 # undef YYERROR_VERBOSE
|
|
76 # define YYERROR_VERBOSE 1
|
|
77 #else
|
|
78 # define YYERROR_VERBOSE 1
|
|
79 #endif
|
|
80
|
|
81 /* Enabling the token table. */
|
|
82 #ifndef YYTOKEN_TABLE
|
|
83 # define YYTOKEN_TABLE 0
|
|
84 #endif
|
|
85
|
|
86 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
|
87 If N is 0, then set CURRENT to the empty location which ends
|
|
88 the previous symbol: RHS[0] (always defined). */
|
|
89
|
|
90 #ifndef YYLLOC_DEFAULT
|
|
91 # define YYLLOC_DEFAULT(Current, Rhs, N) \
|
|
92 do { \
|
|
93 if (N) \
|
|
94 { \
|
|
95 (Current).begin = (Rhs)[1].begin; \
|
|
96 (Current).end = (Rhs)[N].end; \
|
|
97 } \
|
|
98 else \
|
|
99 { \
|
|
100 (Current).begin = (Current).end = (Rhs)[0].end; \
|
|
101 } \
|
|
102 } while (false)
|
|
103 #endif
|
|
104
|
|
105 namespace yy
|
|
106 {
|
|
107
|
|
108 /// A Bison parser.
|
|
109 class script_parser
|
|
110 {
|
|
111 public:
|
|
112 /// Symbol semantic values.
|
|
113 #ifndef YYSTYPE
|
|
114 union semantic_type
|
|
115 #line 27 "script-parser.yy"
|
|
116 {
|
|
117 int ival;
|
|
118 std::string *sval;
|
|
119
|
|
120 int type;
|
|
121 CValueList *value_list;
|
|
122 CArgList *arglist;
|
|
123 CDeclList *decls;
|
|
124 CStateList *states;
|
|
125 CStatement *statement;
|
|
126 CArgDef *argdef;
|
|
127 CArgs *args;
|
|
128 CValueNode *value;
|
|
129 CNode *expr;
|
|
130 CAssign *assign;
|
|
131 CStateBlock *block;
|
|
132 }
|
5
|
133 /* Line 303 of lalr1.cc. */
|
4
|
134 #line 135 "script-parser.hh"
|
|
135 ;
|
|
136 #else
|
|
137 typedef YYSTYPE semantic_type;
|
|
138 #endif
|
|
139 /// Symbol locations.
|
|
140 typedef location location_type;
|
|
141 /// Tokens.
|
|
142 struct token
|
|
143 {
|
|
144 /* Tokens. */
|
|
145 enum yytokentype {
|
|
146 END_OF_FILE = 0,
|
|
147 TK_IVAL = 258,
|
|
148 TK_IDENTIFIER = 259,
|
|
149 TK_SVAL = 260,
|
|
150 TK_LOGOR = 261,
|
|
151 TK_LOGAND = 262,
|
|
152 TK_EQ = 263,
|
|
153 TK_NE = 264,
|
|
154 TK_GE = 265,
|
|
155 TK_LE = 266,
|
|
156 TK_LSHIFT = 267,
|
|
157 TK_RSHIFT = 268,
|
|
158 TK_ADD_ASSIGN = 269,
|
|
159 TK_SUB_ASSIGN = 270,
|
|
160 TK_MUL_ASSIGN = 271,
|
|
161 TK_DIV_ASSIGN = 272,
|
|
162 TK_MOD_ASSIGN = 273,
|
|
163 TK_IF = 274,
|
|
164 TK_ELSE = 275,
|
|
165 TK_WHILE = 276,
|
|
166 TK_FOR = 277,
|
|
167 TK_SWITCH = 278,
|
|
168 TK_CASE = 279,
|
|
169 TK_DEFAULT = 280,
|
|
170 TK_BREAK = 281,
|
|
171 TK_RETURN = 282,
|
|
172 TK_INTEGER = 283,
|
|
173 TK_STRING = 284,
|
|
174 TK_VOID = 285,
|
6
|
175 TK_GOTO = 286,
|
|
176 TK_CODE = 287,
|
|
177 TK_EXIT = 288,
|
|
178 NEG = 289
|
4
|
179 };
|
|
180
|
|
181 };
|
|
182 /// Token type.
|
|
183 typedef token::yytokentype token_type;
|
|
184
|
|
185 /// Build a parser object.
|
|
186 script_parser (compiler& driver_yyarg);
|
|
187 virtual ~script_parser ();
|
|
188
|
|
189 /// Parse.
|
|
190 /// \returns 0 iff parsing succeeded.
|
|
191 virtual int parse ();
|
|
192
|
|
193 /// The current debugging stream.
|
|
194 std::ostream& debug_stream () const;
|
|
195 /// Set the current debugging stream.
|
|
196 void set_debug_stream (std::ostream &);
|
|
197
|
|
198 /// Type for debugging levels.
|
|
199 typedef int debug_level_type;
|
|
200 /// The current debugging level.
|
|
201 debug_level_type debug_level () const;
|
|
202 /// Set the current debugging level.
|
|
203 void set_debug_level (debug_level_type l);
|
|
204
|
|
205 private:
|
|
206 /// Report a syntax error.
|
|
207 /// \param loc where the syntax error is found.
|
|
208 /// \param msg a description of the syntax error.
|
|
209 virtual void error (const location_type& loc, const std::string& msg);
|
|
210
|
|
211 /// Generate an error message.
|
|
212 /// \param state the state where the error occurred.
|
|
213 /// \param tok the look-ahead token.
|
|
214 virtual std::string yysyntax_error_ (int yystate, int tok);
|
|
215
|
|
216 #if YYDEBUG
|
|
217 /// \brief Report a symbol value on the debug stream.
|
|
218 /// \param yytype The token type.
|
|
219 /// \param yyvaluep Its semantic value.
|
|
220 /// \param yylocationp Its location.
|
|
221 virtual void yy_symbol_value_print_ (int yytype,
|
|
222 const semantic_type* yyvaluep,
|
|
223 const location_type* yylocationp);
|
|
224 /// \brief Report a symbol on the debug stream.
|
|
225 /// \param yytype The token type.
|
|
226 /// \param yyvaluep Its semantic value.
|
|
227 /// \param yylocationp Its location.
|
|
228 virtual void yy_symbol_print_ (int yytype,
|
|
229 const semantic_type* yyvaluep,
|
|
230 const location_type* yylocationp);
|
|
231 #endif /* ! YYDEBUG */
|
|
232
|
|
233
|
|
234 /// State numbers.
|
|
235 typedef int state_type;
|
|
236 /// State stack type.
|
|
237 typedef stack<state_type> state_stack_type;
|
|
238 /// Semantic value stack type.
|
|
239 typedef stack<semantic_type> semantic_stack_type;
|
|
240 /// location stack type.
|
|
241 typedef stack<location_type> location_stack_type;
|
|
242
|
|
243 /// The state stack.
|
|
244 state_stack_type yystate_stack_;
|
|
245 /// The semantic value stack.
|
|
246 semantic_stack_type yysemantic_stack_;
|
|
247 /// The location stack.
|
|
248 location_stack_type yylocation_stack_;
|
|
249
|
|
250 /// Internal symbol numbers.
|
|
251 typedef unsigned char token_number_type;
|
|
252 /* Tables. */
|
|
253 /// For a state, the index in \a yytable_ of its portion.
|
|
254 static const short int yypact_[];
|
6
|
255 static const short int yypact_ninf_;
|
4
|
256
|
|
257 /// For a state, default rule to reduce.
|
|
258 /// Unless\a yytable_ specifies something else to do.
|
|
259 /// Zero means the default is an error.
|
|
260 static const unsigned char yydefact_[];
|
|
261
|
|
262 static const short int yypgoto_[];
|
|
263 static const signed char yydefgoto_[];
|
|
264
|
|
265 /// What to do in a state.
|
|
266 /// \a yytable_[yypact_[s]]: what to do in state \a s.
|
|
267 /// - if positive, shift that token.
|
|
268 /// - if negative, reduce the rule which number is the opposite.
|
|
269 /// - if zero, do what YYDEFACT says.
|
|
270 static const short int yytable_[];
|
|
271 static const signed char yytable_ninf_;
|
|
272
|
|
273 static const short int yycheck_[];
|
|
274
|
|
275 /// For a state, its accessing symbol.
|
|
276 static const unsigned char yystos_[];
|
|
277
|
|
278 /// For a rule, its LHS.
|
|
279 static const unsigned char yyr1_[];
|
|
280 /// For a rule, its RHS length.
|
|
281 static const unsigned char yyr2_[];
|
|
282
|
|
283 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
|
284 /// For a symbol, its name in clear.
|
|
285 static const char* const yytname_[];
|
|
286 #endif
|
|
287
|
|
288 #if YYERROR_VERBOSE
|
|
289 /// Convert the symbol name \a n to a form suitable for a diagnostic.
|
|
290 virtual std::string yytnamerr_ (const char *n);
|
|
291 #endif
|
|
292
|
|
293 #if YYDEBUG
|
|
294 /// A type to store symbol numbers and -1.
|
|
295 typedef signed char rhs_number_type;
|
|
296 /// A `-1'-separated list of the rules' RHS.
|
|
297 static const rhs_number_type yyrhs_[];
|
|
298 /// For each rule, the index of the first RHS symbol in \a yyrhs_.
|
|
299 static const unsigned short int yyprhs_[];
|
|
300 /// For each rule, its source line number.
|
|
301 static const unsigned char yyrline_[];
|
|
302 /// For each scanner token number, its symbol number.
|
|
303 static const unsigned short int yytoken_number_[];
|
|
304 /// Report on the debug stream that the rule \a r is going to be reduced.
|
|
305 virtual void yy_reduce_print_ (int r);
|
|
306 /// Print the state stack on the debug stream.
|
|
307 virtual void yystack_print_ ();
|
|
308 #endif
|
|
309
|
|
310 /// Convert a scanner token number \a t to a symbol number.
|
|
311 token_number_type yytranslate_ (int t);
|
|
312
|
|
313 /// \brief Reclaim the memory associated to a symbol.
|
|
314 /// \param yymsg Why this token is reclaimed.
|
|
315 /// \param yytype The symbol type.
|
|
316 /// \param yyvaluep Its semantic value.
|
|
317 /// \param yylocationp Its location.
|
|
318 inline void yydestruct_ (const char* yymsg,
|
|
319 int yytype,
|
|
320 semantic_type* yyvaluep,
|
|
321 location_type* yylocationp);
|
|
322
|
|
323 /// Pop \a n symbols the three stacks.
|
|
324 inline void yypop_ (unsigned int n = 1);
|
|
325
|
|
326 /* Constants. */
|
|
327 static const int yyeof_;
|
|
328 /* LAST_ -- Last index in TABLE_. */
|
|
329 static const int yylast_;
|
|
330 static const int yynnts_;
|
|
331 static const int yyempty_;
|
|
332 static const int yyfinal_;
|
|
333 static const int yyterror_;
|
|
334 static const int yyerrcode_;
|
|
335 static const int yyntokens_;
|
|
336 static const unsigned int yyuser_token_number_max_;
|
|
337 static const token_number_type yyundef_token_;
|
|
338
|
|
339 /* Debugging. */
|
|
340 int yydebug_;
|
|
341 std::ostream* yycdebug_;
|
|
342
|
|
343
|
|
344 /* User arguments. */
|
|
345 compiler& driver;
|
|
346 };
|
|
347 }
|
|
348
|
|
349
|
|
350 #endif /* ! defined PARSER_HEADER_H */
|