]> git.saurik.com Git - bison.git/blame - data/lalr1.java
Get rid of broken %no-parser, -n, and --no-parser implementation and
[bison.git] / data / lalr1.java
CommitLineData
8405b70c
PB
1# Java skeleton for Bison -*- autoconf -*-
2
3# Copyright (C) 2007 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., 51 Franklin Street, Fifth Floor, Boston, MA
18# 02110-1301 USA
19
20m4_include(b4_pkgdatadir/[java.m4])
21
22b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java], [b4_skeleton])])
23m4_ifval(m4_defn([b4_symbol_destructors]),
24 [b4_fatal([%s: %%destructor does not make sense in Java], [b4_skeleton])],
25 [])
26
27m4_divert_push(0)dnl
28@output(b4_parser_file_name@)
29b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
30 [2007])
31
32b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);
33])[/* First part of user declarations. */
34]b4_pre_prologue
35b4_percent_code_get([[imports]])
36[/**
37 * A Bison parser, automatically generated from <tt>@ofile@</tt>.
38 *
39 * @@author LALR (1) parser skeleton written by Paolo Bonzini.
40 */
41]b4_public_if([public ])b4_abstract_if([abstract ])[class ]b4_parser_class_name[
42{
43 ]b4_identification[
44
45 /** True if verbose error messages are enabled. */
46 public boolean errorVerbose = ]b4_flag_value([error_verbose]);
47
48b4_locations_if([[
49 /**
50 * A class defining a pair of positions. Positions, defined by the
51 * <code>]b4_position_type[</code> class, denote a point in the input.
52 * Locations represent a part of the input through the beginning
53 * and ending positions. */
54 public class ]b4_location_type[ {
55 /** The first, inclusive, position in the range. */
56 public ]b4_position_type[ begin;
57
58 /** The first position beyond the range. */
59 public ]b4_position_type[ end;
60
61 /**
62 * Create a ]b4_location_type[ denoting an empty range located at
63 * a given point.
64 * @@param loc The position at which the range is anchored. */
65 public ]b4_location_type[ (]b4_position_type[ loc) {
66 this.begin = this.end = loc;
67 }
68
69 /**
70 * Create a <code>]b4_location_type[</code> from the endpoints of the range.
71 * @@param begin The first position included in the range.
72 * @@param begin The first position beyond the range. */
73 public ]b4_location_type[ (]b4_position_type[ begin, ]b4_position_type[ end) {
74 this.begin = begin;
75 this.end = end;
76 }
77
78 /**
79 * Print a representation of the location. For this to be correct,
80 * <code>]b4_position_type[</code> should override the <code>equals</code>
81 * method. */
82 public String toString () {
83 if (begin.equals (end))
84 return begin.toString ();
85 else
86 return begin.toString () + "-" + end.toString ();
87 }
88 }
89
90]])
91
92[ /** Token returned by the scanner to signal the end of its input. */
93 public static final int EOF = 0;]
94
95b4_token_enums(b4_tokens)
96
97 b4_locations_if([[
d3b12988 98 private ]b4_location_type[ yylloc (YYStack rhs, int n)
8405b70c
PB
99 {
100 if (n > 0)
101 return new ]b4_location_type[ (rhs.locationAt (1).begin, rhs.locationAt (n).end);
102 else
103 return new ]b4_location_type[ (rhs.locationAt (0).end);
104 }]])
105
01b477c6 106 /**
8405b70c
PB
107 * Communication interface between the scanner and the Bison-generated
108 * parser <tt>]b4_parser_class_name[</tt>.
109 */
110 public interface Lexer {
111 ]b4_locations_if([[/**
112 * Method to retrieve the beginning position of the last scanned token.
113 * @@return the position at which the last scanned token starts. */
114 ]b4_position_type[ getStartPos ();
115
116 /**
117 * Method to retrieve the ending position of the last scanned token.
118 * @@return the first position beyond the last scanned token. */
119 ]b4_position_type[ getEndPos ();]])[
120
121 /**
122 * Method to retrieve the semantic value of the last scanned token.
123 * @@return the semantic value of the last scanned token. */
01b477c6 124 ]b4_yystype[ getLVal ();]
8405b70c
PB
125
126 /**
8405b70c
PB
127 * Entry point for the scanner. Returns the token identifier corresponding
128 * to the next token and ]b4_pure_if([prepares to return], [stores])[
129 * the semantic value]b4_locations_if([ and beginning/ending positions])[
130 * of the token.
131 * @@return the token identifier corresponding to the next token. */
01b477c6 132 int yylex () ]b4_maybe_throws([b4_lex_throws])[;
8405b70c
PB
133
134 /**
135 * Entry point for error reporting. Emits an error
136 * ]b4_locations_if([ referring to the given location])[in a user-defined
137 * way.
138 *
139 * ]b4_locations_if([loc], [[The location of the element to which the
140 * error message is related]])[
141 * @@param s The string for the error message. */
01b477c6
PB
142 void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String s);]
143 }
144
145 b4_lexer_if([[private class YYLexer implements Lexer {
146]b4_percent_code_get([[lexer]])[
147 }
8405b70c 148
01b477c6
PB
149 ]])[/** The object doing lexical analysis for us. */
150 private Lexer yylexer;
151 ]
152 b4_parse_param_vars
8405b70c 153
01b477c6 154b4_lexer_if([[
8405b70c 155 /**
01b477c6 156 * Instantiates the Bison-generated parser.
8405b70c 157 */
01b477c6
PB
158 public ]b4_parser_class_name (b4_parse_param_decl([b4_lex_param_decl])[) {
159 this.yylexer = new YYLexer(]b4_lex_param_call[);
160 ]b4_parse_param_cons[
161 }
162]])
163
164 /**
165 * Instantiates the Bison-generated parser.
166 * @@param yylex The scanner that will supply tokens to the parser.
167 */
168 b4_lexer_if([[protected]], [[public]]) b4_parser_class_name[ (]b4_parse_param_decl([[Lexer yylexer]])[) {
169 this.yylexer = yylexer;
170 ]b4_parse_param_cons[
8405b70c
PB
171 }
172
d3b12988 173 private java.io.PrintStream yyDebugStream = System.err;
8405b70c
PB
174
175 /**
176 * Return the <tt>PrintStream</tt> on which the debugging output is
177 * printed.
178 */
d3b12988 179 public final java.io.PrintStream getDebugStream () { return yyDebugStream; }
8405b70c
PB
180
181 /**
182 * Set the <tt>PrintStream</tt> on which the debug output is printed.
183 * @@param s The stream that is used for debugging output.
184 */
d3b12988 185 public final void setDebugStream(java.io.PrintStream s) { yyDebugStream = s; }
8405b70c
PB
186
187 private int yydebug = 0;
188
189 /**
190 * Answer the verbosity of the debugging output; 0 means that all kinds of
191 * output from the parser are suppressed.
192 */
193 public final int getDebugLevel() { return yydebug; }
194
195 /**
196 * Set the verbosity of the debugging output; 0 means that all kinds of
197 * output from the parser are suppressed.
198 * @@param level The verbosity level for debugging output.
199 */
200 public final void setDebugLevel(int level) { yydebug = level; }
201
01b477c6
PB
202 private final int yylex () ]b4_maybe_throws([b4_lex_throws]) [{
203 return yylexer.yylex ();
8405b70c
PB
204 }
205 protected final void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String s) {
01b477c6
PB
206 yylexer.yyerror (]b4_locations_if([loc, ])[s);
207 }
208
209 ]b4_locations_if([
8405b70c 210 protected final void yyerror (String s) {
01b477c6 211 yylexer.yyerror ((Location)null, s);
8405b70c
PB
212 }
213 protected final void yyerror (]b4_position_type[ loc, String s) {
01b477c6 214 yylexer.yyerror (new ]b4_location_type[ (loc), s);
8405b70c
PB
215 }])
216
217 [protected final void yycdebug (String s) {
218 if (yydebug > 0)
d3b12988 219 yyDebugStream.println (s);
8405b70c
PB
220 }
221
d3b12988 222 private final class YYStack {
8405b70c
PB
223 private int[] stateStack = new int[16];
224 ]b4_locations_if([[private ]b4_location_type[[] locStack = new ]b4_location_type[[16];]])[
01b477c6 225 private ]b4_yystype[[] valueStack = new ]b4_yystype[[16];
8405b70c 226
8a93f8e6
PB
227 public int size = 16;
228 public int height = -1;
8405b70c 229
01b477c6 230 public final void push (int state, ]b4_yystype[ value]dnl
8405b70c
PB
231 b4_locations_if([, ]b4_location_type[ loc])[) {
232 height++;
233 if (size == height)
234 {
235 int[] newStateStack = new int[size * 2];
236 System.arraycopy (stateStack, 0, newStateStack, 0, height);
237 stateStack = newStateStack;
238 ]b4_locations_if([[
239 ]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2];
240 System.arraycopy (locStack, 0, newLocStack, 0, height);
241 locStack = newLocStack;]])
242
01b477c6 243 b4_yystype[[] newValueStack = new ]b4_yystype[[size * 2];
8405b70c
PB
244 System.arraycopy (valueStack, 0, newValueStack, 0, height);
245 valueStack = newValueStack;
246
247 size *= 2;
248 }
249
250 stateStack[height] = state;
251 ]b4_locations_if([[locStack[height] = loc;]])[
252 valueStack[height] = value;
253 }
254
255 public final void pop () {
256 height--;
257 }
258
259 public final void pop (int num) {
260 // Avoid memory leaks... garbage collection is a white lie!
261 if (num > 0) {
262 java.util.Arrays.fill (valueStack, height - num + 1, height, null);
263 ]b4_locations_if([[java.util.Arrays.fill (locStack, height - num + 1, height, null);]])[
264 }
265 height -= num;
266 }
267
268 public final int stateAt (int i) {
269 return stateStack[height - i];
270 }
271
272 ]b4_locations_if([[public final ]b4_location_type[ locationAt (int i) {
273 return locStack[height - i];
274 }
275
01b477c6 276 ]])[public final ]b4_yystype[ valueAt (int i) {
8405b70c
PB
277 return valueStack[height - i];
278 }
279
280 // Print the state stack on the debug stream.
8a93f8e6 281 public void print (java.io.PrintStream out)
8405b70c
PB
282 {
283 out.print ("Stack now");
284
285 for (int i = 0; i < height; i++)
286 {
287 out.print (' ');
288 out.print (stateStack[i]);
289 }
290 out.println ();
291 }
292 }
293
294 /**
295 * Returned by a Bison action in order to stop the parsing process and
296 * return success (<tt>true</tt>). */
297 public static final int YYACCEPT = 0;
298
299 /**
300 * Returned by a Bison action in order to stop the parsing process and
301 * return failure (<tt>false</tt>). */
302 public static final int YYABORT = 1;
303
304 /**
305 * Returned by a Bison action in order to start error recovery without
306 * printing an error message. */
307 public static final int YYERROR = 2;
308
309 /**
310 * Returned by a Bison action in order to print an error message and start
311 * error recovery. */
312 public static final int YYFAIL = 3;
313
314 private static final int YYNEWSTATE = 4;
315 private static final int YYDEFAULT = 5;
316 private static final int YYREDUCE = 6;
317 private static final int YYERRLAB1 = 7;
318 private static final int YYRETURN = 8;
319
320 private int yyerrstatus_ = 0;
321
322 /**
323 * Return whether error recovery is being done. In this state, the parser
324 * reads token until it reaches a known state, and then restarts normal
325 * operation. */
d3b12988 326 public final boolean recovering ()
8405b70c
PB
327 {
328 return yyerrstatus_ == 0;
329 }
330
d3b12988 331 private int yyaction (int yyn, YYStack yystack, int yylen)
8405b70c 332 {
01b477c6 333 ]b4_yystype[ yyval;
8405b70c
PB
334 ]b4_locations_if([b4_location_type[ yyloc = yylloc (yystack, yylen);]])[
335
336 /* If YYLEN is nonzero, implement the default value of the action:
337 `$$ = $1'. Otherwise, use the top of the stack.
338
339 Otherwise, the following line sets YYVAL to garbage.
340 This behavior is undocumented and Bison
341 users should not rely upon it. */
342 if (yylen > 0)
343 yyval = yystack.valueAt (yylen - 1);
344 else
345 yyval = yystack.valueAt (0);
346
347 yy_reduce_print (yyn, yystack);
348
349 switch (yyn)
350 {
351 ]b4_user_actions[
352 default: break;
353 }
354
355 yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);
356
357 yystack.pop (yylen);
358 yylen = 0;
359
360 /* Shift the result of the reduction. */
361 yyn = yyr1_[yyn];
362 int yystate = yypgoto_[yyn - yyntokens_] + yystack.stateAt (0);
363 if (0 <= yystate && yystate <= yylast_
364 && yycheck_[yystate] == yystack.stateAt (0))
365 yystate = yytable_[yystate];
366 else
367 yystate = yydefgoto_[yyn - yyntokens_];
368
369 yystack.push (yystate, yyval]b4_locations_if([, yyloc])[);
370 return YYNEWSTATE;
371 }
372
373 /* Return YYSTR after stripping away unnecessary quotes and
374 backslashes, so that it's suitable for yyerror. The heuristic is
375 that double-quoting is unnecessary unless the string contains an
376 apostrophe, a comma, or backslash (other than backslash-backslash).
377 YYSTR is taken from yytname. */
378 private final String yytnamerr_ (String yystr)
379 {
380 if (yystr.charAt (0) == '"')
381 {
382 StringBuffer yyr = new StringBuffer ();
383 strip_quotes: for (int i = 1; i < yystr.length (); i++)
384 switch (yystr.charAt (i))
385 {
386 case '\'':
387 case ',':
388 break strip_quotes;
389
390 case '\\':
391 if (yystr.charAt(++i) != '\\')
392 break strip_quotes;
393 /* Fall through. */
394 default:
395 yyr.append (yystr.charAt (i));
396 break;
397
398 case '"':
399 return yyr.toString ();
400 }
401 }
402 else if (yystr.equals ("$end"))
403 return "end of input";
404
405 return yystr;
406 }
407
408 /*--------------------------------.
409 | Print this symbol on YYOUTPUT. |
410 `--------------------------------*/
411
412 private void yy_symbol_print (String s, int yytype,
01b477c6 413 ]b4_yystype[ yyvaluep]dnl
8405b70c
PB
414 b4_locations_if([, Object yylocationp])[)
415 {
416 if (yydebug > 0)
417 yycdebug (s + (yytype < yyntokens_ ? " token " : " nterm ")
418 + yytname_[yytype] + " ("]b4_locations_if([
419 + yylocationp + ": "])[
420 + (yyvaluep == null ? "(null)" : yyvaluep) + ")");
421 }
422
423 /**
424 * Parse input from the scanner that was specified at object construction
425 * time. Return whether the end of the input was reached successfully.
426 *
427 * @@return <tt>true</tt> if the parsing succeeds. Note that this does not
428 * imply that there were no syntax errors.
429 */
430 public boolean parse () ]b4_maybe_throws([b4_throws])[
431 {
432 /// Lookahead and lookahead in internal form.
433 int yychar = yyempty_;
434 int yytoken = 0;
435
436 /* State. */
437 int yyn = 0;
438 int yylen = 0;
439 int yystate = 0;
440
d3b12988 441 YYStack yystack = new YYStack ();
8405b70c
PB
442
443 /* Error handling. */
444 int yynerrs_ = 0;
445 ]b4_locations_if([/// The location where the error started.
446 ]b4_location_type[ yyerrloc = null;
447
448 /// ]b4_location_type[ of the lookahead.
449 ]b4_location_type[ yylloc = new ]b4_location_type[ (null, null);
450
451 /// @@$.
452 ]b4_location_type[ yyloc;])
453
454 /// Semantic value of the lookahead.
01b477c6 455 b4_yystype[ yylval = null;
8405b70c
PB
456
457 int yyresult;
458
459 yycdebug ("Starting parse\n");
460 yyerrstatus_ = 0;
461
462]m4_ifdef([b4_initial_action], [
463m4_pushdef([b4_at_dollar], [yylloc])dnl
464m4_pushdef([b4_dollar_dollar], [yylval])dnl
465 /* User initialization code. */
466 b4_user_initial_action
467m4_popdef([b4_dollar_dollar])dnl
468m4_popdef([b4_at_dollar])])dnl
469
470 [ /* Initialize the stack. */
471 yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
472
473 int label = YYNEWSTATE;
474 for (;;)
475 switch (label)
476 {
477 /* New state. Unlike in the C/C++ skeletons, the state is already
478 pushed when we come here. */
479 case YYNEWSTATE:
480 yycdebug ("Entering state " + yystate + "\n");
481 if (yydebug > 0)
d3b12988 482 yystack.print (yyDebugStream);
8405b70c
PB
483
484 /* Accept? */
485 if (yystate == yyfinal_)
486 return true;
487
488 /* Take a decision. First try without lookahead. */
489 yyn = yypact_[yystate];
490 if (yyn == yypact_ninf_)
491 {
492 label = YYDEFAULT;
493 break;
494 }
495
496 /* Read a lookahead token. */
497 if (yychar == yyempty_)
498 {
499 yycdebug ("Reading a token: ");
01b477c6
PB
500 yychar = yylex ();]
501 b4_locations_if([[
502 yylloc = new ]b4_location_type[(yylexer.getStartPos (),
503 yylexer.getEndPos ());]])
504 yylval = yylexer.getLVal ();[
8405b70c
PB
505 }
506
507 /* Convert token to internal form. */
508 if (yychar <= EOF)
509 {
510 yychar = yytoken = EOF;
511 yycdebug ("Now at end of input.\n");
512 }
513 else
514 {
515 yytoken = yytranslate_ (yychar);
516 yy_symbol_print ("Next token is", yytoken,
517 yylval]b4_locations_if([, yylloc])[);
518 }
519
520 /* If the proper action on seeing token YYTOKEN is to reduce or to
521 detect an error, take that action. */
522 yyn += yytoken;
523 if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
524 label = YYDEFAULT;
525
526 /* <= 0 means reduce or error. */
527 else if ((yyn = yytable_[yyn]) <= 0)
528 {
529 if (yyn == 0 || yyn == yytable_ninf_)
530 label = YYFAIL;
531 else
532 {
533 yyn = -yyn;
534 label = YYREDUCE;
535 }
536 }
537
538 else
539 {
540 /* Shift the lookahead token. */
541 yy_symbol_print ("Shifting", yytoken,
542 yylval]b4_locations_if([, yylloc])[);
543
544 /* Discard the token being shifted. */
545 yychar = yyempty_;
546
547 /* Count tokens shifted since error; after three, turn off error
548 status. */
549 if (yyerrstatus_ > 0)
550 --yyerrstatus_;
551
552 yystate = yyn;
553 yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
554 label = YYNEWSTATE;
555 }
556 break;
557
558 /*-----------------------------------------------------------.
559 | yydefault -- do the default action for the current state. |
560 `-----------------------------------------------------------*/
561 case YYDEFAULT:
562 yyn = yydefact_[yystate];
563 if (yyn == 0)
564 label = YYFAIL;
565 else
566 label = YYREDUCE;
567 break;
568
569 /*-----------------------------.
570 | yyreduce -- Do a reduction. |
571 `-----------------------------*/
572 case YYREDUCE:
573 yylen = yyr2_[yyn];
574 label = yyaction (yyn, yystack, yylen);
575 yystate = yystack.stateAt (0);
576 break;
577
578 /*------------------------------------.
579 | yyerrlab -- here on detecting error |
580 `------------------------------------*/
581 case YYFAIL:
582 /* If not already recovering from an error, report this error. */
583 if (yyerrstatus_ == 0)
584 {
585 ++yynerrs_;
586 yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
587 }
588
589 ]b4_locations_if([yyerrloc = yylloc;])[
590 if (yyerrstatus_ == 3)
591 {
592 /* If just tried and failed to reuse lookahead token after an
593 error, discard it. */
594
595 if (yychar <= EOF)
596 {
597 /* Return failure if at end of input. */
598 if (yychar == EOF)
599 return false;
600 }
601 else
602 yychar = yyempty_;
603 }
604
605 /* Else will try to reuse lookahead token after shifting the error
606 token. */
607 label = YYERRLAB1;
608 break;
609
610 /*---------------------------------------------------.
611 | errorlab -- error raised explicitly by YYERROR. |
612 `---------------------------------------------------*/
613 case YYERROR:
614
615 ]b4_locations_if([yyerrloc = yystack.locationAt (yylen - 1);])[
616 /* Do not reclaim the symbols of the rule which action triggered
617 this YYERROR. */
618 yystack.pop (yylen);
619 yylen = 0;
620 yystate = yystack.stateAt (0);
621 label = YYERRLAB1;
622 break;
623
624 /*-------------------------------------------------------------.
625 | yyerrlab1 -- common code for both syntax error and YYERROR. |
626 `-------------------------------------------------------------*/
627 case YYERRLAB1:
628 yyerrstatus_ = 3; /* Each real token shifted decrements this. */
629
630 for (;;)
631 {
632 yyn = yypact_[yystate];
633 if (yyn != yypact_ninf_)
634 {
635 yyn += yyterror_;
636 if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
637 {
638 yyn = yytable_[yyn];
639 if (0 < yyn)
640 break;
641 }
642 }
643
644 /* Pop the current state because it cannot handle the error token. */
645 if (yystack.height == 1)
646 return false;
647
648 ]b4_locations_if([yyerrloc = yystack.locationAt (0);])[
649 yystack.pop ();
650 yystate = yystack.stateAt (0);
651 if (yydebug > 0)
d3b12988 652 yystack.print (yyDebugStream);
8405b70c
PB
653 }
654
655 ]b4_locations_if([
656 /* Muck with the stack to setup for yylloc. */
657 yystack.push (0, null, yylloc);
658 yystack.push (0, null, yyerrloc);
659 yyloc = yylloc (yystack, 2);
660 yystack.pop (2);])[
661
662 /* Shift the error token. */
663 yy_symbol_print ("Shifting", yystos_[yyn],
664 yylval]b4_locations_if([, yyloc])[);
665
666 yystate = yyn;
667 yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
668 label = YYNEWSTATE;
669 break;
670
671 /* Accept. */
672 case YYACCEPT:
673 return true;
674
675 /* Abort. */
676 case YYABORT:
677 return false;
678 }
679 }
680
681 // Generate an error message.
682 private String yysyntax_error (int yystate, int tok)
683 {
684 if (errorVerbose)
685 {
686 int yyn = yypact_[yystate];
687 if (yypact_ninf_ < yyn && yyn <= yylast_)
688 {
689 StringBuffer res;
690
691 /* Start YYX at -YYN if negative to avoid negative indexes in
692 YYCHECK. */
693 int yyxbegin = yyn < 0 ? -yyn : 0;
694
695 /* Stay within bounds of both yycheck and yytname. */
696 int yychecklim = yylast_ - yyn + 1;
697 int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
698 int count = 0;
699 for (int x = yyxbegin; x < yyxend; ++x)
700 if (yycheck_[x + yyn] == x && x != yyterror_)
701 ++count;
702
703 // FIXME: This method of building the message is not compatible
704 // with internationalization.
705 res = new StringBuffer ("syntax error, unexpected ");
706 res.append (yytnamerr_ (yytname_[tok]));
707 if (count < 5)
708 {
709 count = 0;
710 for (int x = yyxbegin; x < yyxend; ++x)
711 if (yycheck_[x + yyn] == x && x != yyterror_)
712 {
713 res.append (count++ == 0 ? ", expecting " : " or ");
714 res.append (yytnamerr_ (yytname_[x]));
715 }
716 }
717 return res.toString ();
718 }
719 }
720
721 return "syntax error";
722 }
723
724
725 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
726 STATE-NUM. */
727 private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;
728 private static final ]b4_int_type_for([b4_pact])[ yypact_[] =
729 {
730 ]b4_pact[
731 };
732
733 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
734 doesn't specify something else to do. Zero means the default is an
735 error. */
736 private static final ]b4_int_type_for([b4_defact])[ yydefact_[] =
737 {
738 ]b4_defact[
739 };
740
741 /* YYPGOTO[NTERM-NUM]. */
742 private static final ]b4_int_type_for([b4_pgoto])[ yypgoto_[] =
743 {
744 ]b4_pgoto[
745 };
746
747 /* YYDEFGOTO[NTERM-NUM]. */
748 private static final ]b4_int_type_for([b4_defgoto])[
749 yydefgoto_[] =
750 {
751 ]b4_defgoto[
752 };
753
754 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
755 positive, shift that token. If negative, reduce the rule which
756 number is the opposite. If zero, do what YYDEFACT says. */
757 private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
758 private static final ]b4_int_type_for([b4_table])[
759 yytable_[] =
760 {
761 ]b4_table[
762 };
763
764 /* YYCHECK. */
765 private static final ]b4_int_type_for([b4_check])[
766 yycheck_[] =
767 {
768 ]b4_check[
769 };
770
771 /* STOS_[STATE-NUM] -- The (internal number of the) accessing
772 symbol of state STATE-NUM. */
773 private static final ]b4_int_type_for([b4_stos])[
774 yystos_[] =
775 {
776 ]b4_stos[
777 };
778
779 /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
780 to YYLEX-NUM. */
781 private static final ]b4_int_type_for([b4_toknum])[
782 yytoken_number_[] =
783 {
784 ]b4_toknum[
785 };
786
787 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
788 private static final ]b4_int_type_for([b4_r1])[
789 yyr1_[] =
790 {
791 ]b4_r1[
792 };
793
794 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
795 private static final ]b4_int_type_for([b4_r2])[
796 yyr2_[] =
797 {
798 ]b4_r2[
799 };
800
801 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
802 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
803 private static final String yytname_[] =
804 {
805 ]b4_tname[
806 };
807
808 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
809 private static final ]b4_int_type_for([b4_rhs])[ yyrhs_[] =
810 {
811 ]b4_rhs[
812 };
813
814 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
815 YYRHS. */
816 private static final ]b4_int_type_for([b4_prhs])[ yyprhs_[] =
817 {
818 ]b4_prhs[
819 };
820
821 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
822 private static final ]b4_int_type_for([b4_rline])[ yyrline_[] =
823 {
824 ]b4_rline[
825 };
826
827 // Report on the debug stream that the rule yyrule is going to be reduced.
d3b12988 828 private void yy_reduce_print (int yyrule, YYStack yystack)
8405b70c
PB
829 {
830 if (yydebug == 0)
831 return;
832
833 int yylno = yyrline_[yyrule];
834 int yynrhs = yyr2_[yyrule];
835 /* Print the symbols being reduced, and their result. */
836 yycdebug ("Reducing stack by rule " + (yyrule - 1)
837 + " (line " + yylno + "), ");
838
839 /* The symbols being reduced. */
840 for (int yyi = 0; yyi < yynrhs; yyi++)
841 yy_symbol_print (" $" + (yyi + 1) + " =",
842 yyrhs_[yyprhs_[yyrule] + yyi],
843 ]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
844 b4_rhs_location(yynrhs, yyi + 1)])[);
845 }
846
847 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
848 private static final ]b4_int_type_for([b4_translate])[ yytranslate_table_[] =
849 {
850 ]b4_translate[
851 };
852
853 private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
854 {
855 if (t >= 0 && t <= yyuser_token_number_max_)
856 return yytranslate_table_[t];
857 else
858 return yyundef_token_;
859 }
860
861 private static final int yylast_ = ]b4_last[;
862 private static final int yynnts_ = ]b4_nterms_number[;
863 private static final int yyempty_ = -2;
864 private static final int yyfinal_ = ]b4_final_state_number[;
865 private static final int yyterror_ = 1;
866 private static final int yyerrcode_ = 256;
867 private static final int yyntokens_ = ]b4_tokens_number[;
868
869 private static final int yyuser_token_number_max_ = ]b4_user_token_number_max[;
870 private static final int yyundef_token_ = ]b4_undef_token_number[;
871
872]/* User implementation code. */
873b4_percent_code_get[]dnl
874
875}
876
877b4_epilogue
878m4_divert_pop(0)dnl