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