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