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