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