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