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