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