X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/2b008529edd233bac07a58d557869ae902be1818..5335b65a79189afbbd27ecb55d76e74a4fe31863:/data/lalr1.java diff --git a/data/lalr1.java b/data/lalr1.java index b89a4233..6637c3a2 100644 --- a/data/lalr1.java +++ b/data/lalr1.java @@ -1,6 +1,6 @@ # Java skeleton for Bison -*- autoconf -*- -# Copyright (C) 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,6 +20,9 @@ m4_include(b4_pkgdatadir/[java.m4]) b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java], [b4_skeleton])]) +# We don't depend on %debug in Java, but pacify warnings about non-used flags. +b4_parse_trace_if([0], [0]) + m4_define([b4_symbol_no_destructor_assert], [b4_symbol_if([$1], [has_destructor], [b4_fatal([%s: %s: %%destructor does not make sense in Java], @@ -30,7 +33,7 @@ b4_symbol_foreach([b4_symbol_no_destructor_assert]) m4_divert_push(0)dnl @output(b4_parser_file_name@)@ b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java], - [2007, 2008]) + [2007, 2008, 2009]) b4_percent_define_ifdef([package], [package b4_percent_define_get([package]); ])[/* First part of user declarations. */ @@ -530,7 +533,7 @@ m4_popdef([b4_at_dollar])])dnl /* Take a decision. First try without lookahead. */ yyn = yypact_[yystate]; - if (yyn == yypact_ninf_) + if (yy_pact_value_is_default_ (yyn)) { label = YYDEFAULT; break; @@ -569,7 +572,7 @@ m4_popdef([b4_at_dollar])])dnl /* <= 0 means reduce or error. */ else if ((yyn = yytable_[yyn]) <= 0) { - if (yyn == 0 || yyn == yytable_ninf_) + if (yy_table_value_is_error_ (yyn)) label = YYFAIL; else { @@ -673,7 +676,7 @@ m4_popdef([b4_at_dollar])])dnl for (;;) { yyn = yypact_[yystate]; - if (yyn != yypact_ninf_) + if (!yy_pact_value_is_default_ (yyn)) { yyn += yyterror_; if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) @@ -732,7 +735,8 @@ m4_popdef([b4_at_dollar])])dnl StringBuffer res; /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ + YYCHECK. In other words, skip the first -YYN actions for this + state because they are default actions. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ @@ -740,7 +744,8 @@ m4_popdef([b4_at_dollar])])dnl int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; int count = 0; for (int x = yyxbegin; x < yyxend; ++x) - if (yycheck_[x + yyn] == x && x != yyterror_) + if (yycheck_[x + yyn] == x && x != yyterror_ + && !yy_table_value_is_error_ (yytable_[x + yyn])) ++count; // FIXME: This method of building the message is not compatible @@ -751,7 +756,8 @@ m4_popdef([b4_at_dollar])])dnl { count = 0; for (int x = yyxbegin; x < yyxend; ++x) - if (yycheck_[x + yyn] == x && x != yyterror_) + if (yycheck_[x + yyn] == x && x != yyterror_ + && !yy_table_value_is_error_ (yytable_[x + yyn])) { res.append (count++ == 0 ? ", expecting " : " or "); res.append (yytnamerr_ (yytname_[x])); @@ -764,6 +770,24 @@ m4_popdef([b4_at_dollar])])dnl return "syntax error"; } + /** + * Whether the given yypact_ value indicates a defaulted state. + * @@param yyvalue the value to check + */ + private static boolean yy_pact_value_is_default_ (int yyvalue) + { + return yyvalue == yypact_ninf_; + } + + /** + * Whether the given yytable_ value indicates a syntax error. + * @@param yyvalue the value to check + */ + private static boolean yy_table_value_is_error_ (int yyvalue) + { + return yyvalue == yytable_ninf_; + } + private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[; private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[; @@ -826,5 +850,5 @@ b4_percent_code_get[]dnl } -b4_epilogue +b4_epilogue[]dnl m4_divert_pop(0)dnl