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