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