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