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