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