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