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