]>
Commit | Line | Data |
---|---|---|
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 | [yyvsp@<:@m4_eval([$2 - $1])@:>@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 | [yylsp@<:@m4_eval([$2 - $1])@:>@]) | |
51 | ||
52 | ||
53 | # b4_token_defines(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_token_number_max) TokenNumberType; | |
206 | typedef b4_sint_type(b4_rhs_number_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 short 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 short prhs_[[]]; | |
276 | static const short 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 | /* Reserve initial space. The C parser needed that, but is it really | |
355 | useful here? */ | |
356 | state_stack_.reserve (initdepth_); | |
357 | semantic_stack_.reserve (initdepth_); | |
358 | location_stack_.reserve (initdepth_); | |
359 | ||
360 | /* Start. */ | |
361 | state_ = 0; | |
362 | looka_ = empty_; | |
363 | #if YYLSP_NEEDED | |
364 | location = initlocation_; | |
365 | #endif | |
366 | YYDPRINTF ((stderr, "Starting parse\n")); | |
367 | ||
368 | /* New state. */ | |
369 | yynewstate: | |
370 | state_stack_.push (state_); | |
371 | YYDPRINTF ((stderr, "Entering state %d\n", state_)); | |
372 | goto yybackup; | |
373 | ||
374 | /* Backup. */ | |
375 | yybackup: | |
376 | ||
377 | /* Try to take a decision without lookahead. */ | |
378 | n_ = pact_[[state_]]; | |
379 | if (n_ == flag_) | |
380 | goto yydefault; | |
381 | ||
382 | /* Read a lookahead token. */ | |
383 | if (looka_ == empty_) | |
384 | { | |
385 | YYDPRINTF ((stderr, "Reading a token: ")); | |
386 | lex_ (); | |
387 | } | |
388 | ||
389 | /* Convert token to internal form. */ | |
390 | if (looka_ <= 0) | |
391 | { | |
392 | looka_ = eof_; | |
393 | ilooka_ = 0; | |
394 | YYDPRINTF ((stderr, "Now at end of input.\n")); | |
395 | } | |
396 | else | |
397 | { | |
398 | ilooka_ = translate_ (looka_); | |
399 | #if YYDEBUG | |
400 | if (debug_) | |
401 | { | |
402 | YYFPRINTF (stderr, "Next token is %d (%s", looka_, name_[[ilooka_]]); | |
403 | print_ (); | |
404 | YYFPRINTF (stderr, ")\n"); | |
405 | } | |
406 | #endif | |
407 | } | |
408 | ||
409 | n_ += ilooka_; | |
410 | if (n_ < 0 || n_ > last_ || check_[[n_]] != ilooka_) | |
411 | goto yydefault; | |
412 | ||
413 | /* Reduce or error. */ | |
414 | n_ = table_[[n_]]; | |
415 | if (n_ < 0) | |
416 | { | |
417 | if (n_ == flag_) | |
418 | goto yyerrlab; | |
419 | else | |
420 | { | |
421 | n_ = -n_; | |
422 | goto yyreduce; | |
423 | } | |
424 | } | |
425 | else if (n_ == 0) | |
426 | goto yyerrlab; | |
427 | ||
428 | /* Accept? */ | |
429 | if (n_ == final_) | |
430 | goto yyacceptlab; | |
431 | ||
432 | /* Shift the lookahead token. */ | |
433 | YYDPRINTF ((stderr, "Shifting token %d (%s), ", looka_, name_[[ilooka_]])); | |
434 | ||
435 | /* Discard the token being shifted unless it is eof. */ | |
436 | if (looka_ != eof_) | |
437 | looka_ = empty_; | |
438 | ||
439 | semantic_stack_.push (value); | |
440 | location_stack_.push (location); | |
441 | ||
442 | /* Count tokens shifted since error; after three, turn off error | |
443 | status. */ | |
444 | if (errstatus) | |
445 | --errstatus; | |
446 | ||
447 | state_ = n_; | |
448 | goto yynewstate; | |
449 | ||
450 | /* Default action. */ | |
451 | yydefault: | |
452 | n_ = defact_[[state_]]; | |
453 | if (n_ == 0) | |
454 | goto yyerrlab; | |
455 | goto yyreduce; | |
456 | ||
457 | /* Reduce. */ | |
458 | yyreduce: | |
459 | len_ = r2_[[n_]]; | |
460 | if (len_) | |
461 | { | |
462 | yyval = semantic_stack_[[1 - len_]]; | |
463 | yyloc = location_stack_[[1 - len_]]; | |
464 | } | |
465 | else | |
466 | { | |
467 | yyval = semantic_stack_[[0]]; | |
468 | yyloc = location_stack_[[0]]; | |
469 | } | |
470 | ||
471 | #if YYDEBUG | |
472 | if (debug_) | |
473 | { | |
474 | YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", n_ - 1, rline_[[n_]]); | |
475 | for (unsigned i = prhs_[[n_]]; | |
476 | rhs_[[i]] >= 0; ++i) | |
477 | YYFPRINTF (stderr, "%s ", name_[[rhs_[i]]]); | |
478 | YYFPRINTF (stderr, "-> %s\n", name_[[r1_[n_]]]); | |
479 | } | |
480 | #endif | |
481 | ||
482 | if (len_) | |
483 | { | |
484 | Slice< LocationType, LocationStack > slice (location_stack_, len_); | |
485 | YYLLOC_DEFAULT (yyloc, slice, len_); | |
486 | } | |
487 | ||
488 | { | |
489 | SemanticStack& yyvsp (semantic_stack_); | |
490 | LocationStack& yylsp (location_stack_); | |
491 | ||
492 | switch (n_) | |
493 | { | |
494 | b4_actions | |
495 | } | |
496 | } | |
497 | ||
498 | /* Line __line__ of __file__. */ | |
499 | #line __oline__ "__ofile__" | |
500 | ||
501 | state_stack_.pop (len_); | |
502 | semantic_stack_.pop (len_); | |
503 | location_stack_.pop (len_); | |
504 | ||
505 | #if YYDEBUG | |
506 | if (debug_) | |
507 | { | |
508 | YYFPRINTF (stderr, "state stack now"); | |
509 | for (StateStack::ConstIterator i = state_stack_.begin (); | |
510 | i != state_stack_.end (); ++i) | |
511 | YYFPRINTF (stderr, " %d", *i); | |
512 | YYFPRINTF (stderr, "\n"); | |
513 | } | |
514 | #endif | |
515 | ||
516 | semantic_stack_.push (yyval); | |
517 | location_stack_.push (yyloc); | |
518 | ||
519 | /* Shift the result of the reduction. */ | |
520 | n_ = r1_[[n_]]; | |
521 | state_ = pgoto_[[n_ - ntokens_]] + state_stack_[[0]]; | |
522 | if (state_ >= 0 && state_ <= last_ && check_[[state_]] == state_stack_[[0]]) | |
523 | state_ = table_[[state_]]; | |
524 | else | |
525 | state_ = defgoto_[[n_ - ntokens_]]; | |
526 | goto yynewstate; | |
527 | ||
528 | /* Report and recover from errors. This is very incomplete. */ | |
529 | yyerrlab: | |
530 | /* If not already recovering from an error, report this error. */ | |
531 | if (!errstatus) | |
532 | { | |
533 | ++nerrs; | |
534 | ||
535 | #if YYERROR_VERBOSE | |
536 | n_ = pact_[[state_]]; | |
537 | if (n_ > flag_ && n_ < last_) | |
538 | { | |
539 | message = "parse error, unexpected "; | |
540 | message += name_[[ilooka_]]; | |
541 | { | |
542 | int count = 0; | |
543 | for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x) | |
544 | if (check_[[x + n_]] == x) | |
545 | ++count; | |
546 | if (count < 5) | |
547 | { | |
548 | count = 0; | |
549 | for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x) | |
550 | if (check_[[x + n_]] == x) | |
551 | { | |
552 | message += (!count++) ? ", expecting " : " or "; | |
553 | message += name_[[x]]; | |
554 | } | |
555 | } | |
556 | } | |
557 | } | |
558 | else | |
559 | #endif | |
560 | message = "parse error"; | |
561 | error_ (); | |
562 | } | |
563 | goto yyerrlab1; | |
564 | ||
565 | /* Error raised explicitly by an action. */ | |
566 | yyerrlab1: | |
567 | if (errstatus == 3) | |
568 | { | |
569 | /* If just tried and failed to reuse lookahead token after an | |
570 | error, discard it. */ | |
571 | ||
572 | /* Return failure if at end of input. */ | |
573 | if (looka_ == eof_) | |
574 | goto yyabortlab; | |
575 | YYDPRINTF ((stderr, "Discarding token %d (%s).\n", looka_, name_[[ilooka_]])); | |
576 | looka_ = empty_; | |
577 | } | |
578 | ||
579 | /* Else will try to reuse lookahead token after shifting the error | |
580 | token. */ | |
581 | ||
582 | errstatus = 3; | |
583 | goto yyerrhandle; | |
584 | ||
585 | /* Pop the current state because it cannot handle the error token. */ | |
586 | yyerrdefault: | |
587 | yyerrpop: | |
588 | if (!state_stack_.height ()) | |
589 | goto yyabortlab; | |
590 | state_ = (state_stack_.pop (), state_stack_[[0]]); | |
591 | semantic_stack_.pop (); | |
592 | location_stack_.pop ();; | |
593 | ||
594 | #if YYDEBUG | |
595 | if (debug_) | |
596 | { | |
597 | YYFPRINTF (stderr, "Error: state stack now"); | |
598 | for (StateStack::ConstIterator i = state_stack_.begin (); | |
599 | i != state_stack_.end (); ++i) | |
600 | YYFPRINTF (stderr, " %d", *i); | |
601 | YYFPRINTF (stderr, "\n"); | |
602 | } | |
603 | #endif | |
604 | ||
605 | yyerrhandle: | |
606 | n_ = pact_[[state_]]; | |
607 | if (n_ == flag_) | |
608 | goto yyerrdefault; | |
609 | ||
610 | n_ += terror_; | |
611 | if (n_ < 0 || n_ > last_ || check_[[n_]] != terror_) | |
612 | goto yyerrdefault; | |
613 | ||
614 | n_ = table_[[n_]]; | |
615 | if (n_ < 0) | |
616 | { | |
617 | if (n_ == flag_) | |
618 | goto yyerrpop; | |
619 | n_ = -n_; | |
620 | goto yyreduce; | |
621 | } | |
622 | else if (!n_) | |
623 | goto yyerrpop; | |
624 | ||
625 | if (n_ == final_) | |
626 | goto yyacceptlab; | |
627 | ||
628 | YYDPRINTF ((stderr, "Shifting error token, ")); | |
629 | ||
630 | semantic_stack_.push (value); | |
631 | location_stack_.push (location); | |
632 | ||
633 | state_ = n_; | |
634 | goto yynewstate; | |
635 | ||
636 | /* Accept. */ | |
637 | yyacceptlab: | |
638 | return 0; | |
639 | ||
640 | /* Abort. */ | |
641 | yyabortlab: | |
642 | return 1; | |
643 | } | |
644 | ||
645 | void | |
646 | yy::b4_name::lex_ () | |
647 | { | |
648 | #if YYLSP_NEEDED | |
649 | looka_ = yylex (&value, &location); | |
650 | #else | |
651 | looka_ = yylex (&value); | |
652 | #endif | |
653 | } | |
654 | ||
655 | /* YYPACT[[STATE-NUM]] -- Index in YYTABLE of the portion describing | |
656 | STATE-NUM. */ | |
657 | const short | |
658 | yy::b4_name::pact_[[]] = | |
659 | { | |
660 | b4_pact | |
661 | }; | |
662 | ||
663 | /* YYDEFACT[[S]] -- default rule to reduce with in state S when YYTABLE | |
664 | doesn't specify something else to do. Zero means the default is an | |
665 | error. */ | |
666 | const short | |
667 | yy::b4_name::defact_[[]] = | |
668 | { | |
669 | b4_defact | |
670 | }; | |
671 | ||
672 | /* YYPGOTO[[NTERM-NUM]]. */ | |
673 | const short | |
674 | yy::b4_name::pgoto_[[]] = | |
675 | { | |
676 | b4_pgoto | |
677 | }; | |
678 | ||
679 | /* YYDEFGOTO[[NTERM-NUM]]. */ | |
680 | const short | |
681 | yy::b4_name::defgoto_[[]] = | |
682 | { | |
683 | b4_defgoto | |
684 | }; | |
685 | ||
686 | /* YYTABLE[[YYPACT[STATE-NUM]]]. What to do in state STATE-NUM. If | |
687 | positive, shift that token. If negative, reduce the rule which | |
688 | number is the opposite. If zero, do what YYDEFACT says. */ | |
689 | const short | |
690 | yy::b4_name::table_[[]] = | |
691 | { | |
692 | b4_table | |
693 | }; | |
694 | ||
695 | /* YYCHECK. */ | |
696 | const short | |
697 | yy::b4_name::check_[[]] = | |
698 | { | |
699 | b4_check | |
700 | }; | |
701 | ||
702 | /* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives. */ | |
703 | const yy::b4_name::TokenNumberType | |
704 | yy::b4_name::r1_[[]] = | |
705 | { | |
706 | b4_r1 | |
707 | }; | |
708 | ||
709 | /* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN. */ | |
710 | const short | |
711 | yy::b4_name::r2_[[]] = | |
712 | { | |
713 | b4_r2 | |
714 | }; | |
715 | ||
716 | #if YYDEBUG || YYERROR_VERBOSE | |
717 | /* YYTNAME[[SYMBOL-NUM]] -- String name of the symbol SYMBOL-NUM. | |
718 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ | |
719 | const char* | |
720 | const yy::b4_name::name_[[]] = | |
721 | { | |
722 | b4_tname | |
723 | }; | |
724 | #endif | |
725 | ||
726 | #if YYDEBUG | |
727 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ | |
728 | const yy::b4_name::RhsNumberType | |
729 | yy::b4_name::rhs_[[]] = | |
730 | { | |
731 | b4_rhs | |
732 | }; | |
733 | ||
734 | /* YYPRHS[[YYN]] -- Index of the first RHS symbol of rule number YYN in | |
735 | YYRHS. */ | |
736 | const short | |
737 | yy::b4_name::prhs_[[]] = | |
738 | { | |
739 | b4_prhs | |
740 | }; | |
741 | ||
742 | /* YYRLINE[[YYN]] -- source line where rule number YYN was defined. */ | |
743 | const short | |
744 | yy::b4_name::rline_[[]] = | |
745 | { | |
746 | b4_rline | |
747 | }; | |
748 | #endif | |
749 | ||
750 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ | |
751 | yy::b4_name::TokenNumberType | |
752 | yy::b4_name::translate_ (int token) | |
753 | { | |
754 | static | |
755 | const TokenNumberType | |
756 | translate_[[]] = | |
757 | { | |
758 | b4_translate | |
759 | }; | |
760 | if ((unsigned) token <= user_token_number_max_) | |
761 | return translate_[[token]]; | |
762 | else | |
763 | return undef_token_; | |
764 | } | |
765 | ||
766 | const int yy::b4_name::eof_ = 0; | |
767 | const int yy::b4_name::last_ = b4_last; | |
768 | const int yy::b4_name::flag_ = b4_flag; | |
769 | const int yy::b4_name::nnts_ = b4_nnts; | |
770 | const int yy::b4_name::nsym_ = b4_nsym; | |
771 | const int yy::b4_name::empty_ = -2; | |
772 | const int yy::b4_name::final_ = b4_final; | |
773 | const int yy::b4_name::terror_ = 1; | |
774 | const int yy::b4_name::errcode_ = 256; | |
775 | const int yy::b4_name::ntokens_ = b4_ntokens; | |
776 | const int yy::b4_name::initdepth_ = b4_initdepth; | |
777 | ||
778 | const unsigned yy::b4_name::user_token_number_max_ = b4_user_token_number_max; | |
779 | const yy::b4_name::TokenNumberType yy::b4_name::undef_token_ = b4_undef_token_number; | |
780 | ||
781 | b4_epilogue | |
782 | ||
783 | #output "stack.hh" | |
784 | b4_copyright | |
785 | ||
786 | #ifndef BISON_STACK_HH | |
787 | # define BISON_STACK_HH | |
788 | ||
789 | #include <vector> | |
790 | ||
791 | namespace yy | |
792 | { | |
793 | template < class T, class S = std::vector< T > > | |
794 | class Stack | |
795 | { | |
796 | public: | |
797 | ||
798 | typedef typename S::iterator Iterator; | |
799 | typedef typename S::const_iterator ConstIterator; | |
800 | ||
801 | Stack () : seq_ () | |
802 | { | |
803 | } | |
804 | ||
805 | Stack (unsigned n) : seq_ (n) | |
806 | { | |
807 | } | |
808 | ||
809 | inline | |
810 | T& | |
811 | operator [[]] (int index) | |
812 | { | |
813 | return seq_[[height () - 1 + index]]; | |
814 | } | |
815 | ||
816 | inline | |
817 | const T& | |
818 | operator [[]] (int index) const | |
819 | { | |
820 | return seq_[[height () - 1 + index]]; | |
821 | } | |
822 | ||
823 | inline | |
824 | void | |
825 | push (const T& t) | |
826 | { | |
827 | seq_.push_back (t); | |
828 | } | |
829 | ||
830 | inline | |
831 | void | |
832 | pop (unsigned n = 1) | |
833 | { | |
834 | for (; n; --n) | |
835 | seq_.pop_back (); | |
836 | } | |
837 | ||
838 | inline | |
839 | void | |
840 | reserve (unsigned n) | |
841 | { | |
842 | seq_.reserve (n); | |
843 | } | |
844 | ||
845 | inline | |
846 | unsigned | |
847 | height () const | |
848 | { | |
849 | return seq_.size (); | |
850 | } | |
851 | ||
852 | inline ConstIterator begin () const { return seq_.begin (); } | |
853 | inline ConstIterator end () const { return seq_.end (); } | |
854 | ||
855 | private: | |
856 | ||
857 | S seq_; | |
858 | }; | |
859 | ||
860 | template < class T, class S = Stack< T > > | |
861 | class Slice | |
862 | { | |
863 | public: | |
864 | ||
865 | Slice (const S& stack, | |
866 | unsigned range) : stack_ (stack), | |
867 | range_ (range) | |
868 | { | |
869 | } | |
870 | ||
871 | inline | |
872 | const T& | |
873 | operator [[]] (unsigned index) const | |
874 | { | |
875 | return stack_[[index - range_]]; | |
876 | } | |
877 | ||
878 | private: | |
879 | ||
880 | const S& stack_; | |
881 | unsigned range_; | |
882 | }; | |
883 | } | |
884 | ||
885 | #endif // not BISON_STACK_HH | |
886 | ||
887 | #output "location.hh" | |
888 | b4_copyright | |
889 | ||
890 | #ifndef BISON_LOCATION_HH | |
891 | # define BISON_LOCATION_HH | |
892 | ||
893 | namespace yy | |
894 | { | |
895 | struct Position | |
896 | { | |
897 | int line; | |
898 | int column; | |
899 | }; | |
900 | ||
901 | struct Location | |
902 | { | |
903 | Position first; | |
904 | Position last; | |
905 | }; | |
906 | } | |
907 | ||
908 | #endif // not BISON_LOCATION_HH |