]>
Commit | Line | Data |
---|---|---|
a75c057f AD |
1 | m4_divert(-1) |
2 | ||
0d8bed56 AD |
3 | # b4_token_defines(TOKEN-NAME, TOKEN-NUMBER) |
4 | # ------------------------------------------ | |
5 | # Output the definition of this token as #define. | |
6 | m4_define([b4_token_define], | |
7 | [#define $1 $2 | |
8 | ]) | |
9 | ||
10 | ||
11 | # b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER) | |
12 | # ------------------------------------------------------- | |
13 | # Output the definition of the tokens as #define. | |
14 | m4_define([b4_token_defines], | |
15 | [m4_map([b4_token_define], [$@])]) | |
a75c057f AD |
16 | |
17 | m4_define_default([b4_input_suffix], [.y]) | |
18 | ||
19 | m4_define_default([b4_output_parser_suffix], | |
20 | [m4_translit(b4_input_suffix, [yY], [cC])]) | |
21 | ||
22 | m4_define_default([b4_output_parser_name], | |
23 | [b4_output_prefix[]b4_output_infix[]b4_output_parser_suffix[]]) | |
24 | ||
25 | ||
26 | m4_define_default([b4_output_header_suffix], | |
27 | [m4_translit(b4_input_suffix, [yY], [hH])]) | |
28 | ||
29 | m4_define_default([b4_output_header_name], | |
30 | [b4_output_prefix[]b4_output_infix[]b4_output_header_suffix[]]) | |
31 | ||
32 | m4_define_default([b4_header_guard], | |
33 | [m4_bpatsubst(m4_toupper([BISON_]b4_output_header_name), | |
34 | [[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]], [_])]) | |
35 | ||
af27eacb | 36 | m4_define([b4_inherit], |
0d8bed56 | 37 | [m4_ifdef([b4_root], |
af27eacb RA |
38 | [: public b4_root |
39 | ], | |
40 | [])]) | |
41 | ||
42 | m4_define([b4_param], | |
43 | [m4_ifdef([b4_root], | |
44 | [, | |
45 | const Param& param], | |
46 | [])]) | |
47 | ||
48 | m4_define([b4_constructor], | |
49 | [m4_ifdef([b4_root], | |
50 | [b4_root (param), | |
51 | ], | |
52 | [])]) | |
53 | ||
98254360 RA |
54 | m4_define([b4_copyright], |
55 | [/* -*- C++ -*- */ | |
69e2658b RA |
56 | /* A Bison parser, made from b4_filename, |
57 | by GNU bison b4_version. */ | |
2b548aa6 RA |
58 | |
59 | /* Skeleton output parser for bison, | |
98254360 | 60 | Copyright 2002 Free Software Foundation, Inc. |
2b548aa6 RA |
61 | |
62 | This program is free software; you can redistribute it and/or modify | |
63 | it under the terms of the GNU General Public License as published by | |
64 | the Free Software Foundation; either version 2, or (at your option) | |
65 | any later version. | |
66 | ||
67 | This program is distributed in the hope that it will be useful, | |
68 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
69 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
70 | GNU General Public License for more details. | |
71 | ||
72 | You should have received a copy of the GNU General Public License | |
73 | along with this program; if not, write to the Free Software | |
74 | Foundation, Inc., 59 Temple Place - Suite 330, | |
75 | Boston, MA 02111-1307, USA. */ | |
76 | ||
77 | /* As a special exception, when this file is copied by Bison into a | |
78 | Bison output file, you may use that output file without restriction. | |
79 | This special exception was added by the Free Software Foundation | |
98254360 RA |
80 | in version 1.24 of Bison. */]) |
81 | ||
82 | m4_divert(0)dnl | |
83 | #output "b4_output_header_name" | |
84 | b4_copyright | |
85 | #ifndef b4_header_guard | |
86 | # define b4_header_guard | |
2b548aa6 RA |
87 | |
88 | #include "stack.hh" | |
2b548aa6 RA |
89 | #include "location.hh" |
90 | ||
8d69a1a3 | 91 | #include <string> |
50997c6e | 92 | |
4162fa07 RA |
93 | /* Using locations. */ |
94 | #define YYLSP_NEEDED b4_locations_flag | |
95 | ||
96 | b4_prologue | |
97 | ||
98254360 | 98 | /* Tokens. */ |
0d8bed56 | 99 | b4_token_defines |
98254360 | 100 | |
69e2658b RA |
101 | /* Enabling traces. */ |
102 | #ifndef YYDEBUG | |
103 | # define YYDEBUG b4_debug | |
104 | #endif | |
105 | ||
106 | /* Enabling verbose error message. */ | |
107 | #ifndef YYERROR_VERBOSE | |
108 | # define YYERROR_VERBOSE b4_error_verbose | |
109 | #endif | |
110 | ||
98254360 | 111 | #ifndef YYSTYPE |
642cb8f8 AD |
112 | m4_ifdef([b4_stype_line], |
113 | [#line b4_stype_line "b4_filename" | |
114 | ])dnl | |
98254360 RA |
115 | typedef b4_stype |
116 | yystype; | |
117 | # define YYSTYPE yystype | |
118 | #endif | |
119 | ||
374f5a14 RA |
120 | #ifndef YYLLOC_DEFAULT |
121 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ | |
122 | Current.last_line = Rhs[[N]].last_line; \ | |
123 | Current.last_column = Rhs[[N]].last_column; | |
124 | #endif | |
125 | ||
98254360 RA |
126 | m4_if(b4_locations_flag, [0], [], |
127 | [#ifndef YYLTYPE | |
128 | typedef struct yyltype | |
129 | { | |
130 | int first_line; | |
131 | int first_column; | |
132 | int last_line; | |
133 | int last_column; | |
134 | } yyltype; | |
135 | # define YYLTYPE yyltype | |
136 | #endif]) | |
50997c6e | 137 | |
2b548aa6 RA |
138 | namespace yy |
139 | { | |
3f3eed27 AD |
140 | class b4_name; |
141 | ||
2b548aa6 RA |
142 | template < typename P > |
143 | struct Traits | |
144 | { | |
145 | }; | |
146 | ||
147 | template < > | |
3f3eed27 | 148 | struct Traits< b4_name > |
2b548aa6 | 149 | { |
50997c6e RA |
150 | typedef int StateType; |
151 | typedef yystype SemanticType; | |
152 | typedef b4_ltype LocationType; | |
2b548aa6 RA |
153 | }; |
154 | } | |
155 | ||
2b548aa6 RA |
156 | namespace yy |
157 | { | |
af27eacb | 158 | class b4_name b4_inherit |
2b548aa6 RA |
159 | { |
160 | public: | |
3f3eed27 | 161 | |
50997c6e | 162 | typedef Traits< b4_name >::StateType StateType; |
3f3eed27 AD |
163 | typedef Traits< b4_name >::SemanticType SemanticType; |
164 | typedef Traits< b4_name >::LocationType LocationType; | |
2b548aa6 RA |
165 | |
166 | typedef Stack< StateType > StateStack; | |
167 | typedef Stack< SemanticType > SemanticStack; | |
168 | typedef Stack< LocationType > LocationStack; | |
169 | ||
8d69a1a3 RA |
170 | #if YYLSP_NEEDED |
171 | b4_name (bool debug, | |
0d8bed56 | 172 | LocationType initlocation[]b4_param) : |
af27eacb RA |
173 | b4_constructor[]debug_ (debug), |
174 | initlocation_ (initlocation) | |
8d69a1a3 | 175 | #else |
af27eacb RA |
176 | b4_name (bool debug[]b4_param) : |
177 | b4_constructor[]debug_ (debug) | |
8d69a1a3 | 178 | #endif |
50997c6e | 179 | { |
50997c6e RA |
180 | } |
181 | ||
182 | virtual ~b4_name () | |
2b548aa6 | 183 | { |
2b548aa6 RA |
184 | } |
185 | ||
186 | virtual int parse (); | |
187 | ||
188 | private: | |
3f3eed27 | 189 | |
69e2658b | 190 | virtual void lex_ (); |
4bb2bc3f | 191 | virtual void error_ (); |
4aacc3a7 | 192 | virtual void print_ (); |
4bb2bc3f | 193 | |
2b548aa6 | 194 | /* Stacks. */ |
69e2658b RA |
195 | StateStack state_stack_; |
196 | SemanticStack semantic_stack_; | |
197 | LocationStack location_stack_; | |
2b548aa6 RA |
198 | |
199 | /* Tables. */ | |
3f3eed27 AD |
200 | static const short pact_[[]]; |
201 | static const short defact_[[]]; | |
202 | static const short pgoto_[[]]; | |
203 | static const short defgoto_[[]]; | |
204 | static const short table_[[]]; | |
205 | static const short check_[[]]; | |
3f3eed27 AD |
206 | static const short r1_[[]]; |
207 | static const short r2_[[]]; | |
69e2658b RA |
208 | |
209 | #if YYDEBUG || YYERROR_VERBOSE | |
3f3eed27 | 210 | static const char* const name_[[]]; |
69e2658b | 211 | #endif |
2b548aa6 RA |
212 | |
213 | /* More tables, for debugging. */ | |
69e2658b | 214 | #if YYDEBUG |
3f3eed27 AD |
215 | static const short rhs_[[]]; |
216 | static const short prhs_[[]]; | |
217 | static const short rline_[[]]; | |
69e2658b | 218 | #endif |
2b548aa6 RA |
219 | |
220 | /* Even more tables. */ | |
69e2658b | 221 | static inline char translate_ (int token); |
2b548aa6 | 222 | |
762a801e | 223 | /* Constants. */ |
50997c6e | 224 | static const int eof_; |
69e2658b RA |
225 | static const int last_; |
226 | static const int flag_; | |
227 | static const int nnts_; | |
228 | static const int nsym_; | |
50997c6e | 229 | static const int empty_; |
69e2658b | 230 | static const int final_; |
762a801e RA |
231 | static const int terror_; |
232 | static const int errcode_; | |
50997c6e | 233 | static const int ntokens_; |
69e2658b RA |
234 | static const int initdepth_; |
235 | static const unsigned maxtok_; | |
2b548aa6 RA |
236 | |
237 | /* State. */ | |
69e2658b RA |
238 | int n_; |
239 | int len_; | |
50997c6e | 240 | int debug_; |
69e2658b | 241 | int state_; |
4bb2bc3f | 242 | |
69e2658b RA |
243 | /* Lookahead and lookahead in internal form. */ |
244 | int looka_; | |
245 | int ilooka_; | |
4bb2bc3f RA |
246 | |
247 | /* Message. */ | |
248 | std::string message; | |
249 | ||
374f5a14 | 250 | /* Semantic value and location of lookahead token. */ |
2b548aa6 RA |
251 | SemanticType value; |
252 | LocationType location; | |
8d69a1a3 | 253 | |
374f5a14 RA |
254 | /* @$ and $$. */ |
255 | SemanticType yyval; | |
256 | LocationType yyloc; | |
257 | ||
8d69a1a3 RA |
258 | /* Initial location. */ |
259 | LocationType initlocation_; | |
2b548aa6 RA |
260 | }; |
261 | } | |
262 | ||
98254360 RA |
263 | #endif /* not b4_header_guard */ |
264 | ||
3f3eed27 | 265 | #output "b4_output_prefix[]b4_output_infix[].cc" |
98254360 RA |
266 | b4_copyright |
267 | ||
268 | #include "b4_output_header_name" | |
50997c6e | 269 | |
2b548aa6 | 270 | /* Enable debugging if requested. */ |
50997c6e | 271 | #if YYDEBUG |
2b548aa6 RA |
272 | # include <cstdio> |
273 | # define YYFPRINTF std::fprintf | |
2b548aa6 RA |
274 | # define YYDPRINTF(Args) \ |
275 | do { \ | |
50997c6e | 276 | if (debug_) \ |
2b548aa6 RA |
277 | YYFPRINTF Args; \ |
278 | } while (0) | |
2b548aa6 RA |
279 | #else /* !YYDEBUG */ |
280 | # define YYDPRINTF(Args) | |
281 | #endif /* !YYDEBUG */ | |
282 | ||
2b548aa6 | 283 | int |
3f3eed27 | 284 | yy::b4_name::parse () |
2b548aa6 | 285 | { |
4bb2bc3f RA |
286 | int nerrs = 0; |
287 | int errstatus = 0; | |
288 | ||
2b548aa6 | 289 | /* Initialize stack. */ |
69e2658b RA |
290 | state_stack_ = StateStack (0); |
291 | semantic_stack_ = SemanticStack (1); | |
292 | location_stack_ = LocationStack (1); | |
2b548aa6 RA |
293 | |
294 | /* Reserve initial space. The C parser needed that, but is it really | |
295 | useful here? */ | |
69e2658b RA |
296 | state_stack_.reserve (initdepth_); |
297 | semantic_stack_.reserve (initdepth_); | |
298 | location_stack_.reserve (initdepth_); | |
2b548aa6 RA |
299 | |
300 | /* Start. */ | |
69e2658b RA |
301 | state_ = 0; |
302 | looka_ = empty_; | |
8d69a1a3 RA |
303 | #if YYLSP_NEEDED |
304 | location = initlocation_; | |
305 | #endif | |
2b548aa6 RA |
306 | YYDPRINTF ((stderr, "Starting parse\n")); |
307 | ||
308 | /* New state. */ | |
309 | yynewstate: | |
69e2658b RA |
310 | state_stack_.push (state_); |
311 | YYDPRINTF ((stderr, "Entering state %d\n", state_)); | |
50997c6e | 312 | goto yybackup; |
2b548aa6 RA |
313 | |
314 | /* Backup. */ | |
315 | yybackup: | |
316 | ||
317 | /* Try to take a decision without lookahead. */ | |
69e2658b RA |
318 | n_ = pact_[[state_]]; |
319 | if (n_ == flag_) | |
2b548aa6 RA |
320 | goto yydefault; |
321 | ||
322 | /* Read a lookahead token. */ | |
69e2658b | 323 | if (looka_ == empty_) |
2b548aa6 RA |
324 | { |
325 | YYDPRINTF ((stderr, "Reading a token: ")); | |
69e2658b | 326 | lex_ (); |
2b548aa6 RA |
327 | } |
328 | ||
329 | /* Convert token to internal form. */ | |
69e2658b | 330 | if (looka_ <= 0) |
2b548aa6 | 331 | { |
69e2658b RA |
332 | looka_ = eof_; |
333 | ilooka_ = 0; | |
2b548aa6 RA |
334 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
335 | } | |
336 | else | |
337 | { | |
69e2658b | 338 | ilooka_ = translate_ (looka_); |
50997c6e RA |
339 | #if YYDEBUG |
340 | if (debug_) | |
341 | { | |
69e2658b | 342 | YYFPRINTF (stderr, "Next token is %d (%s", looka_, name_[[ilooka_]]); |
4aacc3a7 | 343 | print_ (); |
50997c6e RA |
344 | YYFPRINTF (stderr, ")\n"); |
345 | } | |
2b548aa6 RA |
346 | #endif |
347 | } | |
348 | ||
69e2658b RA |
349 | n_ += ilooka_; |
350 | if (n_ < 0 || n_ > last_ || check_[[n_]] != ilooka_) | |
2b548aa6 RA |
351 | goto yydefault; |
352 | ||
353 | /* Reduce or error. */ | |
69e2658b RA |
354 | n_ = table_[[n_]]; |
355 | if (n_ < 0) | |
2b548aa6 | 356 | { |
69e2658b | 357 | if (n_ == flag_) |
2b548aa6 RA |
358 | goto yyerrlab; |
359 | else | |
360 | { | |
69e2658b | 361 | n_ = -n_; |
2b548aa6 RA |
362 | goto yyreduce; |
363 | } | |
364 | } | |
69e2658b | 365 | else if (n_ == 0) |
2b548aa6 | 366 | goto yyerrlab; |
a75c057f | 367 | |
2b548aa6 | 368 | /* Accept? */ |
69e2658b | 369 | if (n_ == final_) |
2b548aa6 RA |
370 | goto yyacceptlab; |
371 | ||
372 | /* Shift the lookahead token. */ | |
69e2658b | 373 | YYDPRINTF ((stderr, "Shifting token %d (%s), ", looka_, name_[[ilooka_]])); |
2b548aa6 RA |
374 | |
375 | /* Discard the token being shifted unless it is eof. */ | |
69e2658b RA |
376 | if (looka_ != eof_) |
377 | looka_ = empty_; | |
2b548aa6 | 378 | |
69e2658b RA |
379 | semantic_stack_.push (value); |
380 | location_stack_.push (location); | |
8d69a1a3 RA |
381 | |
382 | /* Count tokens shifted since error; after three, turn off error | |
383 | status. */ | |
384 | if (errstatus) | |
385 | --errstatus; | |
386 | ||
69e2658b | 387 | state_ = n_; |
2b548aa6 RA |
388 | goto yynewstate; |
389 | ||
390 | /* Default action. */ | |
391 | yydefault: | |
69e2658b RA |
392 | n_ = defact_[[state_]]; |
393 | if (n_ == 0) | |
2b548aa6 | 394 | goto yyerrlab; |
50997c6e | 395 | goto yyreduce; |
2b548aa6 RA |
396 | |
397 | /* Reduce. */ | |
398 | yyreduce: | |
69e2658b RA |
399 | len_ = r2_[[n_]]; |
400 | if (len_) | |
50997c6e | 401 | { |
374f5a14 RA |
402 | yyval = semantic_stack_[[1 - len_]]; |
403 | yyloc = location_stack_[[1 - len_]]; | |
50997c6e RA |
404 | } |
405 | else | |
69e2658b | 406 | { |
374f5a14 RA |
407 | yyval = semantic_stack_[[0]]; |
408 | yyloc = location_stack_[[0]]; | |
50997c6e | 409 | } |
2b548aa6 | 410 | |
50997c6e RA |
411 | #if YYDEBUG |
412 | if (debug_) | |
2b548aa6 | 413 | { |
69e2658b RA |
414 | YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", n_ - 1, rline_[[n_]]); |
415 | for (unsigned i = prhs_[[n_]]; | |
3f3eed27 AD |
416 | rhs_[[i]] >= 0; ++i) |
417 | YYFPRINTF (stderr, "%s ", name_[[rhs_[i]]]); | |
69e2658b | 418 | YYFPRINTF (stderr, "-> %s\n", name_[[r1_[n_]]]); |
2b548aa6 RA |
419 | } |
420 | #endif | |
a75c057f | 421 | |
374f5a14 RA |
422 | if (len_) |
423 | { | |
424 | Slice< LocationType, LocationStack > slice (location_stack_, len_); | |
425 | YYLLOC_DEFAULT (yyloc, slice, len_); | |
426 | } | |
427 | ||
2b548aa6 | 428 | { |
69e2658b RA |
429 | SemanticStack& yyvsp (semantic_stack_); |
430 | LocationStack& yylsp (location_stack_); | |
2b548aa6 | 431 | |
69e2658b | 432 | switch (n_) |
2b548aa6 | 433 | { |
3f3eed27 | 434 | b4_actions |
2b548aa6 RA |
435 | } |
436 | } | |
a75c057f | 437 | |
69e2658b RA |
438 | state_stack_.pop (len_); |
439 | semantic_stack_.pop (len_); | |
440 | location_stack_.pop (len_); | |
2b548aa6 | 441 | |
50997c6e RA |
442 | #if YYDEBUG |
443 | if (debug_) | |
2b548aa6 RA |
444 | { |
445 | YYFPRINTF (stderr, "state stack now"); | |
a75c057f | 446 | for (StateStack::ConstIterator i = state_stack_.begin (); |
69e2658b | 447 | i != state_stack_.end (); ++i) |
2b548aa6 RA |
448 | YYFPRINTF (stderr, " %d", *i); |
449 | YYFPRINTF (stderr, "\n"); | |
450 | } | |
451 | #endif | |
a75c057f | 452 | |
374f5a14 RA |
453 | semantic_stack_.push (yyval); |
454 | location_stack_.push (yyloc); | |
2b548aa6 RA |
455 | |
456 | /* Shift the result of the reduction. */ | |
69e2658b RA |
457 | n_ = r1_[[n_]]; |
458 | state_ = pgoto_[[n_ - ntokens_]] + state_stack_[[0]]; | |
459 | if (state_ >= 0 && state_ <= last_ && check_[[state_]] == state_stack_[[0]]) | |
460 | state_ = table_[[state_]]; | |
2b548aa6 | 461 | else |
69e2658b | 462 | state_ = defgoto_[[n_ - ntokens_]]; |
2b548aa6 RA |
463 | goto yynewstate; |
464 | ||
465 | /* Report and recover from errors. This is very incomplete. */ | |
466 | yyerrlab: | |
4bb2bc3f RA |
467 | /* If not already recovering from an error, report this error. */ |
468 | if (!errstatus) | |
469 | { | |
470 | ++nerrs; | |
a75c057f | 471 | |
69e2658b RA |
472 | #if YYERROR_VERBOSE |
473 | n_ = pact_[[state_]]; | |
474 | if (n_ > flag_ && n_ < last_) | |
4bb2bc3f RA |
475 | { |
476 | message = "parse error, unexpected "; | |
69e2658b | 477 | message += name_[[ilooka_]]; |
4bb2bc3f RA |
478 | { |
479 | int count = 0; | |
69e2658b RA |
480 | for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x) |
481 | if (check_[[x + n_]] == x) | |
4bb2bc3f RA |
482 | ++count; |
483 | if (count < 5) | |
484 | { | |
485 | count = 0; | |
69e2658b RA |
486 | for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x) |
487 | if (check_[[x + n_]] == x) | |
4bb2bc3f | 488 | { |
a75c057f | 489 | message += (!count++) ? ", expecting " : " or "; |
4bb2bc3f RA |
490 | message += name_[[x]]; |
491 | } | |
492 | } | |
493 | } | |
494 | } | |
495 | else | |
69e2658b | 496 | #endif |
4bb2bc3f | 497 | message = "parse error"; |
8d69a1a3 | 498 | error_ (); |
4bb2bc3f | 499 | } |
762a801e | 500 | goto yyerrlab1; |
a75c057f | 501 | |
762a801e RA |
502 | /* Error raised explicitly by an action. */ |
503 | yyerrlab1: | |
504 | if (errstatus == 3) | |
505 | { | |
506 | /* If just tried and failed to reuse lookahead token after an | |
507 | error, discard it. */ | |
508 | ||
509 | /* Return failure if at end of input. */ | |
69e2658b | 510 | if (looka_ == eof_) |
762a801e | 511 | goto yyabortlab; |
69e2658b RA |
512 | YYDPRINTF ((stderr, "Discarding token %d (%s).\n", looka_, name_[[ilooka_]])); |
513 | looka_ = empty_; | |
762a801e RA |
514 | } |
515 | ||
516 | /* Else will try to reuse lookahead token after shifting the error | |
517 | token. */ | |
518 | ||
519 | errstatus = 3; | |
520 | goto yyerrhandle; | |
521 | ||
522 | /* Pop the current state because it cannot handle the error token. */ | |
523 | yyerrdefault: | |
524 | yyerrpop: | |
69e2658b | 525 | if (!state_stack_.height ()) |
762a801e | 526 | goto yyabortlab; |
69e2658b RA |
527 | state_ = (state_stack_.pop (), state_stack_[[0]]); |
528 | semantic_stack_.pop (); | |
529 | location_stack_.pop ();; | |
762a801e RA |
530 | |
531 | #if YYDEBUG | |
532 | if (debug_) | |
533 | { | |
534 | YYFPRINTF (stderr, "Error: state stack now"); | |
a75c057f | 535 | for (StateStack::ConstIterator i = state_stack_.begin (); |
69e2658b | 536 | i != state_stack_.end (); ++i) |
762a801e | 537 | YYFPRINTF (stderr, " %d", *i); |
a75c057f | 538 | YYFPRINTF (stderr, "\n"); |
762a801e RA |
539 | } |
540 | #endif | |
541 | ||
542 | yyerrhandle: | |
69e2658b RA |
543 | n_ = pact_[[state_]]; |
544 | if (n_ == flag_) | |
762a801e RA |
545 | goto yyerrdefault; |
546 | ||
69e2658b RA |
547 | n_ += terror_; |
548 | if (n_ < 0 || n_ > last_ || check_[[n_]] != terror_) | |
762a801e RA |
549 | goto yyerrdefault; |
550 | ||
69e2658b RA |
551 | n_ = table_[[n_]]; |
552 | if (n_ < 0) | |
762a801e | 553 | { |
69e2658b | 554 | if (n_ == flag_) |
762a801e | 555 | goto yyerrpop; |
69e2658b | 556 | n_ = -n_; |
762a801e RA |
557 | goto yyreduce; |
558 | } | |
69e2658b | 559 | else if (!n_) |
762a801e RA |
560 | goto yyerrpop; |
561 | ||
69e2658b | 562 | if (n_ == final_) |
762a801e RA |
563 | goto yyacceptlab; |
564 | ||
565 | YYDPRINTF ((stderr, "Shifting error token, ")); | |
566 | ||
69e2658b RA |
567 | semantic_stack_.push (value); |
568 | location_stack_.push (location); | |
762a801e | 569 | |
69e2658b | 570 | state_ = n_; |
762a801e RA |
571 | goto yynewstate; |
572 | ||
2b548aa6 RA |
573 | /* Accept. */ |
574 | yyacceptlab: | |
575 | return 0; | |
762a801e RA |
576 | |
577 | /* Abort. */ | |
578 | yyabortlab: | |
579 | return 1; | |
2b548aa6 RA |
580 | } |
581 | ||
69e2658b RA |
582 | void |
583 | yy::b4_name::lex_ () | |
584 | { | |
585 | #if YYLSP_NEEDED | |
586 | looka_ = yylex (&value, &location); | |
587 | #else | |
588 | looka_ = yylex (&value); | |
589 | #endif | |
590 | } | |
591 | ||
6b45a3ca | 592 | /* YYPACT[[STATE-NUM]] -- Index in YYTABLE of the portion describing |
2b548aa6 | 593 | STATE-NUM. */ |
69e2658b | 594 | const short |
3f3eed27 | 595 | yy::b4_name::pact_[[]] = |
2b548aa6 | 596 | { |
3f3eed27 | 597 | b4_pact |
2b548aa6 RA |
598 | }; |
599 | ||
6b45a3ca | 600 | /* YYDEFACT[[S]] -- default rule to reduce with in state S when YYTABLE |
2b548aa6 RA |
601 | doesn't specify something else to do. Zero means the default is an |
602 | error. */ | |
69e2658b | 603 | const short |
3f3eed27 | 604 | yy::b4_name::defact_[[]] = |
2b548aa6 | 605 | { |
3f3eed27 | 606 | b4_defact |
2b548aa6 RA |
607 | }; |
608 | ||
6b45a3ca | 609 | /* YYPGOTO[[NTERM-NUM]]. */ |
69e2658b | 610 | const short |
3f3eed27 | 611 | yy::b4_name::pgoto_[[]] = |
2b548aa6 | 612 | { |
3f3eed27 | 613 | b4_pgoto |
2b548aa6 RA |
614 | }; |
615 | ||
6b45a3ca | 616 | /* YYDEFGOTO[[NTERM-NUM]]. */ |
69e2658b | 617 | const short |
3f3eed27 | 618 | yy::b4_name::defgoto_[[]] = |
2b548aa6 | 619 | { |
3f3eed27 | 620 | b4_defgoto |
2b548aa6 RA |
621 | }; |
622 | ||
6b45a3ca | 623 | /* YYTABLE[[YYPACT[STATE-NUM]]]. What to do in state STATE-NUM. If |
2b548aa6 RA |
624 | positive, shift that token. If negative, reduce the rule which |
625 | number is the opposite. If zero, do what YYDEFACT says. */ | |
69e2658b | 626 | const short |
3f3eed27 | 627 | yy::b4_name::table_[[]] = |
2b548aa6 | 628 | { |
3f3eed27 | 629 | b4_table |
2b548aa6 RA |
630 | }; |
631 | ||
632 | /* YYCHECK. */ | |
69e2658b | 633 | const short |
3f3eed27 | 634 | yy::b4_name::check_[[]] = |
2b548aa6 | 635 | { |
3f3eed27 | 636 | b4_check |
2b548aa6 RA |
637 | }; |
638 | ||
6b45a3ca | 639 | /* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives. */ |
a75c057f | 640 | const short |
3f3eed27 | 641 | yy::b4_name::r1_[[]] = |
2b548aa6 | 642 | { |
3f3eed27 | 643 | b4_r1 |
2b548aa6 RA |
644 | }; |
645 | ||
6b45a3ca | 646 | /* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN. */ |
a75c057f | 647 | const short |
3f3eed27 | 648 | yy::b4_name::r2_[[]] = |
2b548aa6 | 649 | { |
3f3eed27 | 650 | b4_r2 |
2b548aa6 RA |
651 | }; |
652 | ||
69e2658b | 653 | #if YYDEBUG || YYERROR_VERBOSE |
6b45a3ca | 654 | /* YYTNAME[[SYMBOL-NUM]] -- String name of the symbol SYMBOL-NUM. |
2b548aa6 RA |
655 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
656 | const char* | |
3f3eed27 | 657 | const yy::b4_name::name_[[]] = |
2b548aa6 | 658 | { |
3f3eed27 | 659 | b4_tname |
2b548aa6 | 660 | }; |
69e2658b | 661 | #endif |
2b548aa6 | 662 | |
69e2658b | 663 | #if YYDEBUG |
2b548aa6 | 664 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
a75c057f | 665 | const short |
3f3eed27 | 666 | yy::b4_name::rhs_[[]] = |
2b548aa6 | 667 | { |
3f3eed27 | 668 | b4_rhs |
2b548aa6 RA |
669 | }; |
670 | ||
6b45a3ca | 671 | /* YYPRHS[[YYN]] -- Index of the first RHS symbol of rule number YYN in |
2b548aa6 | 672 | YYRHS. */ |
69e2658b | 673 | const short |
3f3eed27 | 674 | yy::b4_name::prhs_[[]] = |
2b548aa6 | 675 | { |
3f3eed27 | 676 | b4_prhs |
2b548aa6 RA |
677 | }; |
678 | ||
69e2658b RA |
679 | /* YYRLINE[[YYN]] -- source line where rule number YYN was defined. */ |
680 | const short | |
681 | yy::b4_name::rline_[[]] = | |
682 | { | |
683 | b4_rline | |
684 | }; | |
685 | #endif | |
686 | ||
2b548aa6 RA |
687 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
688 | char | |
69e2658b | 689 | yy::b4_name::translate_ (int token) |
2b548aa6 | 690 | { |
a75c057f AD |
691 | static |
692 | const char | |
3f3eed27 | 693 | translate_[[]] = |
2b548aa6 | 694 | { |
3f3eed27 | 695 | b4_translate |
2b548aa6 | 696 | }; |
69e2658b | 697 | return ((unsigned)(token) <= maxtok_ ? translate_[[token]] : nsym_); |
2b548aa6 RA |
698 | } |
699 | ||
50997c6e | 700 | const int yy::b4_name::eof_ = 0; |
69e2658b RA |
701 | const int yy::b4_name::last_ = b4_last; |
702 | const int yy::b4_name::flag_ = b4_flag; | |
703 | const int yy::b4_name::nnts_ = b4_nnts; | |
704 | const int yy::b4_name::nsym_ = b4_nsym; | |
50997c6e | 705 | const int yy::b4_name::empty_ = -2; |
69e2658b | 706 | const int yy::b4_name::final_ = b4_final; |
762a801e RA |
707 | const int yy::b4_name::terror_ = 1; |
708 | const int yy::b4_name::errcode_ = 256; | |
50997c6e | 709 | const int yy::b4_name::ntokens_ = b4_ntokens; |
69e2658b RA |
710 | const int yy::b4_name::initdepth_ = b4_initdepth; |
711 | ||
712 | const unsigned yy::b4_name::maxtok_ = b4_maxtok; | |
2b548aa6 | 713 | |
3f3eed27 | 714 | b4_epilogue |
2b548aa6 | 715 | |
3f3eed27 | 716 | #output "stack.hh" |
98254360 RA |
717 | b4_copyright |
718 | ||
2b548aa6 RA |
719 | #ifndef BISON_STACK_HH |
720 | # define BISON_STACK_HH | |
721 | ||
722 | #include <vector> | |
723 | ||
724 | namespace yy | |
725 | { | |
726 | template < class T, class S = std::vector< T > > | |
727 | class Stack | |
728 | { | |
729 | public: | |
730 | ||
731 | typedef typename S::iterator Iterator; | |
732 | typedef typename S::const_iterator ConstIterator; | |
733 | ||
734 | Stack () : seq_ () | |
735 | { | |
736 | } | |
737 | ||
738 | Stack (unsigned n) : seq_ (n) | |
739 | { | |
740 | } | |
741 | ||
742 | inline | |
743 | T& | |
3f3eed27 | 744 | operator [[]] (int index) |
2b548aa6 | 745 | { |
374f5a14 | 746 | return seq_[[height () - 1 + index]]; |
2b548aa6 RA |
747 | } |
748 | ||
749 | inline | |
750 | const T& | |
3f3eed27 | 751 | operator [[]] (int index) const |
2b548aa6 | 752 | { |
374f5a14 | 753 | return seq_[[height () - 1 + index]]; |
2b548aa6 RA |
754 | } |
755 | ||
756 | inline | |
757 | void | |
758 | push (const T& t) | |
759 | { | |
760 | seq_.push_back (t); | |
761 | } | |
762 | ||
763 | inline | |
764 | void | |
765 | pop (unsigned n = 1) | |
766 | { | |
767 | for (; n; --n) | |
768 | seq_.pop_back (); | |
769 | } | |
a75c057f | 770 | |
2b548aa6 RA |
771 | inline |
772 | void | |
773 | reserve (unsigned n) | |
774 | { | |
775 | seq_.reserve (n); | |
776 | } | |
777 | ||
762a801e RA |
778 | inline |
779 | unsigned | |
780 | height () const | |
781 | { | |
782 | return seq_.size (); | |
783 | } | |
784 | ||
2b548aa6 RA |
785 | inline ConstIterator begin () const { return seq_.begin (); } |
786 | inline ConstIterator end () const { return seq_.end (); } | |
787 | ||
788 | private: | |
789 | ||
790 | S seq_; | |
791 | }; | |
374f5a14 RA |
792 | |
793 | template < class T, class S = Stack< T > > | |
794 | class Slice | |
795 | { | |
796 | public: | |
797 | ||
798 | Slice (const S& stack, | |
799 | unsigned range) : stack_ (stack), | |
800 | range_ (range) | |
801 | { | |
802 | } | |
803 | ||
804 | inline | |
805 | const T& | |
806 | operator [[]] (unsigned index) const | |
807 | { | |
808 | return stack_[[index - range_]]; | |
809 | } | |
810 | ||
811 | private: | |
812 | ||
813 | const S& stack_; | |
814 | unsigned range_; | |
815 | }; | |
2b548aa6 RA |
816 | } |
817 | ||
818 | #endif // not BISON_STACK_HH | |
819 | ||
3f3eed27 | 820 | #output "location.hh" |
98254360 RA |
821 | b4_copyright |
822 | ||
2b548aa6 RA |
823 | #ifndef BISON_LOCATION_HH |
824 | # define BISON_LOCATION_HH | |
825 | ||
826 | namespace yy | |
827 | { | |
828 | struct Position | |
829 | { | |
830 | int line; | |
831 | int column; | |
832 | }; | |
833 | ||
834 | struct Location | |
835 | { | |
836 | Position first; | |
837 | Position last; | |
838 | }; | |
839 | } | |
840 | ||
841 | #endif // not BISON_LOCATION_HH |