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