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