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