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