global: remove unnecessary horizontal tabs.

This change was made by applying emacs' untabify function to
nearly all files in Bison's repository.  Required tabs in make
files, ChangeLog, regexps, and test code were manually skipped.
Other notable exceptions and changes are listed below.
* bootstrap: Skip because we sync this with gnulib.
* data/m4sugar/foreach.m4
* data/m4sugar/m4sugar.m4: Skip because we sync these with
Autoconf.
* djgpp: Skip because I don't know how to test djgpp properly, and
this code appears to be unmaintained anyway.
* README-hacking (Hacking): Specify that tabs should be avoided
where not required.
This commit is contained in:
Joel E. Denny
2011-07-24 17:50:37 -04:00
parent c12aa01f82
commit e969014232
98 changed files with 5335 additions and 5312 deletions

View File

@@ -1,3 +1,19 @@
2011-07-24 Joel E. Denny <joeldenny@joeldenny.org>
global: remove unnecessary horizontal tabs.
This change was made by applying emacs' untabify function to
nearly all files in Bison's repository. Required tabs in make
files, ChangeLog, regexps, and test code were manually skipped.
Other notable exceptions and changes are listed below.
* bootstrap: Skip because we sync this with gnulib.
* data/m4sugar/foreach.m4
* data/m4sugar/m4sugar.m4: Skip because we sync these with
Autoconf.
* djgpp: Skip because I don't know how to test djgpp properly, and
this code appears to be unmaintained anyway.
* README-hacking (Hacking): Specify that tabs should be avoided
where not required.
2011-07-10 Joel E. Denny <joeldenny@joeldenny.org>
build: avoid YACC typo inherited from Autoconf.

22
NEWS
View File

@@ -894,26 +894,26 @@ Bison News
if the symbols have destructors. For instance:
exp: exp "?" exp ":" exp { $1 ? $1 : $3; }
| exp "+" exp
;
| exp "+" exp
;
will trigger a warning about $$ and $5 in the first rule, and $3 in
the second ($1 is copied to $$ by the default rule). This example
most likely contains three errors, and could be rewritten as:
exp: exp "?" exp ":" exp
{ $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); }
| exp "+" exp
{ $$ = $1 ? $1 : $3; if ($1) free ($3); }
;
{ $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); }
| exp "+" exp
{ $$ = $1 ? $1 : $3; if ($1) free ($3); }
;
However, if the original actions were really intended, memory leaks
and all, the warnings can be suppressed by letting Bison believe the
values are used, e.g.:
exp: exp "?" exp ":" exp { $1 ? $1 : $3; (void) ($$, $5); }
| exp "+" exp { $$ = $1; (void) $3; }
;
| exp "+" exp { $$ = $1; (void) $3; }
;
If there are mid-rule actions, the warning is issued if no action
uses it. The following triggers no warning: $1 and $3 are used.
@@ -1157,16 +1157,16 @@ Bison News
In agreement with POSIX and with other Yaccs, leaving a default
action is valid when $$ is untyped, and $1 typed:
untyped: ... typed;
untyped: ... typed;
but the converse remains an error:
typed: ... untyped;
typed: ... untyped;
** Values of mid-rule actions
The following code:
foo: { ... } { $$ = $1; } ...
foo: { ... } { $$ = $1; } ...
was incorrectly rejected: $1 is defined in the second mid-rule
action, and is equal to the $$ of the first mid-rule action.

View File

@@ -46,6 +46,13 @@ of the .output file etc. This excludes impossible error messages
(comparable to assert/abort), and all the --trace output which is
meant for the maintainers only.
** Horizontal tabs
Do not add horizontal tab characters to any file in Bison's repository
except where required. For example, do not use tabs to format C code.
However, make files, ChangeLog, and some regular expressions require
tabs. Also, test cases might need to contain tabs to check that Bison
properly processes tabs in its input.
* Working from the repository

View File

@@ -25,8 +25,8 @@ LALR(1) Look-Ahead Sets", ACM Transactions on Programming Languages
and Systems (TOPLAS) 4, 4 (October 1982), 615-649. Their
technique is the standard one now.)
paul rubin
free software foundation
paul rubin
free software foundation
[DeRemer-Pennello reference corrected by Paul Eggert <eggert@cs.ucla.edu>,

44
TODO
View File

@@ -166,11 +166,11 @@ what it should look like. For instance what follows crashes.
The code in yyerrlab reads:
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
There are only two yychar that can be <= YYEOF: YYEMPTY and YYEOF.
But I can't produce the situation where yychar is YYEMPTY here, is it
@@ -280,7 +280,7 @@ Note that there remains the problem of locations: `@r'?
We should find a means to provide an access to values deep in the
stack. For instance, instead of
baz: qux { $$ = $<foo>-1 + $<bar>0 + $1; }
baz: qux { $$ = $<foo>-1 + $<bar>0 + $1; }
we should be able to have:
@@ -313,13 +313,13 @@ XML output for GNU Bison
* Unit rules
Maybe we could expand unit rules, i.e., transform
exp: arith | bool;
arith: exp '+' exp;
bool: exp '&' exp;
exp: arith | bool;
arith: exp '+' exp;
bool: exp '&' exp;
into
exp: exp '+' exp | exp '&' exp;
exp: exp '+' exp | exp '&' exp;
when there are no actions. This can significantly speed up some
grammars. I can't find the papers. In particular the book `LR
@@ -344,19 +344,19 @@ Wow, %printer is not documented. Clearly mark YYPRINT as obsolete.
* Coding system independence
Paul notes:
Currently Bison assumes 8-bit bytes (i.e. that UCHAR_MAX is
255). It also assumes that the 8-bit character encoding is
the same for the invocation of 'bison' as it is for the
invocation of 'cc', but this is not necessarily true when
people run bison on an ASCII host and then use cc on an EBCDIC
host. I don't think these topics are worth our time
addressing (unless we find a gung-ho volunteer for EBCDIC or
PDP-10 ports :-) but they should probably be documented
somewhere.
Currently Bison assumes 8-bit bytes (i.e. that UCHAR_MAX is
255). It also assumes that the 8-bit character encoding is
the same for the invocation of 'bison' as it is for the
invocation of 'cc', but this is not necessarily true when
people run bison on an ASCII host and then use cc on an EBCDIC
host. I don't think these topics are worth our time
addressing (unless we find a gung-ho volunteer for EBCDIC or
PDP-10 ports :-) but they should probably be documented
somewhere.
More importantly, Bison does not currently allow NUL bytes in
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
the source code. This should get fixed.
More importantly, Bison does not currently allow NUL bytes in
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
the source code. This should get fixed.
* --graph
Show reductions.

View File

@@ -18,50 +18,50 @@ while (<STDIN>)
\s # Spaces.
/x)
{
my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
$short = '' if ! defined $short;
$short = '-d' if $long eq '--defines' && ! $short;
my $dir = '%' . substr($long, 2);
if (index ($scanner, "\"$dir\"") < 0)
{
if ($long eq '--force-define') { $dir = '%define'; }
else { $dir = ''; }
}
if ($arg)
{
my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
$short = '' if ! defined $short;
$short = '-d' if $long eq '--defines' && ! $short;
my $dir = '%' . substr($long, 2);
if (index ($scanner, "\"$dir\"") < 0)
{
if ($long eq '--force-define') { $dir = '%define'; }
else { $dir = ''; }
}
if ($arg)
{
# if $opt, $arg contains the closing ].
substr ($arg, -1) = ''
if $opt eq '[';
$arg =~ s/^=//;
$arg =~ s/^=//;
$arg = lc ($arg);
my $dir_arg = $arg;
my $dir_arg = $arg;
# If the argument is compite (e.g., for --define[=NAME[=VALUE]]),
# put each word in @var, to build @var{name}[=@var{value}], not
# @var{name[=value]}].
$arg =~ s/(\w+)/\@var{$1}/g;
my $long_arg = "=$arg";
if ($opt eq '[') {
$long_arg = "[$long_arg]";
$arg = "[$arg]";
}
# For arguments of directives: this only works if all arguments
# are strings and have the same syntax as on the command line.
if ($dir_arg eq 'name[=value]')
{
$dir_arg = '@var{name} ["@var{value}"]';
}
else
{
$dir_arg =~ s/(\w+)/\@var{"$1"}/g;
$dir_arg = '[' . $dir_arg . ']'
if $opt eq '[';
}
$long = "$long$long_arg";
$short = "$short $arg" if $short && $short ne '-d';
$dir = "$dir $dir_arg" if $dir;
}
$option{$long} = $short;
$directive{$long} = $dir;
$arg =~ s/(\w+)/\@var{$1}/g;
my $long_arg = "=$arg";
if ($opt eq '[') {
$long_arg = "[$long_arg]";
$arg = "[$arg]";
}
# For arguments of directives: this only works if all arguments
# are strings and have the same syntax as on the command line.
if ($dir_arg eq 'name[=value]')
{
$dir_arg = '@var{name} ["@var{value}"]';
}
else
{
$dir_arg =~ s/(\w+)/\@var{"$1"}/g;
$dir_arg = '[' . $dir_arg . ']'
if $opt eq '[';
}
$long = "$long$long_arg";
$short = "$short $arg" if $short && $short ne '-d';
$dir = "$dir $dir_arg" if $dir;
}
$option{$long} = $short;
$directive{$long} = $dir;
}
}

View File

@@ -1,5 +1,5 @@
EXTRA_DIST += \
build-aux/cross-options.pl \
build-aux/move-if-change \
build-aux/prev-version.txt \
EXTRA_DIST += \
build-aux/cross-options.pl \
build-aux/move-if-change \
build-aux/prev-version.txt \
build-aux/update-b4-copyright

View File

@@ -61,7 +61,7 @@ AC_ARG_ENABLE(gcc-warnings,
yes|no) ;;
*) AC_MSG_ERROR([bad value ${enableval} for gcc-warnings option]) ;;
esac],
[enableval=no])
[enableval=no])
if test "${enableval}" = yes; then
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
AC_SUBST([WERROR_CFLAGS])
@@ -175,7 +175,7 @@ do
eval "test x\$$ac_var = x || $ac_var=lib/\$$ac_var"
done
AC_CONFIG_FILES([Makefile
po/Makefile.in
examples/calc++/Makefile
doc/yacc.1])
po/Makefile.in
examples/calc++/Makefile
doc/yacc.1])
AC_OUTPUT

View File

@@ -304,8 +304,8 @@ m4_define([b4_parser_tables_define],
m4_define([b4_flag_if],
[m4_case(b4_$1_flag,
[0], [$3],
[1], [$2],
[m4_fatal([invalid $1 value: ]$1)])])
[1], [$2],
[m4_fatal([invalid $1 value: ]$1)])])
# b4_define_flag_if(FLAG)
@@ -330,10 +330,10 @@ m4_define([b4_$3_if],
# b4_FLAG_if(IF-TRUE, IF-FALSE)
# -----------------------------
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
b4_define_flag_if([defines]) # Whether headers are requested.
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
b4_define_flag_if([defines]) # Whether headers are requested.
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
## --------- ##
@@ -435,7 +435,7 @@ m4_define([b4_type_action_],
b4_dollar_dollar([b4_symbol([$1], [number])],
[b4_symbol([$1], [tag])],
[b4_symbol([$1], [type])]);
break;
break;
])])
@@ -629,8 +629,8 @@ m4_define([b4_percent_define_get_syncline],
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
m4_define([b4_percent_define_ifdef],
[m4_ifdef([b4_percent_define(]$1[)],
[b4_percent_define_use([$1])$2],
[$3])])
[b4_percent_define_use([$1])$2],
[$3])])
## --------- ##
@@ -765,7 +765,7 @@ m4_popdef([b4_macro_name])])
m4_define([b4_percent_code_ifdef],
[m4_ifdef([b4_percent_code(]$1[)],
[m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])$2],
[$3])])
[$3])])
## ------------------ ##

View File

@@ -405,24 +405,24 @@ m4_define([b4_parse_param_decl_1],
# Extra initialisations of the constructor.
m4_define([b4_parse_param_cons],
[m4_ifset([b4_parse_param],
[
[
b4_cc_constructor_calls(b4_parse_param)])])
m4_define([b4_cc_constructor_calls],
[m4_map_sep([b4_cc_constructor_call], [,
[m4_map_sep([b4_cc_constructor_call], [,
], [$@])])
m4_define([b4_cc_constructor_call],
[$2 ($2_yyarg)])
[$2 ($2_yyarg)])
# b4_parse_param_vars
# -------------------
# Extra instance variables.
m4_define([b4_parse_param_vars],
[m4_ifset([b4_parse_param],
[
[
/* User arguments. */
b4_cc_var_decls(b4_parse_param)])])
m4_define([b4_cc_var_decls],
[m4_map_sep([b4_cc_var_decl], [
[m4_map_sep([b4_cc_var_decl], [
], [$@])])
m4_define([b4_cc_var_decl],
[ $1;])
[ $1;])

View File

@@ -146,7 +146,7 @@ m4_define([b4_int_type],
m4_eval([0 <= $1]), [1], [unsigned int],
[int])])
[int])])
# b4_int_type_for(NAME)
@@ -235,7 +235,7 @@ m4_define([b4_token_enums],
enum yytokentype {
m4_map_sep([ b4_token_enum], [,
],
[$@])
[$@])
};
#endif
])])
@@ -314,7 +314,7 @@ $1 (b4_c_ansi_formals(m4_shift2($@)))[]dnl
m4_define([b4_c_ansi_formals],
[m4_if([$#], [0], [void],
[$#$1], [1], [void],
[m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
[m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
m4_define([b4_c_ansi_formal],
[$1])
@@ -335,9 +335,9 @@ m4_define([b4_c_knr_formal_name],
# Output the K&R argument declarations.
m4_define([b4_c_knr_formal_decls],
[m4_map_sep([b4_c_knr_formal_decl],
[
[
],
[$@])])
[$@])])
m4_define([b4_c_knr_formal_decl],
[ $1;])
@@ -457,7 +457,7 @@ b4_parse_param_use[]dnl
{
]b4_symbol_foreach([b4_symbol_destructor])dnl
[ default:
break;
break;
}
}]dnl
])
@@ -477,9 +477,9 @@ m4_define_default([b4_yy_symbol_print_generate],
/*ARGSUSED*/
]$1([yy_symbol_value_print],
[static void],
[[FILE *yyoutput], [yyoutput]],
[[int yytype], [yytype]],
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
[[FILE *yyoutput], [yyoutput]],
[[int yytype], [yytype]],
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
m4_ifset([b4_parse_param], [, b4_parse_param]))[
{
@@ -498,7 +498,7 @@ b4_parse_param_use[]dnl
{
]b4_symbol_foreach([b4_symbol_printer])dnl
[ default:
break;
break;
}
}
@@ -509,9 +509,9 @@ b4_parse_param_use[]dnl
]$1([yy_symbol_print],
[static void],
[[FILE *yyoutput], [yyoutput]],
[[int yytype], [yytype]],
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
[[FILE *yyoutput], [yyoutput]],
[[int yytype], [yytype]],
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
m4_ifset([b4_parse_param], [, b4_parse_param]))[
{

1348
data/glr.c

File diff suppressed because it is too large Load Diff

View File

@@ -77,9 +77,9 @@ m4_define([b4_yy_symbol_print_generate],
[[FILE *], []],
[[int yytype], [yytype]],
[[const b4_namespace_ref::b4_parser_class_name::semantic_type *yyvaluep],
[yyvaluep]],
[yyvaluep]],
[[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp],
[yylocationp]],
[yylocationp]],
b4_parse_param)[
{
]b4_parse_param_use[]dnl
@@ -146,7 +146,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
inline void
]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,
const semantic_type* yyvaluep, const location_type* yylocationp)
const semantic_type* yyvaluep, const location_type* yylocationp)
{
/* Pacify ``unused variable'' warnings. */
YYUSE (yyvaluep);
@@ -155,18 +155,18 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
{
]b4_symbol_foreach([b4_symbol_printer])dnl
[ default:
break;
break;
}
}
void
]b4_parser_class_name[::yy_symbol_print_ (int yytype,
const semantic_type* yyvaluep, const location_type* yylocationp)
const semantic_type* yyvaluep, const location_type* yylocationp)
{
*yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm")
<< ' ' << yytname[yytype] << " ("
<< *yylocationp << ": ";
<< ' ' << yytname[yytype] << " ("
<< *yylocationp << ": ";
yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
*yycdebug_ << ')';
}
@@ -205,10 +205,10 @@ b4_namespace_close[
# Let glr.c believe that the user arguments include the parser itself.
m4_ifset([b4_parse_param],
[m4_pushdef([b4_parse_param],
m4_dquote([[[b4_namespace_ref::b4_parser_class_name& yyparser], [[yyparser]]],]
m4_dquote([[[b4_namespace_ref::b4_parser_class_name& yyparser], [[yyparser]]],]
m4_defn([b4_parse_param])))],
[m4_pushdef([b4_parse_param],
[[[[b4_namespace_ref::b4_parser_class_name& yyparser], [[yyparser]]]]])
[[[[b4_namespace_ref::b4_parser_class_name& yyparser], [[yyparser]]]]])
])
m4_include(b4_pkgdatadir/[glr.c])
m4_popdef([b4_parse_param])
@@ -244,17 +244,17 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
the previous symbol: RHS[0] (always defined). */
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
(Current).end = YYRHSLOC (Rhs, N).end; \
} \
else \
{ \
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
} \
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
(Current).end = YYRHSLOC (Rhs, N).end; \
} \
else \
{ \
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
} \
while (/*CONSTCOND*/ 0)
#endif
@@ -298,15 +298,15 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
/// \param yyvaluep Its semantic value.
/// \param yylocationp Its location.
virtual void yy_symbol_value_print_ (int yytype,
const semantic_type* yyvaluep,
const location_type* yylocationp);
const semantic_type* yyvaluep,
const location_type* yylocationp);
/// \brief Report a symbol on the debug stream.
/// \param yytype The token type.
/// \param yyvaluep Its semantic value.
/// \param yylocationp Its location.
virtual void yy_symbol_print_ (int yytype,
const semantic_type* yyvaluep,
const location_type* yylocationp);
const semantic_type* yyvaluep,
const location_type* yylocationp);
private:
/* Debugging. */
std::ostream* yycdebug_;
@@ -318,9 +318,9 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
/// \param yyvaluep Its semantic value.
/// \param yylocationp Its location.
inline void yydestruct_ (const char* yymsg,
int yytype,
semantic_type* yyvaluep,
location_type* yylocationp);
int yytype,
semantic_type* yyvaluep,
location_type* yylocationp);
]b4_parse_param_vars[
};

View File

@@ -426,14 +426,14 @@ b4_percent_code_get[]dnl
} \
} while (false)
# define YY_REDUCE_PRINT(Rule) \
do { \
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug_) \
yy_reduce_print_ (Rule); \
yy_reduce_print_ (Rule); \
} while (false)
# define YY_STACK_PRINT() \
do { \
# define YY_STACK_PRINT() \
do { \
if (yydebug_) \
yystack_print_ (); \
} while (false)
@@ -575,7 +575,7 @@ b4_percent_code_get[]dnl
{
]b4_symbol_foreach([b4_symbol_printer])dnl
[ default:
break;
break;
}
yyo << ')';
}
@@ -739,7 +739,7 @@ m4_popdef([b4_at_dollar])])dnl
[ yyla = b4_c_function_call([yylex], [symbol_type],
m4_ifdef([b4_lex_param], b4_lex_param));],
[ yyla.type = yytranslate_ (b4_c_function_call([yylex], [int],
[[YYSTYPE*], [&yyla.value]][]dnl
[[YYSTYPE*], [&yyla.value]][]dnl
b4_locations_if([, [[location*], [&yyla.location]]])dnl
m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
yyempty = false;
@@ -756,10 +756,10 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
yyn = yytable_[yyn];
if (yyn <= 0)
{
if (yy_table_value_is_error_ (yyn))
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
if (yy_table_value_is_error_ (yyn))
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
/* Discard the token being shifted. */
@@ -818,7 +818,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
switch (yyn)
{
]b4_user_actions[
default:
default:
break;
}
}
@@ -859,8 +859,8 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
/* If not already recovering from an error, report this error. */
if (!yyerrstatus_)
{
++yynerrs_;
error (]b4_args(b4_locations_if([yyla.location]),
++yynerrs_;
error (]b4_args(b4_locations_if([yyla.location]),
[[yysyntax_error_ (yystack_[0].state,
yyempty ? yyempty_ : yyla.type)]])[);
}
@@ -869,7 +869,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
yyerror_range[1].location = yyla.location;]])[
if (yyerrstatus_ == 3)
{
/* If just tried and failed to reuse lookahead token after an
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
/* Return failure if at end of input. */
@@ -879,7 +879,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
{
yy_destroy_ ("Error: discarding", yyla);
yyempty = true;
}
}
}
/* Else will try to reuse lookahead token after shifting the error
@@ -910,7 +910,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
{
stack_symbol_type error_token;
for (;;)
@@ -965,8 +965,8 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
yypop_ (yylen);
while (yystack_.size () != 1)
{
yy_destroy_ ("Cleanup: popping", yystack_[0]);
yypop_ ();
yy_destroy_ ("Cleanup: popping", yystack_[0]);
yypop_ ();
}
return yyresult;
@@ -1098,7 +1098,7 @@ b4_error_verbose_if([state_type yystate, int yytoken],
for (stack_type::const_iterator
i = yystack_.begin (),
i_end = yystack_.end ();
i != i_end; ++i)
i != i_end; ++i)
*yycdebug_ << ' ' << i->state;
*yycdebug_ << std::endl;
}
@@ -1111,7 +1111,7 @@ b4_error_verbose_if([state_type yystate, int yytoken],
int yynrhs = yyr2_[yyrule];
/* Print the symbols being reduced, and their result. */
*yycdebug_ << "Reducing stack by rule " << yyrule - 1
<< " (line " << yylno << "):" << std::endl;
<< " (line " << yylno << "):" << std::endl;
/* The symbols being reduced. */
for (int yyi = 0; yyi < yynrhs; yyi++)
YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",

View File

@@ -13,32 +13,32 @@
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
dist_pkgdata_DATA = \
data/README \
data/bison.m4 \
data/c++-skel.m4 \
data/c++.m4 \
data/c-skel.m4 \
data/c.m4 \
data/glr.c \
data/glr.cc \
data/java-skel.m4 \
data/java.m4 \
data/lalr1.cc \
data/lalr1.java \
data/location.cc \
data/stack.hh \
data/variant.hh \
dist_pkgdata_DATA = \
data/README \
data/bison.m4 \
data/c++-skel.m4 \
data/c++.m4 \
data/c-skel.m4 \
data/c.m4 \
data/glr.c \
data/glr.cc \
data/java-skel.m4 \
data/java.m4 \
data/lalr1.cc \
data/lalr1.java \
data/location.cc \
data/stack.hh \
data/variant.hh \
data/yacc.c
m4sugardir = $(pkgdatadir)/m4sugar
dist_m4sugar_DATA = \
data/m4sugar/foreach.m4 \
dist_m4sugar_DATA = \
data/m4sugar/foreach.m4 \
data/m4sugar/m4sugar.m4
xsltdir = $(pkgdatadir)/xslt
dist_xslt_DATA = \
data/xslt/bison.xsl \
data/xslt/xml2dot.xsl \
data/xslt/xml2text.xsl \
dist_xslt_DATA = \
data/xslt/bison.xsl \
data/xslt/xml2dot.xsl \
data/xslt/xml2text.xsl \
data/xslt/xml2xhtml.xsl

View File

@@ -279,8 +279,8 @@ b4_copyright([Locations for Bison parsers in C++])[
position last = loc.end - 1;
ostr << loc.begin;
if (last.filename
&& (!loc.begin.filename
|| *loc.begin.filename != *last.filename))
&& (!loc.begin.filename
|| *loc.begin.filename != *last.filename))
ostr << '-' << last;
else if (loc.begin.line != last.line)
ostr << '-' << last.line << '.' << last.column;

View File

@@ -74,7 +74,7 @@ b4_copyright([Stack handling for Bison parsers in C++])[
pop (unsigned int n = 1)
{
for (; n; --n)
seq_.pop_front ();
seq_.pop_front ();
}
inline

View File

@@ -124,20 +124,20 @@
<xsl:with-param name="dst" select="@state"/>
<xsl:with-param name="style">
<xsl:choose>
<xsl:when test="@symbol = 'error'">
<xsl:text>dotted</xsl:text>
</xsl:when>
<xsl:when test="@type = 'shift'">
<xsl:text>solid</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>dashed</xsl:text>
</xsl:otherwise>
<xsl:when test="@symbol = 'error'">
<xsl:text>dotted</xsl:text>
</xsl:when>
<xsl:when test="@type = 'shift'">
<xsl:text>solid</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>dashed</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="label">
<xsl:if test="not(@symbol = 'error')">
<xsl:value-of select="@symbol"/>
<xsl:value-of select="@symbol"/>
</xsl:if>
</xsl:with-param>
</xsl:call-template>

View File

@@ -253,9 +253,9 @@
<xsl:text>&#10;</xsl:text>
<xsl:apply-templates select="transition[@type = $type]">
<xsl:with-param name="pad">
<xsl:call-template name="max-width-symbol">
<xsl:with-param name="node" select="transition[@type = $type]"/>
</xsl:call-template>
<xsl:call-template name="max-width-symbol">
<xsl:with-param name="node" select="transition[@type = $type]"/>
</xsl:call-template>
</xsl:with-param>
</xsl:apply-templates>
</xsl:if>
@@ -266,9 +266,9 @@
<xsl:text>&#10;</xsl:text>
<xsl:apply-templates select="error">
<xsl:with-param name="pad">
<xsl:call-template name="max-width-symbol">
<xsl:with-param name="node" select="error"/>
</xsl:call-template>
<xsl:call-template name="max-width-symbol">
<xsl:with-param name="node" select="error"/>
</xsl:call-template>
</xsl:with-param>
</xsl:apply-templates>
</xsl:if>
@@ -279,9 +279,9 @@
<xsl:text>&#10;</xsl:text>
<xsl:apply-templates select="reduction">
<xsl:with-param name="pad">
<xsl:call-template name="max-width-symbol">
<xsl:with-param name="node" select="reduction"/>
</xsl:call-template>
<xsl:call-template name="max-width-symbol">
<xsl:with-param name="node" select="reduction"/>
</xsl:call-template>
</xsl:with-param>
</xsl:apply-templates>
</xsl:if>
@@ -290,7 +290,7 @@
<xsl:template match="item">
<xsl:param name="pad"/>
<xsl:param name="prev-rule-number"
select="preceding-sibling::item[1]/@rule-number"/>
select="preceding-sibling::item[1]/@rule-number"/>
<xsl:apply-templates
select="key('bison:ruleByNumber', current()/@rule-number)"
>
@@ -329,14 +329,14 @@
<xsl:choose>
<xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
<xsl:call-template name="lpad">
<xsl:with-param name="str" select="'|'"/>
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
<xsl:with-param name="str" select="'|'"/>
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
<xsl:call-template name="lpad">
<xsl:with-param name="str" select="'|'"/>
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
<xsl:with-param name="str" select="'|'"/>
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
@@ -442,7 +442,7 @@
<xsl:value-of select="@rule"/>
<xsl:text> (</xsl:text>
<xsl:value-of
select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"/>
select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"/>
<xsl:text>)</xsl:text>
</xsl:otherwise>
</xsl:choose>
@@ -479,9 +479,9 @@
<xsl:variable name="longest">
<xsl:for-each select="$node">
<xsl:sort data-type="number" select="string-length(@symbol)"
order="descending"/>
order="descending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="string-length(@symbol)"/>
<xsl:value-of select="string-length(@symbol)"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
@@ -498,7 +498,7 @@
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="space">
<xsl:with-param name="repeat" select="$diff"/>
<xsl:with-param name="repeat" select="$diff"/>
</xsl:call-template>
<xsl:value-of select="$str"/>
</xsl:otherwise>
@@ -516,7 +516,7 @@
<xsl:otherwise>
<xsl:value-of select="$str"/>
<xsl:call-template name="space">
<xsl:with-param name="repeat" select="$diff"/>
<xsl:with-param name="repeat" select="$diff"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>

View File

@@ -31,32 +31,32 @@
<xsl:import href="bison.xsl"/>
<xsl:output method="xml" encoding="UTF-8"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
indent="yes"/>
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
indent="yes"/>
<xsl:template match="/">
<html>
<head>
<title>
<xsl:value-of select="bison-xml-report/filename"/>
<xsl:text> - GNU Bison XML Automaton Report</xsl:text>
<xsl:value-of select="bison-xml-report/filename"/>
<xsl:text> - GNU Bison XML Automaton Report</xsl:text>
</title>
<style type="text/css"><![CDATA[
body {
font-family: "Nimbus Sans L", Arial, sans-serif;
font-size: 9pt;
font-size: 9pt;
}
a:link {
color: #1f00ff;
text-decoration: none;
color: #1f00ff;
text-decoration: none;
}
a:visited {
color: #1f00ff;
text-decoration: none;
color: #1f00ff;
text-decoration: none;
}
a:hover {
color: red;
color: red;
}
#menu a {
text-decoration: underline;
@@ -109,21 +109,21 @@
<li>
<a href="#reductions">Reductions</a>
<ul class="lower-alpha">
<li><a href="#nonterminals_useless_in_grammar">Nonterminals useless in grammar</a></li>
<li><a href="#terminals_unused_in_grammar">Terminals unused in grammar</a></li>
<li><a href="#rules_useless_in_grammar">Rules useless in grammar</a></li>
<xsl:if test="grammar/rules/rule[@usefulness='useless-in-parser']">
<li><a href="#rules_useless_in_parser">Rules useless in parser due to conflicts</a></li>
</xsl:if>
<li><a href="#nonterminals_useless_in_grammar">Nonterminals useless in grammar</a></li>
<li><a href="#terminals_unused_in_grammar">Terminals unused in grammar</a></li>
<li><a href="#rules_useless_in_grammar">Rules useless in grammar</a></li>
<xsl:if test="grammar/rules/rule[@usefulness='useless-in-parser']">
<li><a href="#rules_useless_in_parser">Rules useless in parser due to conflicts</a></li>
</xsl:if>
</ul>
</li>
<li><a href="#conflicts">Conflicts</a></li>
<li>
<a href="#grammar">Grammar</a>
<ul class="lower-alpha">
<li><a href="#grammar">Itemset</a></li>
<li><a href="#terminals">Terminal symbols</a></li>
<li><a href="#nonterminals">Nonterminal symbols</a></li>
<li><a href="#grammar">Itemset</a></li>
<li><a href="#terminals">Terminal symbols</a></li>
<li><a href="#nonterminals">Nonterminal symbols</a></li>
</ul>
</li>
<li><a href="#automaton">Automaton</a></li>
@@ -154,9 +154,9 @@
<xsl:if test="nonterminal[@usefulness='useless-in-grammar']">
<p class="pre">
<xsl:for-each select="nonterminal[@usefulness='useless-in-grammar']">
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>&#10;</xsl:text>
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>&#10;</xsl:text>
</xsl:for-each>
<xsl:text>&#10;&#10;</xsl:text>
</p>
@@ -173,9 +173,9 @@
<p class="pre">
<xsl:for-each select="terminal[@usefulness='unused-in-grammar']">
<xsl:sort select="@symbol-number" data-type="number"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>&#10;</xsl:text>
<xsl:text> </xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>&#10;</xsl:text>
</xsl:for-each>
<xsl:text>&#10;&#10;</xsl:text>
</p>
@@ -381,7 +381,7 @@
<h3>
<a>
<xsl:attribute name="name">
<xsl:value-of select="concat('state_', @number)"/>
<xsl:value-of select="concat('state_', @number)"/>
</xsl:attribute>
</a>
<xsl:text>state </xsl:text>
@@ -410,9 +410,9 @@
<xsl:text>&#10;</xsl:text>
<xsl:apply-templates select="transition[@type = $type]">
<xsl:with-param name="pad">
<xsl:call-template name="max-width-symbol">
<xsl:with-param name="node" select="transition[@type = $type]"/>
</xsl:call-template>
<xsl:call-template name="max-width-symbol">
<xsl:with-param name="node" select="transition[@type = $type]"/>
</xsl:call-template>
</xsl:with-param>
</xsl:apply-templates>
</xsl:if>
@@ -423,9 +423,9 @@
<xsl:text>&#10;</xsl:text>
<xsl:apply-templates select="error">
<xsl:with-param name="pad">
<xsl:call-template name="max-width-symbol">
<xsl:with-param name="node" select="error"/>
</xsl:call-template>
<xsl:call-template name="max-width-symbol">
<xsl:with-param name="node" select="error"/>
</xsl:call-template>
</xsl:with-param>
</xsl:apply-templates>
</xsl:if>
@@ -436,9 +436,9 @@
<xsl:text>&#10;</xsl:text>
<xsl:apply-templates select="reduction">
<xsl:with-param name="pad">
<xsl:call-template name="max-width-symbol">
<xsl:with-param name="node" select="reduction"/>
</xsl:call-template>
<xsl:call-template name="max-width-symbol">
<xsl:with-param name="node" select="reduction"/>
</xsl:call-template>
</xsl:with-param>
</xsl:apply-templates>
</xsl:if>
@@ -447,7 +447,7 @@
<xsl:template match="item">
<xsl:param name="pad"/>
<xsl:param name="prev-rule-number"
select="preceding-sibling::item[1]/@rule-number"/>
select="preceding-sibling::item[1]/@rule-number"/>
<xsl:apply-templates
select="key('bison:ruleByNumber', current()/@rule-number)"
>
@@ -477,7 +477,7 @@
<xsl:if test="$itemset != 'true'">
<a>
<xsl:attribute name="name">
<xsl:value-of select="concat('rule_', @number)"/>
<xsl:value-of select="concat('rule_', @number)"/>
</xsl:attribute>
</a>
</xsl:if>
@@ -486,19 +486,19 @@
<xsl:choose>
<xsl:when test="$itemset = 'true'">
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('#rule_', @number)"/>
</xsl:attribute>
<xsl:call-template name="lpad">
<xsl:with-param name="str" select="string(@number)"/>
<xsl:with-param name="pad" select="number($pad)"/>
</xsl:call-template>
<xsl:attribute name="href">
<xsl:value-of select="concat('#rule_', @number)"/>
</xsl:attribute>
<xsl:call-template name="lpad">
<xsl:with-param name="str" select="string(@number)"/>
<xsl:with-param name="pad" select="number($pad)"/>
</xsl:call-template>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="lpad">
<xsl:with-param name="str" select="string(@number)"/>
<xsl:with-param name="pad" select="number($pad)"/>
<xsl:with-param name="str" select="string(@number)"/>
<xsl:with-param name="pad" select="number($pad)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
@@ -508,19 +508,19 @@
<xsl:choose>
<xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
<xsl:call-template name="lpad">
<xsl:with-param name="str" select="'|'"/>
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
<xsl:with-param name="str" select="'|'"/>
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
<xsl:call-template name="lpad">
<xsl:with-param name="str" select="'|'"/>
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
<xsl:with-param name="str" select="'|'"/>
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<span class="i">
<xsl:value-of select="lhs"/>
<xsl:value-of select="lhs"/>
</span>
<xsl:text> &#8594;</xsl:text>
</xsl:otherwise>
@@ -589,18 +589,18 @@
<xsl:choose>
<xsl:when test="@type = 'shift'">
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('#state_', @state)"/>
</xsl:attribute>
<xsl:value-of select="concat('shift, and go to state ', @state)"/>
<xsl:attribute name="href">
<xsl:value-of select="concat('#state_', @state)"/>
</xsl:attribute>
<xsl:value-of select="concat('shift, and go to state ', @state)"/>
</a>
</xsl:when>
<xsl:when test="@type = 'goto'">
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('#state_', @state)"/>
</xsl:attribute>
<xsl:value-of select="concat('go to state ', @state)"/>
<xsl:attribute name="href">
<xsl:value-of select="concat('#state_', @state)"/>
</xsl:attribute>
<xsl:value-of select="concat('go to state ', @state)"/>
</a>
</xsl:when>
</xsl:choose>
@@ -637,10 +637,10 @@
</xsl:when>
<xsl:otherwise>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('#rule_', @rule)"/>
</xsl:attribute>
<xsl:value-of select="concat('reduce using rule ', @rule)"/>
<xsl:attribute name="href">
<xsl:value-of select="concat('#rule_', @rule)"/>
</xsl:attribute>
<xsl:value-of select="concat('reduce using rule ', @rule)"/>
</a>
<xsl:text> (</xsl:text>
<xsl:value-of
@@ -687,9 +687,9 @@
<xsl:variable name="longest">
<xsl:for-each select="$node">
<xsl:sort data-type="number" select="string-length(@symbol)"
order="descending"/>
order="descending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="string-length(@symbol)"/>
<xsl:value-of select="string-length(@symbol)"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
@@ -706,7 +706,7 @@
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="space">
<xsl:with-param name="repeat" select="$diff"/>
<xsl:with-param name="repeat" select="$diff"/>
</xsl:call-template>
<xsl:value-of select="$str"/>
</xsl:otherwise>
@@ -724,7 +724,7 @@
<xsl:otherwise>
<xsl:value-of select="$str"/>
<xsl:call-template name="space">
<xsl:with-param name="repeat" select="$diff"/>
<xsl:with-param name="repeat" select="$diff"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>

View File

@@ -76,8 +76,8 @@ m4_define([b4_pure_flag],
# Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise.
m4_define([b4_yacc_pure_if],
[b4_pure_if([m4_ifset([b4_parse_param],
[$1], [$2])],
[$2])])
[$1], [$2])],
[$2])])
# b4_yyerror_args
@@ -117,7 +117,7 @@ m4_define([b4_int_type],
m4_eval([0 <= $1]), [1], [unsigned int],
[int])])
[int])])
## ----------------- ##
@@ -464,7 +464,7 @@ b4_push_if([], [b4_lac_if([], [[
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
&& (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
@@ -489,8 +489,8 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
&& ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|| (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
&& ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
@@ -520,15 +520,15 @@ union yyalloc
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (YYID (0))
#endif
@@ -541,13 +541,13 @@ union yyalloc
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
# define YYCOPY(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
while (YYID (0))
# endif
# endif
@@ -572,7 +572,7 @@ union yyalloc
#define YYUNDEFTOK ]b4_undef_token_number[
#define YYMAXUTOK ]b4_user_token_number_max[
#define YYTRANSLATE(YYX) \
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
@@ -617,14 +617,14 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
]b4_parser_tables_define[
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2)
#define YYEOF 0
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2)
#define YYEOF 0
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
/* Like YYERROR except do call yyerror. This remains here temporarily
@@ -634,7 +634,7 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
discussed. */
#define YYFAIL goto yyerrlab
#define YYFAIL goto yyerrlab
#if defined YYFAIL
/* This is here to suppress warnings from the GCC cpp's
-Wunused-macros. Normally we don't worry about that warning, but
@@ -644,26 +644,26 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (1); \]b4_lac_if([[
YY_LAC_DISCARD ("YYBACKUP"); \]])[
goto yybackup; \
} \
else \
{ \
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (1); \]b4_lac_if([[
YY_LAC_DISCARD ("YYBACKUP"); \]])[
goto yybackup; \
} \
else \
{ \
yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
YYERROR; \
} \
YYERROR; \
} \
while (YYID (0))
#define YYTERROR 1
#define YYERRCODE 256
#define YYTERROR 1
#define YYERRCODE 256
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
@@ -672,22 +672,22 @@ while (YYID (0))
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (YYID (N)) \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
while (YYID (0))
#endif]b4_locations_if([[
@@ -698,10 +698,10 @@ while (YYID (0))
#ifndef YY_LOCATION_PRINT
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
(Loc).last_line, (Loc).last_column)
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
(Loc).last_line, (Loc).last_column)
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
@@ -731,21 +731,21 @@ while (YYID (0))
# define YYFPRINTF fprintf
# endif
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
} while (YYID (0))
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \
Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
YYFPRINTF (stderr, "\n"); \
} \
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \
Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
YYFPRINTF (stderr, "\n"); \
} \
} while (YYID (0))
]b4_yy_symbol_print_generate([b4_c_function_def])[
@@ -756,8 +756,8 @@ do { \
`------------------------------------------------------------------*/
]b4_c_function_def([yy_stack_print], [static void],
[[yytype_int16 *yybottom], [yybottom]],
[[yytype_int16 *yytop], [yytop]])[
[[yytype_int16 *yybottom], [yybottom]],
[[yytype_int16 *yytop], [yytop]])[
{
YYFPRINTF (stderr, "Stack now");
for (; yybottom <= yytop; yybottom++)
@@ -768,10 +768,10 @@ do { \
YYFPRINTF (stderr, "\n");
}
# define YY_STACK_PRINT(Bottom, Top) \
do { \
if (yydebug) \
yy_stack_print ((Bottom), (Top)); \
# define YY_STACK_PRINT(Bottom, Top) \
do { \
if (yydebug) \
yy_stack_print ((Bottom), (Top)); \
} while (YYID (0))
@@ -804,9 +804,9 @@ do { \
}
}
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug) \
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug) \
yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
} while (YYID (0))
@@ -822,7 +822,7 @@ int yydebug;
/* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH
#ifndef YYINITDEPTH
# define YYINITDEPTH ]b4_stack_depth_init[
#endif
@@ -1129,27 +1129,27 @@ yytnamerr (char *yyres, const char *yystr)
char const *yyp = yystr;
for (;;)
switch (*++yyp)
{
case '\'':
case ',':
goto do_not_strip_quotes;
switch (*++yyp)
{
case '\'':
case ',':
goto do_not_strip_quotes;
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
/* Fall through. */
default:
if (yyres)
yyres[yyn] = *yyp;
yyn++;
break;
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
/* Fall through. */
default:
if (yyres)
yyres[yyn] = *yyp;
yyn++;
break;
case '"':
if (yyres)
yyres[yyn] = '\0';
return yyn;
}
case '"':
if (yyres)
yyres[yyn] = '\0';
return yyn;
}
do_not_strip_quotes: ;
}
@@ -1552,26 +1552,26 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
#ifdef yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;]b4_locations_if([
YYLTYPE *yyls1 = yyls;])[
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;]b4_locations_if([
YYLTYPE *yyls1 = yyls;])[
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
&yyls1, yysize * sizeof (*yylsp),])[
&yystacksize);
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
&yyls1, yysize * sizeof (*yylsp),])[
&yystacksize);
]b4_locations_if([
yyls = yyls1;])[
yyss = yyss1;
yyvs = yyvs1;
yyls = yyls1;])[
yyss = yyss1;
yyvs = yyvs1;
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
@@ -1579,23 +1579,23 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
yystacksize = YYMAXDEPTH;
{
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
YYSTACK_RELOCATE (yyls_alloc, yyls);])[
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
YYSTACK_RELOCATE (yyls_alloc, yyls);])[
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
#endif /* no yyoverflow */
@@ -1605,10 +1605,10 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
yylsp = yyls + yysize - 1;])[
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
(unsigned long int) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
@@ -1844,20 +1844,20 @@ yyerrlab:
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
error, discard it. */
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
yychar = YYEMPTY;
}
{
yydestruct ("Error: discarding",
yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
yychar = YYEMPTY;
}
}
/* Else will try to reuse lookahead token after shifting the error
@@ -1890,29 +1890,29 @@ yyerrorlab:
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
YYABORT;
YYABORT;
]b4_locations_if([[ yyerror_range[1] = *yylsp;]])[
yydestruct ("Error: popping",
yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
@@ -1977,7 +1977,7 @@ yyreturn:
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
yystos[*yyssp], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
YYPOPSTACK (1);
}
#ifndef yyoverflow

View File

@@ -1,4 +1,4 @@
# Doxyfile 1.3.4 -*- Makefile -*-
# Doxyfile 1.3.4 -*- Makefile -*-
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project
@@ -362,7 +362,7 @@ WARN_LOGFILE =
# with spaces.
INPUT = @top_srcdir@/src \
@top_builddir@/src
@top_builddir@/src
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
@@ -373,8 +373,8 @@ INPUT = @top_srcdir@/src \
FILE_PATTERNS = *.c \
*.h \
*.l \
*.y
*.l \
*.y
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
@@ -387,8 +387,8 @@ RECURSIVE = YES
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE = @top_srcdir@/src/scan-gram.c \
@top_srcdir@/src/scan-skel.c \
@top_builddir@/src/parse-*.[ch]
@top_srcdir@/src/scan-skel.c \
@top_builddir@/src/parse-*.[ch]
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
# directories that are symbolic links (a Unix filesystem feature) are

View File

@@ -15,9 +15,9 @@
AM_MAKEINFOFLAGS = --no-split
info_TEXINFOS = doc/bison.texinfo
doc_bison_TEXINFOS = \
$(CROSS_OPTIONS_TEXI) \
doc/fdl.texi \
doc_bison_TEXINFOS = \
$(CROSS_OPTIONS_TEXI) \
doc/fdl.texi \
doc/gpl-3.0.texi
CLEANFILES = doc/bison.fns
@@ -35,7 +35,7 @@ $(CROSS_OPTIONS_TEXI): doc/bison.help $(CROSS_OPTIONS_PL)
# diff in the next run. Note that $@ might not exist yet.
{ test ! -f $@ || cat $@; } >$@~
test ! -f $@.tmp || rm -f $@.tmp
src/bison$(EXEEXT) --help | \
src/bison$(EXEEXT) --help | \
perl $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
diff -u $@~ $@.tmp || true
mv $@.tmp $@
@@ -101,14 +101,14 @@ remove_time_stamp = \
# Depend on configure to get version number changes.
$(top_srcdir)/doc/bison.1: doc/bison.help doc/bison.x $(top_srcdir)/configure
@echo "Updating man page $@"
$(HELP2MAN) \
--include=$(top_srcdir)/doc/bison.x \
$(HELP2MAN) \
--include=$(top_srcdir)/doc/bison.x \
--output=$@.t src/bison$(EXEEXT)
if $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \
if $(remove_time_stamp) $@ >$@a.t 2>/dev/null && \
$(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \
touch $@; \
else \
mv $@.t $@; \
touch $@; \
else \
mv $@.t $@; \
fi
rm -f $@*.t

View File

@@ -284,8 +284,8 @@ for my $size (1 .. $max)
{
use Text::Wrap;
print $out wrap ("| ", " ",
(map { "\"$_\"" } (1 .. $size)),
" END \n"),
(map { "\"$_\"" } (1 .. $size)),
" END \n"),
" { \$\$ = $size; }\n";
};
print $out ";\n";
@@ -411,7 +411,7 @@ static int yylex (void);
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%left NEG /* negation--unary minus */
@@ -640,13 +640,13 @@ EOF
%%
result:
text { /* Throw away the result. */ }
text { /* Throw away the result. */ }
;
text:
/* nothing */ { /* This will generate an empty string */ }
| text TEXT { std::swap ($$, $2); }
| text NUMBER { $$ = string_cast($2); }
/* nothing */ { /* This will generate an empty string */ }
| text TEXT { std::swap ($$, $2); }
| text NUMBER { $$ = string_cast($2); }
;
EOF
}
@@ -663,13 +663,13 @@ EOF
%%
result:
text { delete $1; }
text { delete $1; }
;
text:
/* nothing */ { $$ = new std::string; }
| text TEXT { delete $1; $$ = $2; }
| text NUMBER { delete $1; $$ = new std::string (string_cast ($2)); }
/* nothing */ { $$ = new std::string; }
| text TEXT { delete $1; $$ = $2; }
| text NUMBER { delete $1; $$ = new std::string (string_cast ($2)); }
;
EOF
}

View File

@@ -10,7 +10,7 @@ my $prefix = "lib/";
sub contents ($)
{
my ($file) = @_;
local $/; # Turn on slurp-mode.
local $/; # Turn on slurp-mode.
my $f = new IO::File "< $file" or die "$file";
my $contents = $f->getline or die "$file";
$f->close;

View File

@@ -55,9 +55,9 @@ MAINTAINERCLEANFILES = $(srcdir)/*.stamp $(BUILT_SOURCES)
# Compile the parser and save cycles.
# This code comes from "Handling Tools that Produce Many Outputs",
# from the Automake documentation.
EXTRA_DIST = \
$(srcdir)/calc++-parser.stamp \
$(srcdir)/calc++-parser.yy \
EXTRA_DIST = \
$(srcdir)/calc++-parser.stamp \
$(srcdir)/calc++-parser.yy \
$(srcdir)/calc.stamp
# Don't depend on $(BISON) otherwise we would rebuild these files
# in srcdir, including during distcheck, which is forbidden.

View File

@@ -65,23 +65,23 @@ BEGIN {
# => + 2.
# Note that recent Bison support it, but not Flex.
if (file ~ /\.[chy]*$/)
input = "#line " (FNR + 1) " \"" FILENAME "\"\n";
input = "#line " (FNR + 1) " \"" FILENAME "\"\n";
next;
}
if ($0 ~ /^@end example$/)
{
if (input == "")
fatal("no contents: " file);
fatal("no contents: " file);
input = normalize(input);
# No spurious end of line: use printf.
if (files_output[file])
# The parens around the output file seem to be required
# The parens around the output file seem to be required
# by awk on Mac OS X Tiger (darwin 8.4.6).
printf ("%s", input) >> (output_dir "/" file);
else
printf ("%s", input) > (output_dir "/" file);
printf ("%s", input) > (output_dir "/" file);
close (output_dir "/" file);
files_output[file] = 1;
@@ -105,11 +105,11 @@ function normalize(contents, i, lines, n, line, res) {
# Whole line commands.
if (line ~ /^@(c |comment|dots|end (ignore|group)|ignore|group)/)
# Gperf accepts empty lines as valid input!!!
if (file ~ /\.gperf$/)
continue;
else
line = "";
# Gperf accepts empty lines as valid input!!!
if (file ~ /\.gperf$/)
continue;
else
line = "";
gsub (/"@value\{VERSION\}"/, "\"" VERSION "\"", line)
gsub (/^@result\{\}/, "", line);

View File

@@ -47,7 +47,7 @@ abitset_resize (bitset src, bitset_bindex size)
found and with *NEXT indicating where search stopped. */
static bitset_bindex
abitset_small_list (bitset src, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_bindex count;
@@ -73,27 +73,27 @@ abitset_small_list (bitset src, bitset_bindex *list,
if (num >= BITSET_WORD_BITS)
{
for (count = 0; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
else
{
for (count = 0; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
bitno++;
break;
}
}
word >>= 1;
}
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
bitno++;
break;
}
}
word >>= 1;
}
}
*next = bitno;
@@ -115,7 +115,7 @@ abitset_set (bitset dst ATTRIBUTE_UNUSED, bitset_bindex bitno ATTRIBUTE_UNUSED)
/* Reset bit BITNO in bitset DST. */
static void
abitset_reset (bitset dst ATTRIBUTE_UNUSED,
bitset_bindex bitno ATTRIBUTE_UNUSED)
bitset_bindex bitno ATTRIBUTE_UNUSED)
{
/* This should never occur for abitsets since we should always hit
the cache. It is likely someone is trying to access outside the
@@ -126,7 +126,7 @@ abitset_reset (bitset dst ATTRIBUTE_UNUSED,
/* Test bit BITNO in bitset SRC. */
static bool
abitset_test (bitset src ATTRIBUTE_UNUSED,
bitset_bindex bitno ATTRIBUTE_UNUSED)
bitset_bindex bitno ATTRIBUTE_UNUSED)
{
/* This should never occur for abitsets since we should always
hit the cache. */
@@ -140,7 +140,7 @@ abitset_test (bitset src ATTRIBUTE_UNUSED,
stopped. */
static bitset_bindex
abitset_list_reverse (bitset src, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_bindex rbitno;
@@ -173,18 +173,18 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
for (; word; bitcnt--)
{
if (word & BITSET_MSB)
{
list[count++] = bitoff + bitcnt;
if (count >= num)
{
*next = n_bits - (bitoff + bitcnt);
return count;
}
}
word <<= 1;
}
{
if (word & BITSET_MSB)
{
list[count++] = bitoff + bitcnt;
if (count >= num)
{
*next = n_bits - (bitoff + bitcnt);
return count;
}
}
word <<= 1;
}
bitoff -= BITSET_WORD_BITS;
bitcnt = BITSET_WORD_BITS - 1;
}
@@ -200,7 +200,7 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
found and with *NEXT indicating where search stopped. */
static bitset_bindex
abitset_list (bitset src, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_bindex count;
@@ -217,80 +217,80 @@ abitset_list (bitset src, bitset_bindex *list,
{
/* Many bitsets are zero, so make this common case fast. */
for (windex = 0; windex < size && !srcp[windex]; windex++)
continue;
continue;
if (windex >= size)
return 0;
return 0;
/* If num is 1, we could speed things up with a binary search
of the current word. */
of the current word. */
bitoff = windex * BITSET_WORD_BITS;
}
else
{
if (bitno >= BITSET_SIZE_ (src))
return 0;
return 0;
windex = bitno / BITSET_WORD_BITS;
bitno = bitno % BITSET_WORD_BITS;
if (bitno)
{
/* Handle the case where we start within a word.
Most often, this is executed with large bitsets
with many set bits where we filled the array
on the previous call to this function. */
{
/* Handle the case where we start within a word.
Most often, this is executed with large bitsets
with many set bits where we filled the array
on the previous call to this function. */
bitoff = windex * BITSET_WORD_BITS;
word = srcp[windex] >> bitno;
for (bitno = bitoff + bitno; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
windex++;
}
bitoff = windex * BITSET_WORD_BITS;
word = srcp[windex] >> bitno;
for (bitno = bitoff + bitno; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
windex++;
}
bitoff = windex * BITSET_WORD_BITS;
}
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
{
if (!(word = srcp[windex]))
continue;
continue;
if ((count + BITSET_WORD_BITS) < num)
{
for (bitno = bitoff; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
{
for (bitno = bitoff; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
else
{
for (bitno = bitoff; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
}
{
for (bitno = bitoff; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
}
}
*next = bitoff;
@@ -387,7 +387,7 @@ abitset_equal_p (bitset dst, bitset src)
for (i = 0; i < size; i++)
if (*srcp++ != *dstp++)
return false;
return false;
return true;
}
@@ -402,7 +402,7 @@ abitset_subset_p (bitset dst, bitset src)
for (i = 0; i < size; i++, dstp++, srcp++)
if (*dstp != (*srcp | *dstp))
return false;
return false;
return true;
}
@@ -417,7 +417,7 @@ abitset_disjoint_p (bitset dst, bitset src)
for (i = 0; i < size; i++)
if (*srcp++ & *dstp++)
return false;
return false;
return true;
}
@@ -452,10 +452,10 @@ abitset_and_cmp (bitset dst, bitset src1, bitset src2)
bitset_word tmp = *src1p++ & *src2p++;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
{
changed = true;
*dstp = tmp;
}
}
return changed;
}
@@ -490,10 +490,10 @@ abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
bitset_word tmp = *src1p++ & ~(*src2p++);
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
{
changed = true;
*dstp = tmp;
}
}
return changed;
}
@@ -528,10 +528,10 @@ abitset_or_cmp (bitset dst, bitset src1, bitset src2)
bitset_word tmp = *src1p++ | *src2p++;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
{
changed = true;
*dstp = tmp;
}
}
return changed;
}
@@ -566,10 +566,10 @@ abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
bitset_word tmp = *src1p++ ^ *src2p++;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
{
changed = true;
*dstp = tmp;
}
}
return changed;
}
@@ -606,10 +606,10 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
{
changed = true;
*dstp = tmp;
}
}
return changed;
}
@@ -646,10 +646,10 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
{
changed = true;
*dstp = tmp;
}
}
return changed;
}
@@ -686,10 +686,10 @@ abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
{
changed = true;
*dstp = tmp;
}
}
return changed;
}

View File

@@ -32,9 +32,9 @@
Memory for bit array and bitset structure allocated
contiguously.
BITSET_LIST: Linked list of arrays of bits (variable size, least storage
for large very sparse sets).
for large very sparse sets).
BITSET_TABLE: Expandable table of pointers to arrays of bits
(variable size, less storage for large sparse sets).
(variable size, less storage for large sparse sets).
Faster than BITSET_LIST for random access.
BITSET_VARRAY: Variable array of bits (variable size, fast for
dense bitsets).
@@ -42,7 +42,7 @@
statistics and/or better run-time checking.
*/
enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_VARRAY,
BITSET_TYPE_NUM, BITSET_STATS};
BITSET_TYPE_NUM, BITSET_STATS};
#define BITSET_TYPE_NAMES {"abitset", "lbitset", "ebitset", "vbitset"}
extern const char * const bitset_type_names[];
@@ -78,19 +78,19 @@ typedef size_t bitset_windex;
#define BITSET_LIST_SIZE 1024
enum bitset_ops {BITSET_OP_ZERO, BITSET_OP_ONES,
BITSET_OP_COPY, BITSET_OP_NOT,
BITSET_OP_EMPTY_P, BITSET_OP_EQUAL_P,
BITSET_OP_SUBSET_P, BITSET_OP_DISJOINT_P,
BITSET_OP_AND, BITSET_OP_OR, BITSET_OP_XOR, BITSET_OP_ANDN,
BITSET_OP_OR_AND, BITSET_OP_AND_OR, BITSET_OP_ANDN_OR};
BITSET_OP_COPY, BITSET_OP_NOT,
BITSET_OP_EMPTY_P, BITSET_OP_EQUAL_P,
BITSET_OP_SUBSET_P, BITSET_OP_DISJOINT_P,
BITSET_OP_AND, BITSET_OP_OR, BITSET_OP_XOR, BITSET_OP_ANDN,
BITSET_OP_OR_AND, BITSET_OP_AND_OR, BITSET_OP_ANDN_OR};
struct bbitset_struct
{
const struct bitset_vtable *vtable;
bitset_windex cindex; /* Cache word index. */
bitset_windex csize; /* Cache size in words. */
bitset_word *cdata; /* Cache data pointer. */
bitset_bindex n_bits; /* Number of bits. */
bitset_windex cindex; /* Cache word index. */
bitset_windex csize; /* Cache size in words. */
bitset_word *cdata; /* Cache data pointer. */
bitset_bindex n_bits; /* Number of bits. */
/* Perhaps we could sacrifice another word to indicate
that the bitset is known to be zero, that a bit has been set
in the cache, and that a bit has been cleared in the cache.
@@ -148,9 +148,9 @@ struct bitset_vtable
bool (*or_and_cmp) (bitset, bitset, bitset, bitset);
bitset_bindex (*list) (bitset, bitset_bindex *, bitset_bindex,
bitset_bindex *);
bitset_bindex *);
bitset_bindex (*list_reverse) (bitset, bitset_bindex *, bitset_bindex,
bitset_bindex *);
bitset_bindex *);
void (*free) (bitset);
enum bitset_type type;
};

View File

@@ -151,7 +151,7 @@ bitset_alloc (bitset_bindex n_bits, enum bitset_type type)
/* Create a bitset of N_BITS of type TYPE. */
bitset
bitset_obstack_alloc (struct obstack *bobstack,
bitset_bindex n_bits, enum bitset_type type)
bitset_bindex n_bits, enum bitset_type type)
{
size_t bytes;
bitset bset;
@@ -296,15 +296,15 @@ bitset_print (FILE *file, bitset bset, bool verbose)
if (verbose)
fprintf (file, "n_bits = %lu, set = {",
(unsigned long int) bitset_size (bset));
(unsigned long int) bitset_size (bset));
pos = 30;
BITSET_FOR_EACH (iter, bset, i, 0)
{
if (pos > 70)
{
fprintf (file, "\n");
pos = 0;
fprintf (file, "\n");
pos = 0;
}
fprintf (file, "%lu ", (unsigned long int) i);
@@ -407,7 +407,7 @@ bitset_copy_ (bitset dst, bitset src)
four operand operations. */
static inline bool
bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
enum bitset_ops op)
enum bitset_ops op)
{
bool changed = false;
bool stats_enabled_save;

View File

@@ -33,11 +33,11 @@
/* Attributes used to select a bitset implementation. */
enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
BITSET_VARIABLE = 2, /* Bitset size variable. */
BITSET_DENSE = 4, /* Bitset dense. */
BITSET_SPARSE = 8, /* Bitset sparse. */
BITSET_FRUGAL = 16, /* Prefer most compact. */
BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */
BITSET_VARIABLE = 2, /* Bitset size variable. */
BITSET_DENSE = 4, /* Bitset dense. */
BITSET_SPARSE = 8, /* Bitset sparse. */
BITSET_FRUGAL = 16, /* Prefer most compact. */
BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */
typedef unsigned int bitset_attrs;
@@ -49,26 +49,26 @@ union bitset_union
{
/* This must be the first member of every other structure that is a
member of this union. */
struct bbitset_struct b; /* Base bitset data. */
struct bbitset_struct b; /* Base bitset data. */
struct abitset_struct
{
struct bbitset_struct b;
bitset_word words[1]; /* The array of bits. */
bitset_word words[1]; /* The array of bits. */
} a;
struct ebitset_struct
{
struct bbitset_struct b;
bitset_windex size; /* Number of elements. */
struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
bitset_windex size; /* Number of elements. */
struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
} e;
struct lbitset_struct
{
struct bbitset_struct b;
struct lbitset_elt_struct *head; /* First element in linked list. */
struct lbitset_elt_struct *tail; /* Last element in linked list. */
struct lbitset_elt_struct *head; /* First element in linked list. */
struct lbitset_elt_struct *tail; /* Last element in linked list. */
} l;
struct bitset_stats_struct
@@ -80,7 +80,7 @@ union bitset_union
struct vbitset_struct
{
struct bbitset_struct b;
bitset_windex size; /* Allocated size of array. */
bitset_windex size; /* Allocated size of array. */
} v;
};
@@ -116,7 +116,7 @@ extern void bitset_free (bitset);
/* Create a bitset of desired type and size using an obstack. The
bitset is zeroed. */
extern bitset bitset_obstack_alloc (struct obstack *bobstack,
bitset_bindex, enum bitset_type);
bitset_bindex, enum bitset_type);
/* Free bitset allocated on obstack. */
extern void bitset_obstack_free (bitset);
@@ -312,14 +312,14 @@ extern void bitset_dump (FILE *, bitset);
printf ("%lu ", (unsigned long int) i);
};
*/
#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
(ITER.num == BITSET_LIST_SIZE) \
&& (ITER.num = bitset_list (BSET, ITER.list, \
BITSET_LIST_SIZE, &ITER.next));) \
for (ITER.i = 0; \
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
ITER.i++)
#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
(ITER.num == BITSET_LIST_SIZE) \
&& (ITER.num = bitset_list (BSET, ITER.list, \
BITSET_LIST_SIZE, &ITER.next));) \
for (ITER.i = 0; \
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
ITER.i++)
/* Loop over all elements of BSET, in reverse order starting with
@@ -334,14 +334,14 @@ extern void bitset_dump (FILE *, bitset);
printf ("%lu ", (unsigned long int) i);
};
*/
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
(ITER.num == BITSET_LIST_SIZE) \
&& (ITER.num = bitset_list_reverse (BSET, ITER.list, \
BITSET_LIST_SIZE, &ITER.next));) \
for (ITER.i = 0; \
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
ITER.i++)
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
(ITER.num == BITSET_LIST_SIZE) \
&& (ITER.num = bitset_list_reverse (BSET, ITER.list, \
BITSET_LIST_SIZE, &ITER.next));) \
for (ITER.i = 0; \
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
ITER.i++)
/* Define set operations in terms of logical operations. */

View File

@@ -48,29 +48,29 @@
/* Accessor macros. */
#define BITSET_STATS_ALLOCS_INC(TYPE) \
#define BITSET_STATS_ALLOCS_INC(TYPE) \
bitset_stats_info->types[(TYPE)].allocs++
#define BITSET_STATS_FREES_INC(BSET) \
#define BITSET_STATS_FREES_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].frees++
#define BITSET_STATS_SETS_INC(BSET) \
#define BITSET_STATS_SETS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].sets++
#define BITSET_STATS_CACHE_SETS_INC(BSET) \
#define BITSET_STATS_CACHE_SETS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_sets++
#define BITSET_STATS_RESETS_INC(BSET) \
#define BITSET_STATS_RESETS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].resets++
#define BITSET_STATS_CACHE_RESETS_INC(BSET) \
#define BITSET_STATS_CACHE_RESETS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_resets++
#define BITSET_STATS_TESTS_INC(BSET) \
#define BITSET_STATS_TESTS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].tests++
#define BITSET_STATS_CACHE_TESTS_INC(BSET) \
#define BITSET_STATS_CACHE_TESTS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_tests++
#define BITSET_STATS_LISTS_INC(BSET) \
#define BITSET_STATS_LISTS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].lists++
#define BITSET_STATS_LIST_COUNTS_INC(BSET, I) \
#define BITSET_STATS_LIST_COUNTS_INC(BSET, I) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_counts[(I)]++
#define BITSET_STATS_LIST_SIZES_INC(BSET, I) \
#define BITSET_STATS_LIST_SIZES_INC(BSET, I) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_sizes[(I)]++
#define BITSET_STATS_LIST_DENSITY_INC(BSET, I) \
#define BITSET_STATS_LIST_DENSITY_INC(BSET, I) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_density[(I)]++
@@ -105,7 +105,7 @@ bool bitset_stats_enabled = false;
/* Print a percentage histogram with message MSG to FILE. */
static void
bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
unsigned int n_bins, unsigned int *bins)
unsigned int n_bins, unsigned int *bins)
{
unsigned int i;
unsigned int total;
@@ -120,16 +120,16 @@ bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
fprintf (file, "%s %s", name, msg);
for (i = 0; i < n_bins; i++)
fprintf (file, "%.0f-%.0f%%\t%8u (%5.1f%%)\n",
i * 100.0 / n_bins,
(i + 1) * 100.0 / n_bins, bins[i],
(100.0 * bins[i]) / total);
i * 100.0 / n_bins,
(i + 1) * 100.0 / n_bins, bins[i],
(100.0 * bins[i]) / total);
}
/* Print a log histogram with message MSG to FILE. */
static void
bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
unsigned int n_bins, unsigned int *bins)
unsigned int n_bins, unsigned int *bins)
{
unsigned int i;
unsigned int total;
@@ -153,50 +153,50 @@ bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
fprintf (file, "%s %s", name, msg);
for (i = 0; i < 2; i++)
fprintf (file, "%*d\t%8u (%5.1f%%)\n",
max_width, i, bins[i], 100.0 * bins[i] / total);
max_width, i, bins[i], 100.0 * bins[i] / total);
for (; i < n_bins; i++)
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
1UL << (i - 1),
(1UL << i) - 1,
bins[i],
(100.0 * bins[i]) / total);
max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
1UL << (i - 1),
(1UL << i) - 1,
bins[i],
(100.0 * bins[i]) / total);
}
/* Print bitset statistics to FILE. */
static void
bitset_stats_print_1 (FILE *file, const char *name,
struct bitset_type_info_struct *stats)
struct bitset_type_info_struct *stats)
{
if (!stats)
return;
fprintf (file, "%s:\n", name);
fprintf (file, _("%u bitset_allocs, %u freed (%.2f%%).\n"),
stats->allocs, stats->frees,
stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);
stats->allocs, stats->frees,
stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);
fprintf (file, _("%u bitset_sets, %u cached (%.2f%%)\n"),
stats->sets, stats->cache_sets,
stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);
stats->sets, stats->cache_sets,
stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);
fprintf (file, _("%u bitset_resets, %u cached (%.2f%%)\n"),
stats->resets, stats->cache_resets,
stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);
stats->resets, stats->cache_resets,
stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);
fprintf (file, _("%u bitset_tests, %u cached (%.2f%%)\n"),
stats->tests, stats->cache_tests,
stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);
stats->tests, stats->cache_tests,
stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);
fprintf (file, _("%u bitset_lists\n"), stats->lists);
bitset_log_histogram_print (file, name, _("count log histogram\n"),
BITSET_LOG_COUNT_BINS, stats->list_counts);
BITSET_LOG_COUNT_BINS, stats->list_counts);
bitset_log_histogram_print (file, name, _("size log histogram\n"),
BITSET_LOG_SIZE_BINS, stats->list_sizes);
BITSET_LOG_SIZE_BINS, stats->list_sizes);
bitset_percent_histogram_print (file, name, _("density histogram\n"),
BITSET_DENSITY_BINS, stats->list_density);
BITSET_DENSITY_BINS, stats->list_density);
}
@@ -216,7 +216,7 @@ bitset_stats_print (FILE *file, bool verbose ATTRIBUTE_UNUSED)
for (i = 0; i < BITSET_TYPE_NUM; i++)
bitset_stats_print_1 (file, bitset_type_names[i],
&bitset_stats_info->types[i]);
&bitset_stats_info->types[i]);
}
@@ -253,15 +253,15 @@ bitset_stats_read (const char *file_name)
if (file)
{
if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
1, file) != 1)
{
if (ferror (file))
perror (_("Could not read stats file."));
else
fprintf (stderr, _("Bad stats file size.\n"));
}
1, file) != 1)
{
if (ferror (file))
perror (_("Could not read stats file."));
else
fprintf (stderr, _("Bad stats file size.\n"));
}
if (fclose (file) != 0)
perror (_("Could not read stats file."));
perror (_("Could not read stats file."));
}
bitset_stats_info_data.runs++;
}
@@ -283,10 +283,10 @@ bitset_stats_write (const char *file_name)
if (file)
{
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
1, file) != 1)
perror (_("Could not write stats file."));
1, file) != 1)
perror (_("Could not write stats file."));
if (fclose (file) != 0)
perror (_("Could not write stats file."));
perror (_("Could not write stats file."));
}
else
perror (_("Could not open stats file for writing."));
@@ -340,7 +340,7 @@ bitset_stats_reset (bitset dst, bitset_bindex bitno)
if (offset < bset->b.csize)
{
bset->b.cdata[offset] &=
~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
BITSET_STATS_CACHE_RESETS_INC (bset);
}
else
@@ -570,7 +570,7 @@ bitset_stats_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
static bitset_bindex
bitset_stats_list (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex count;
bitset_bindex tmp;
@@ -609,7 +609,7 @@ bitset_stats_list (bitset bset, bitset_bindex *list,
static bitset_bindex
bitset_stats_list_reverse (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
bitset_bindex num, bitset_bindex *next)
{
return BITSET_LIST_REVERSE_ (bset->s.bset, list, num, next);
}

View File

@@ -56,7 +56,7 @@ bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
{
fprintf (out, "%2lu|", (unsigned long int) i);
for (j = 0; j < hsize; ++j)
fputs (bitset_test (bset[i], j) ? "1" : " ", out);
fputs (bitset_test (bset[i], j) ? "1" : " ", out);
fputs ("|\n", out);
}

View File

@@ -27,7 +27,7 @@
type TYPE. */
bitset *
bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
enum bitset_type type)
enum bitset_type type)
{
size_t vector_bytes;
size_t bytes;
@@ -116,7 +116,7 @@ bitsetv_transitive_closure (bitsetv bsetv)
for (i = 0; bsetv[i]; i++)
for (j = 0; bsetv[j]; j++)
if (bitset_test (bsetv[j], i))
bitset_or (bsetv[j], bsetv[j], bsetv[i]);
bitset_or (bsetv[j], bsetv[j], bsetv[i]);
}
@@ -139,7 +139,7 @@ bitsetv_reflexive_transitive_closure (bitsetv bsetv)
FILE. */
void
bitsetv_dump (FILE *file, char const *title, char const *subtitle,
bitsetv bsetv)
bitsetv bsetv)
{
bitset_windex i;

View File

@@ -58,7 +58,7 @@ typedef struct ebitset_elt_struct
{
union
{
bitset_word words[EBITSET_ELT_WORDS]; /* Bits that are set. */
bitset_word words[EBITSET_ELT_WORDS]; /* Bits that are set. */
struct ebitset_elt_struct *next;
}
u;
@@ -84,7 +84,7 @@ static ebitset_elt ebitset_zero_elts[1]; /* Elements of all zero bits. */
/* Obstack to allocate bitset elements from. */
static struct obstack ebitset_obstack;
static bool ebitset_obstack_init = false;
static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
#define EBITSET_N_ELTS(N) (((N) + EBITSET_ELT_BITS - 1) / EBITSET_ELT_BITS)
#define EBITSET_ELTS(BSET) ((BSET)->e.elts)
@@ -96,7 +96,7 @@ static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
/* Disable bitset cache and mark BSET as being zero. */
#define EBITSET_ZERO_SET(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX, \
(BSET)->b.cdata = 0)
(BSET)->b.cdata = 0)
#define EBITSET_CACHE_DISABLE(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX)
@@ -136,37 +136,37 @@ ebitset_resize (bitset src, bitset_bindex n_bits)
bitset_windex size;
/* The bitset needs to grow. If we already have enough memory
allocated, then just zero what we need. */
allocated, then just zero what we need. */
if (newsize > EBITSET_ASIZE (src))
{
/* We need to allocate more memory. When oldsize is
non-zero this means that we are changing the size, so
grow the bitset 25% larger than requested to reduce
number of reallocations. */
{
/* We need to allocate more memory. When oldsize is
non-zero this means that we are changing the size, so
grow the bitset 25% larger than requested to reduce
number of reallocations. */
if (oldsize == 0)
size = newsize;
else
size = newsize + newsize / 4;
if (oldsize == 0)
size = newsize;
else
size = newsize + newsize / 4;
EBITSET_ELTS (src)
= realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
EBITSET_ASIZE (src) = size;
}
EBITSET_ELTS (src)
= realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
EBITSET_ASIZE (src) = size;
}
memset (EBITSET_ELTS (src) + oldsize, 0,
(newsize - oldsize) * sizeof (ebitset_elt *));
(newsize - oldsize) * sizeof (ebitset_elt *));
}
else
{
/* The bitset needs to shrink. There's no point deallocating
the memory unless it is shrinking by a reasonable amount. */
the memory unless it is shrinking by a reasonable amount. */
if ((oldsize - newsize) >= oldsize / 2)
{
EBITSET_ELTS (src)
= realloc (EBITSET_ELTS (src), newsize * sizeof (ebitset_elt *));
EBITSET_ASIZE (src) = newsize;
}
{
EBITSET_ELTS (src)
= realloc (EBITSET_ELTS (src), newsize * sizeof (ebitset_elt *));
EBITSET_ASIZE (src) = newsize;
}
/* Need to prune any excess bits. FIXME. */
}
@@ -190,16 +190,16 @@ ebitset_elt_alloc (void)
else
{
if (!ebitset_obstack_init)
{
ebitset_obstack_init = true;
{
ebitset_obstack_init = true;
/* Let particular systems override the size of a chunk. */
/* Let particular systems override the size of a chunk. */
#ifndef OBSTACK_CHUNK_SIZE
#define OBSTACK_CHUNK_SIZE 0
#endif
/* Let them override the alloc and free routines too. */
/* Let them override the alloc and free routines too. */
#ifndef OBSTACK_CHUNK_ALLOC
#define OBSTACK_CHUNK_ALLOC xmalloc
@@ -213,16 +213,16 @@ ebitset_elt_alloc (void)
#define __alignof__(type) 0
#endif
obstack_specify_allocation (&ebitset_obstack, OBSTACK_CHUNK_SIZE,
__alignof__ (ebitset_elt),
OBSTACK_CHUNK_ALLOC,
OBSTACK_CHUNK_FREE);
}
obstack_specify_allocation (&ebitset_obstack, OBSTACK_CHUNK_SIZE,
__alignof__ (ebitset_elt),
OBSTACK_CHUNK_ALLOC,
OBSTACK_CHUNK_FREE);
}
/* Perhaps we should add a number of new elements to the free
list. */
list. */
elt = (ebitset_elt *) obstack_alloc (&ebitset_obstack,
sizeof (ebitset_elt));
sizeof (ebitset_elt));
}
return elt;
@@ -293,7 +293,7 @@ ebitset_elt_zero_p (ebitset_elt *elt)
static ebitset_elt *
ebitset_elt_find (bitset bset, bitset_bindex bindex,
enum ebitset_find_mode mode)
enum ebitset_find_mode mode)
{
ebitset_elt *elt;
bitset_windex size;
@@ -308,13 +308,13 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
if (eindex < size)
{
if ((elt = elts[eindex]))
{
if (EBITSET_WORDS (elt) == bset->b.cdata)
return elt;
{
if (EBITSET_WORDS (elt) == bset->b.cdata)
return elt;
EBITSET_CACHE_SET (bset, eindex);
return elt;
}
EBITSET_CACHE_SET (bset, eindex);
return elt;
}
}
/* The element could not be found. */
@@ -329,7 +329,7 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
case EBITSET_CREATE:
if (eindex >= size)
ebitset_resize (bset, bindex);
ebitset_resize (bset, bindex);
/* Create a new element. */
elt = ebitset_elt_calloc ();
@@ -361,22 +361,22 @@ ebitset_weed (bitset bset)
ebitset_elt *elt = elts[j];
if (elt)
{
if (ebitset_elt_zero_p (elt))
{
ebitset_elt_remove (bset, j);
count++;
}
}
{
if (ebitset_elt_zero_p (elt))
{
ebitset_elt_remove (bset, j);
count++;
}
}
else
count++;
count++;
}
count = j - count;
if (!count)
{
/* All the bits are zero. We could shrink the elts.
For now just mark BSET as known to be zero. */
For now just mark BSET as known to be zero. */
EBITSET_ZERO_SET (bset);
}
else
@@ -402,7 +402,7 @@ ebitset_zero (bitset bset)
ebitset_elt *elt = elts[j];
if (elt)
ebitset_elt_remove (bset, j);
ebitset_elt_remove (bset, j);
}
/* All the bits are zero. We could shrink the elts.
@@ -437,13 +437,13 @@ ebitset_equal_p (bitset dst, bitset src)
ebitset_elt *delt = delts[j];
if (!selt && !delt)
continue;
continue;
if ((selt && !delt) || (!selt && delt))
return false;
return false;
for (i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
return false;
if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
return false;
}
return true;
}
@@ -472,14 +472,14 @@ ebitset_copy_ (bitset dst, bitset src)
ebitset_elt *selt = selts[j];
if (selt)
{
ebitset_elt *tmp;
{
ebitset_elt *tmp;
tmp = ebitset_elt_alloc ();
delts[j] = tmp;
memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt),
sizeof (EBITSET_WORDS (selt)));
}
tmp = ebitset_elt_alloc ();
delts[j] = tmp;
memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt),
sizeof (EBITSET_WORDS (selt)));
}
}
EBITSET_NONZERO_SET (dst);
}
@@ -545,9 +545,9 @@ ebitset_test (bitset src, bitset_bindex bitno)
bitset_windex windex = bitno / BITSET_WORD_BITS;
return (ebitset_elt_find (src, bitno, EBITSET_FIND)
&& ((src->b.cdata[windex - src->b.cindex]
>> (bitno % BITSET_WORD_BITS))
& 1));
&& ((src->b.cdata[windex - src->b.cindex]
>> (bitno % BITSET_WORD_BITS))
& 1));
}
@@ -564,7 +564,7 @@ ebitset_free (bitset bset)
found and with *NEXT indicating where search stopped. */
static bitset_bindex
ebitset_list_reverse (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex n_bits;
bitset_bindex bitno;
@@ -610,33 +610,33 @@ ebitset_list_reverse (bitset bset, bitset_bindex *list,
elt = elts[eindex];
if (elt)
{
srcp = EBITSET_WORDS (elt);
{
srcp = EBITSET_WORDS (elt);
do
{
bitset_word word;
do
{
bitset_word word;
word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
for (; word; bcount--)
{
if (word & BITSET_MSB)
{
list[count++] = boffset + bcount;
if (count >= num)
{
*next = n_bits - (boffset + bcount);
return count;
}
}
word <<= 1;
}
boffset -= BITSET_WORD_BITS;
bcount = BITSET_WORD_BITS - 1;
}
while (woffset--);
}
for (; word; bcount--)
{
if (word & BITSET_MSB)
{
list[count++] = boffset + bcount;
if (count >= num)
{
*next = n_bits - (boffset + bcount);
return count;
}
}
word <<= 1;
}
boffset -= BITSET_WORD_BITS;
bcount = BITSET_WORD_BITS - 1;
}
while (woffset--);
}
woffset = EBITSET_ELT_WORDS - 1;
boffset = eindex * EBITSET_ELT_BITS - BITSET_WORD_BITS;
@@ -653,7 +653,7 @@ ebitset_list_reverse (bitset bset, bitset_bindex *list,
found and with *NEXT indicating where search stopped. */
static bitset_bindex
ebitset_list (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_windex windex;
@@ -680,33 +680,33 @@ ebitset_list (bitset bset, bitset_bindex *list,
elt = elts[eindex];
if (elt)
{
bitset_windex woffset;
bitset_word *srcp = EBITSET_WORDS (elt);
{
bitset_windex woffset;
bitset_word *srcp = EBITSET_WORDS (elt);
windex = bitno / BITSET_WORD_BITS;
woffset = eindex * EBITSET_ELT_WORDS;
windex = bitno / BITSET_WORD_BITS;
woffset = eindex * EBITSET_ELT_WORDS;
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
{
word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS);
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
{
word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS);
for (; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
bitno = (windex + 1) * BITSET_WORD_BITS;
}
}
for (; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
bitno = (windex + 1) * BITSET_WORD_BITS;
}
}
/* Skip to next element. */
eindex++;
@@ -722,108 +722,108 @@ ebitset_list (bitset bset, bitset_bindex *list,
elt = elts[eindex];
if (!elt)
continue;
continue;
srcp = EBITSET_WORDS (elt);
windex = eindex * EBITSET_ELT_WORDS;
if ((count + EBITSET_ELT_BITS) < num)
{
/* The coast is clear, plant boot! */
{
/* The coast is clear, plant boot! */
#if EBITSET_ELT_WORDS == 2
word = srcp[0];
if (word)
{
if (!(word & 0xffff))
{
word >>= 16;
bitno += 16;
}
if (!(word & 0xff))
{
word >>= 8;
bitno += 8;
}
for (; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
windex++;
bitno = windex * BITSET_WORD_BITS;
word = srcp[0];
if (word)
{
if (!(word & 0xffff))
{
word >>= 16;
bitno += 16;
}
if (!(word & 0xff))
{
word >>= 8;
bitno += 8;
}
for (; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
windex++;
bitno = windex * BITSET_WORD_BITS;
word = srcp[1];
if (word)
{
if (!(word & 0xffff))
{
word >>= 16;
bitno += 16;
}
for (; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
windex++;
bitno = windex * BITSET_WORD_BITS;
word = srcp[1];
if (word)
{
if (!(word & 0xffff))
{
word >>= 16;
bitno += 16;
}
for (; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
windex++;
bitno = windex * BITSET_WORD_BITS;
#else
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
{
bitno = windex * BITSET_WORD_BITS;
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
{
bitno = windex * BITSET_WORD_BITS;
word = srcp[i];
if (word)
{
if (!(word & 0xffff))
{
word >>= 16;
bitno += 16;
}
if (!(word & 0xff))
{
word >>= 8;
bitno += 8;
}
for (; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
}
word = srcp[i];
if (word)
{
if (!(word & 0xffff))
{
word >>= 16;
bitno += 16;
}
if (!(word & 0xff))
{
word >>= 8;
bitno += 8;
}
for (; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
}
#endif
}
}
else
{
/* Tread more carefully since we need to check
if array overflows. */
{
/* Tread more carefully since we need to check
if array overflows. */
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
{
bitno = windex * BITSET_WORD_BITS;
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
{
bitno = windex * BITSET_WORD_BITS;
for (word = srcp[i]; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
}
}
for (word = srcp[i]; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
}
}
}
*next = bitno;
@@ -853,19 +853,19 @@ ebitset_unused_clear (bitset dst)
elt = elts[eindex];
if (elt)
{
bitset_windex windex;
bitset_windex woffset;
bitset_word *srcp = EBITSET_WORDS (elt);
{
bitset_windex windex;
bitset_windex woffset;
bitset_word *srcp = EBITSET_WORDS (elt);
windex = n_bits / BITSET_WORD_BITS;
woffset = eindex * EBITSET_ELT_WORDS;
windex = n_bits / BITSET_WORD_BITS;
woffset = eindex * EBITSET_ELT_WORDS;
srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
windex++;
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
srcp[windex - woffset] = 0;
}
srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
windex++;
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
srcp[windex - woffset] = 0;
}
}
}
@@ -879,9 +879,9 @@ ebitset_ones (bitset dst)
for (j = 0; j < EBITSET_SIZE (dst); j++)
{
/* Create new elements if they cannot be found. Perhaps
we should just add pointers to a ones element? */
we should just add pointers to a ones element? */
elt =
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));
}
EBITSET_NONZERO_SET (dst);
@@ -904,12 +904,12 @@ ebitset_empty_p (bitset dst)
ebitset_elt *elt = elts[j];
if (elt)
{
if (!ebitset_elt_zero_p (elt))
return 0;
/* Do some weeding as we go. */
ebitset_elt_remove (dst, j);
}
{
if (!ebitset_elt_zero_p (elt))
return 0;
/* Do some weeding as we go. */
ebitset_elt_remove (dst, j);
}
}
/* All the bits are zero. We could shrink the elts.
@@ -932,14 +932,14 @@ ebitset_not (bitset dst, bitset src)
for (j = 0; j < EBITSET_SIZE (src); j++)
{
/* Create new elements for dst if they cannot be found
or substitute zero elements if src elements not found. */
or substitute zero elements if src elements not found. */
selt =
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
delt =
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_CREATE);
for (i = 0; i < EBITSET_ELT_WORDS; i++)
EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i];
EBITSET_WORDS (delt)[i] = ~EBITSET_WORDS (selt)[i];
}
EBITSET_NONZERO_SET (dst);
ebitset_unused_clear (dst);
@@ -972,17 +972,17 @@ ebitset_subset_p (bitset dst, bitset src)
delt = j < dsize ? delts[j] : 0;
if (!selt && !delt)
continue;
continue;
if (!selt)
selt = &ebitset_zero_elts[0];
selt = &ebitset_zero_elts[0];
if (!delt)
delt = &ebitset_zero_elts[0];
delt = &ebitset_zero_elts[0];
for (i = 0; i < EBITSET_ELT_WORDS; i++)
if (EBITSET_WORDS (delt)[i]
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
return false;
if (EBITSET_WORDS (delt)[i]
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
return false;
}
return true;
}
@@ -1014,11 +1014,11 @@ ebitset_disjoint_p (bitset dst, bitset src)
delt = j < dsize ? delts[j] : 0;
if (!selt || !delt)
continue;
continue;
for (i = 0; i < EBITSET_ELT_WORDS; i++)
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
return false;
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
return false;
}
return true;
}
@@ -1066,93 +1066,93 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
delt = j < dsize ? delts[j] : 0;
if (!selt1 && !selt2)
{
if (delt)
{
changed = true;
ebitset_elt_remove (dst, j);
}
continue;
}
{
if (delt)
{
changed = true;
ebitset_elt_remove (dst, j);
}
continue;
}
if (!selt1)
selt1 = &ebitset_zero_elts[0];
selt1 = &ebitset_zero_elts[0];
if (!selt2)
selt2 = &ebitset_zero_elts[0];
selt2 = &ebitset_zero_elts[0];
if (!delt)
delt = ebitset_elt_calloc ();
delt = ebitset_elt_calloc ();
else
delts[j] = 0;
delts[j] = 0;
srcp1 = EBITSET_WORDS (selt1);
srcp2 = EBITSET_WORDS (selt2);
dstp = EBITSET_WORDS (delt);
switch (op)
{
default:
abort ();
{
default:
abort ();
case BITSET_OP_OR:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ | *srcp2++;
case BITSET_OP_OR:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ | *srcp2++;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
case BITSET_OP_AND:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ & *srcp2++;
case BITSET_OP_AND:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ & *srcp2++;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
case BITSET_OP_XOR:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ ^ *srcp2++;
case BITSET_OP_XOR:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ ^ *srcp2++;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
case BITSET_OP_ANDN:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ & ~(*srcp2++);
case BITSET_OP_ANDN:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ & ~(*srcp2++);
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
}
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
}
if (!ebitset_elt_zero_p (delt))
{
ebitset_elt_add (dst, delt, j);
}
{
ebitset_elt_add (dst, delt, j);
}
else
{
ebitset_elt_free (delt);
}
{
ebitset_elt_free (delt);
}
}
/* If we have elements of DST left over, free them all. */
@@ -1165,7 +1165,7 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
delt = delts[j];
if (delt)
ebitset_elt_remove (dst, j);
ebitset_elt_remove (dst, j);
}
EBITSET_NONZERO_SET (dst);

View File

@@ -60,10 +60,10 @@ typedef bitset_word lbitset_word;
These are linked together in a doubly-linked list. */
typedef struct lbitset_elt_struct
{
struct lbitset_elt_struct *next; /* Next element. */
struct lbitset_elt_struct *prev; /* Previous element. */
bitset_windex index; /* bitno / BITSET_WORD_BITS. */
bitset_word words[LBITSET_ELT_WORDS]; /* Bits that are set. */
struct lbitset_elt_struct *next; /* Next element. */
struct lbitset_elt_struct *prev; /* Previous element. */
bitset_windex index; /* bitno / BITSET_WORD_BITS. */
bitset_word words[LBITSET_ELT_WORDS]; /* Bits that are set. */
}
lbitset_elt;
@@ -76,7 +76,7 @@ static lbitset_elt lbitset_zero_elts[3]; /* Elements of all zero bits. */
/* Obstack to allocate bitset elements from. */
static struct obstack lbitset_obstack;
static bool lbitset_obstack_init = false;
static lbitset_elt *lbitset_free_list; /* Free list of bitset elements. */
static lbitset_elt *lbitset_free_list; /* Free list of bitset elements. */
extern void debug_lbitset (bitset);
@@ -102,16 +102,16 @@ lbitset_elt_alloc (void)
else
{
if (!lbitset_obstack_init)
{
lbitset_obstack_init = true;
{
lbitset_obstack_init = true;
/* Let particular systems override the size of a chunk. */
/* Let particular systems override the size of a chunk. */
#ifndef OBSTACK_CHUNK_SIZE
#define OBSTACK_CHUNK_SIZE 0
#endif
/* Let them override the alloc and free routines too. */
/* Let them override the alloc and free routines too. */
#ifndef OBSTACK_CHUNK_ALLOC
#define OBSTACK_CHUNK_ALLOC xmalloc
@@ -125,16 +125,16 @@ lbitset_elt_alloc (void)
#define __alignof__(type) 0
#endif
obstack_specify_allocation (&lbitset_obstack, OBSTACK_CHUNK_SIZE,
__alignof__ (lbitset_elt),
OBSTACK_CHUNK_ALLOC,
OBSTACK_CHUNK_FREE);
}
obstack_specify_allocation (&lbitset_obstack, OBSTACK_CHUNK_SIZE,
__alignof__ (lbitset_elt),
OBSTACK_CHUNK_ALLOC,
OBSTACK_CHUNK_FREE);
}
/* Perhaps we should add a number of new elements to the free
list. */
list. */
elt = (lbitset_elt *) obstack_alloc (&lbitset_obstack,
sizeof (lbitset_elt));
sizeof (lbitset_elt));
}
return elt;
@@ -185,20 +185,20 @@ lbitset_elt_unlink (bitset bset, lbitset_elt *elt)
if (LBITSET_CURRENT (bset) == elt)
{
if (next)
{
bset->b.cdata = next->words;
bset->b.cindex = next->index;
}
{
bset->b.cdata = next->words;
bset->b.cindex = next->index;
}
else if (prev)
{
bset->b.cdata = prev->words;
bset->b.cindex = prev->index;
}
{
bset->b.cdata = prev->words;
bset->b.cindex = prev->index;
}
else
{
bset->b.csize = 0;
bset->b.cdata = 0;
}
{
bset->b.csize = 0;
bset->b.cdata = 0;
}
}
lbitset_elt_free (elt);
@@ -278,13 +278,13 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
else if (windex < bset->b.cindex)
{
for (ptr = current;
ptr->prev && ptr->prev->index > windex; ptr = ptr->prev)
continue;
ptr->prev && ptr->prev->index > windex; ptr = ptr->prev)
continue;
if (ptr->prev)
ptr->prev->next = elt;
ptr->prev->next = elt;
else
LBITSET_HEAD (bset) = elt;
LBITSET_HEAD (bset) = elt;
elt->prev = ptr->prev;
elt->next = ptr;
@@ -295,13 +295,13 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
else
{
for (ptr = current;
ptr->next && ptr->next->index < windex; ptr = ptr->next)
continue;
ptr->next && ptr->next->index < windex; ptr = ptr->next)
continue;
if (ptr->next)
ptr->next->prev = elt;
ptr->next->prev = elt;
else
LBITSET_TAIL (bset) = elt;
LBITSET_TAIL (bset) = elt;
elt->next = ptr->next;
elt->prev = ptr;
@@ -317,7 +317,7 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
static lbitset_elt *
lbitset_elt_find (bitset bset, bitset_windex windex,
enum lbitset_find_mode mode)
enum lbitset_find_mode mode)
{
lbitset_elt *elt;
lbitset_elt *current;
@@ -327,7 +327,7 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
current = LBITSET_CURRENT (bset);
/* Check if element is the cached element. */
if ((windex - bset->b.cindex) < bset->b.csize)
return current;
return current;
}
else
{
@@ -337,28 +337,28 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
if (current)
{
if (windex < bset->b.cindex)
{
for (elt = current;
elt->prev && elt->index > windex; elt = elt->prev)
continue;
}
{
for (elt = current;
elt->prev && elt->index > windex; elt = elt->prev)
continue;
}
else
{
for (elt = current;
elt->next && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
elt = elt->next)
continue;
}
{
for (elt = current;
elt->next && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
elt = elt->next)
continue;
}
/* ELT is the nearest to the one we want. If it's not the one
we want, the one we want does not exist. */
we want, the one we want does not exist. */
if (elt && (windex - elt->index) < LBITSET_ELT_WORDS)
{
bset->b.cindex = elt->index;
bset->b.csize = LBITSET_ELT_WORDS;
bset->b.cdata = elt->words;
return elt;
}
{
bset->b.cindex = elt->index;
bset->b.csize = LBITSET_ELT_WORDS;
bset->b.cdata = elt->words;
return elt;
}
}
switch (mode)
@@ -394,7 +394,7 @@ lbitset_weed (bitset bset)
{
next = elt->next;
if (lbitset_elt_zero_p (elt))
lbitset_elt_unlink (bset, elt);
lbitset_elt_unlink (bset, elt);
}
}
@@ -431,11 +431,11 @@ lbitset_equal_p (bitset dst, bitset src)
selt && delt; selt = selt->next, delt = delt->next)
{
if (selt->index != delt->index)
return false;
return false;
for (j = 0; j < LBITSET_ELT_WORDS; j++)
if (delt->words[j] != selt->words[j])
return false;
if (delt->words[j] != selt->words[j])
return false;
}
return !selt && !delt;
}
@@ -467,9 +467,9 @@ lbitset_copy (bitset dst, bitset src)
tmp->prev = prev;
tmp->next = 0;
if (prev)
prev->next = tmp;
prev->next = tmp;
else
LBITSET_HEAD (dst) = tmp;
LBITSET_HEAD (dst) = tmp;
prev = tmp;
memcpy (tmp->words, elt->words, sizeof (elt->words));
@@ -549,9 +549,9 @@ lbitset_test (bitset src, bitset_bindex bitno)
bitset_windex windex = bitno / BITSET_WORD_BITS;
return (lbitset_elt_find (src, windex, LBITSET_FIND)
&& ((src->b.cdata[windex - src->b.cindex]
>> (bitno % BITSET_WORD_BITS))
& 1));
&& ((src->b.cdata[windex - src->b.cindex]
>> (bitno % BITSET_WORD_BITS))
& 1));
}
@@ -567,7 +567,7 @@ lbitset_free (bitset bset)
found and with *NEXT indicating where search stopped. */
static bitset_bindex
lbitset_list_reverse (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex rbitno;
bitset_bindex bitno;
@@ -603,7 +603,7 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
if (windex >= elt->index + LBITSET_ELT_WORDS)
{
/* We are trying to start in no-mans land so start
at end of current elt. */
at end of current elt. */
bcount = BITSET_WORD_BITS - 1;
windex = elt->index + LBITSET_ELT_WORDS - 1;
}
@@ -623,33 +623,33 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
bitset_word *srcp = elt->words;
for (; (windex - elt->index) < LBITSET_ELT_WORDS;
windex--, boffset -= BITSET_WORD_BITS,
bcount = BITSET_WORD_BITS - 1)
{
word =
srcp[windex - elt->index] << (BITSET_WORD_BITS - 1 - bcount);
windex--, boffset -= BITSET_WORD_BITS,
bcount = BITSET_WORD_BITS - 1)
{
word =
srcp[windex - elt->index] << (BITSET_WORD_BITS - 1 - bcount);
for (; word; bcount--)
{
if (word & BITSET_MSB)
{
list[count++] = boffset + bcount;
if (count >= num)
{
*next = n_bits - (boffset + bcount);
return count;
}
}
word <<= 1;
}
}
for (; word; bcount--)
{
if (word & BITSET_MSB)
{
list[count++] = boffset + bcount;
if (count >= num)
{
*next = n_bits - (boffset + bcount);
return count;
}
}
word <<= 1;
}
}
elt = elt->prev;
if (elt)
{
windex = elt->index + LBITSET_ELT_WORDS - 1;
boffset = windex * BITSET_WORD_BITS;
}
{
windex = elt->index + LBITSET_ELT_WORDS - 1;
boffset = windex * BITSET_WORD_BITS;
}
}
*next = n_bits - (boffset + 1);
@@ -662,7 +662,7 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
found and with *NEXT indicating where search stopped. */
static bitset_bindex
lbitset_list (bitset bset, bitset_bindex *list,
bitset_bindex num, bitset_bindex *next)
bitset_bindex num, bitset_bindex *next)
{
bitset_bindex bitno;
bitset_windex windex;
@@ -693,51 +693,51 @@ lbitset_list (bitset bset, bitset_bindex *list,
/* Skip to starting element. */
for (elt = head;
elt && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
elt = elt->next)
continue;
elt && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
elt = elt->next)
continue;
if (!elt)
return 0;
return 0;
if (windex < elt->index)
{
windex = elt->index;
bitno = windex * BITSET_WORD_BITS;
}
{
windex = elt->index;
bitno = windex * BITSET_WORD_BITS;
}
else
{
bitset_word *srcp = elt->words;
{
bitset_word *srcp = elt->words;
/* We are starting within an element. */
/* We are starting within an element. */
for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
{
word = srcp[windex - elt->index] >> (bitno % BITSET_WORD_BITS);
for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
{
word = srcp[windex - elt->index] >> (bitno % BITSET_WORD_BITS);
for (; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
bitno = (windex + 1) * BITSET_WORD_BITS;
}
for (; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
bitno = (windex + 1) * BITSET_WORD_BITS;
}
elt = elt->next;
if (elt)
{
windex = elt->index;
bitno = windex * BITSET_WORD_BITS;
}
}
elt = elt->next;
if (elt)
{
windex = elt->index;
bitno = windex * BITSET_WORD_BITS;
}
}
}
@@ -750,109 +750,109 @@ lbitset_list (bitset bset, bitset_bindex *list,
bitset_word *srcp = elt->words;
if ((count + LBITSET_ELT_BITS) < num)
{
/* The coast is clear, plant boot! */
{
/* The coast is clear, plant boot! */
#if LBITSET_ELT_WORDS == 2
word = srcp[0];
if (word)
{
if (!(word & 0xffff))
{
word >>= 16;
bitno += 16;
}
if (!(word & 0xff))
{
word >>= 8;
bitno += 8;
}
for (; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
windex++;
bitno = windex * BITSET_WORD_BITS;
word = srcp[0];
if (word)
{
if (!(word & 0xffff))
{
word >>= 16;
bitno += 16;
}
if (!(word & 0xff))
{
word >>= 8;
bitno += 8;
}
for (; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
windex++;
bitno = windex * BITSET_WORD_BITS;
word = srcp[1];
if (word)
{
if (!(word & 0xffff))
{
word >>= 16;
bitno += 16;
}
for (; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
windex++;
bitno = windex * BITSET_WORD_BITS;
word = srcp[1];
if (word)
{
if (!(word & 0xffff))
{
word >>= 16;
bitno += 16;
}
for (; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
windex++;
bitno = windex * BITSET_WORD_BITS;
#else
for (i = 0; i < LBITSET_ELT_WORDS; i++)
{
word = srcp[i];
if (word)
{
if (!(word & 0xffff))
{
word >>= 16;
bitno += 16;
}
if (!(word & 0xff))
{
word >>= 8;
bitno += 8;
}
for (; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
windex++;
bitno = windex * BITSET_WORD_BITS;
}
for (i = 0; i < LBITSET_ELT_WORDS; i++)
{
word = srcp[i];
if (word)
{
if (!(word & 0xffff))
{
word >>= 16;
bitno += 16;
}
if (!(word & 0xff))
{
word >>= 8;
bitno += 8;
}
for (; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
windex++;
bitno = windex * BITSET_WORD_BITS;
}
#endif
}
}
else
{
/* Tread more carefully since we need to check
if array overflows. */
{
/* Tread more carefully since we need to check
if array overflows. */
for (i = 0; i < LBITSET_ELT_WORDS; i++)
{
for (word = srcp[i]; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
windex++;
bitno = windex * BITSET_WORD_BITS;
}
}
for (i = 0; i < LBITSET_ELT_WORDS; i++)
{
for (word = srcp[i]; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
windex++;
bitno = windex * BITSET_WORD_BITS;
}
}
elt = elt->next;
if (elt)
{
windex = elt->index;
bitno = windex * BITSET_WORD_BITS;
}
{
windex = elt->index;
bitno = windex * BITSET_WORD_BITS;
}
}
*next = bitno;
@@ -870,7 +870,7 @@ lbitset_empty_p (bitset dst)
{
next = elt->next;
if (!lbitset_elt_zero_p (elt))
return 0;
return 0;
/* Weed as we go. */
lbitset_elt_unlink (dst, elt);
}
@@ -903,7 +903,7 @@ lbitset_unused_clear (bitset dst)
windex++;
for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
srcp[windex - elt->index] = 0;
srcp[windex - elt->index] = 0;
}
}
@@ -952,12 +952,12 @@ lbitset_not (bitset dst, bitset src)
for (i = 0; i < windex; i += LBITSET_ELT_WORDS)
{
/* Create new elements for dst if they cannot be found
or substitute zero elements if src elements not found. */
or substitute zero elements if src elements not found. */
selt = lbitset_elt_find (src, i, LBITSET_SUBST);
delt = lbitset_elt_find (dst, i, LBITSET_CREATE);
for (j = 0; j < LBITSET_ELT_WORDS; j++)
delt->words[j] = ~selt->words[j];
delt->words[j] = ~selt->words[j];
}
lbitset_unused_clear (dst);
lbitset_weed (dst);
@@ -977,26 +977,26 @@ lbitset_subset_p (bitset dst, bitset src)
selt || delt; selt = selt->next, delt = delt->next)
{
if (!selt)
selt = &lbitset_zero_elts[0];
selt = &lbitset_zero_elts[0];
else if (!delt)
delt = &lbitset_zero_elts[0];
delt = &lbitset_zero_elts[0];
else if (selt->index != delt->index)
{
if (selt->index < delt->index)
{
lbitset_zero_elts[2].next = delt;
delt = &lbitset_zero_elts[2];
}
else
{
lbitset_zero_elts[1].next = selt;
selt = &lbitset_zero_elts[1];
}
}
{
if (selt->index < delt->index)
{
lbitset_zero_elts[2].next = delt;
delt = &lbitset_zero_elts[2];
}
else
{
lbitset_zero_elts[1].next = selt;
selt = &lbitset_zero_elts[1];
}
}
for (j = 0; j < LBITSET_ELT_WORDS; j++)
if (delt->words[j] != (selt->words[j] | delt->words[j]))
return false;
if (delt->words[j] != (selt->words[j] | delt->words[j]))
return false;
}
return true;
}
@@ -1014,25 +1014,25 @@ lbitset_disjoint_p (bitset dst, bitset src)
selt && delt; selt = selt->next, delt = delt->next)
{
if (selt->index != delt->index)
{
if (selt->index < delt->index)
{
lbitset_zero_elts[2].next = delt;
delt = &lbitset_zero_elts[2];
}
else
{
lbitset_zero_elts[1].next = selt;
selt = &lbitset_zero_elts[1];
}
/* Since the elements are different, there is no
intersection of these elements. */
continue;
}
{
if (selt->index < delt->index)
{
lbitset_zero_elts[2].next = delt;
delt = &lbitset_zero_elts[2];
}
else
{
lbitset_zero_elts[1].next = selt;
selt = &lbitset_zero_elts[1];
}
/* Since the elements are different, there is no
intersection of these elements. */
continue;
}
for (j = 0; j < LBITSET_ELT_WORDS; j++)
if (selt->words[j] & delt->words[j])
return false;
if (selt->words[j] & delt->words[j])
return false;
}
return true;
}
@@ -1065,124 +1065,124 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
while (selt1 || selt2)
{
/* Figure out whether we need to substitute zero elements for
missing links. */
missing links. */
if (windex1 == windex2)
{
windex = windex1;
stmp1 = selt1;
stmp2 = selt2;
selt1 = selt1->next;
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
selt2 = selt2->next;
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
}
{
windex = windex1;
stmp1 = selt1;
stmp2 = selt2;
selt1 = selt1->next;
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
selt2 = selt2->next;
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
}
else if (windex1 < windex2)
{
windex = windex1;
stmp1 = selt1;
stmp2 = &lbitset_zero_elts[0];
selt1 = selt1->next;
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
}
{
windex = windex1;
stmp1 = selt1;
stmp2 = &lbitset_zero_elts[0];
selt1 = selt1->next;
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
}
else
{
windex = windex2;
stmp1 = &lbitset_zero_elts[0];
stmp2 = selt2;
selt2 = selt2->next;
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
}
{
windex = windex2;
stmp1 = &lbitset_zero_elts[0];
stmp2 = selt2;
selt2 = selt2->next;
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
}
/* Find the appropriate element from DST. Begin by discarding
elements that we've skipped. */
elements that we've skipped. */
while (delt && delt->index < windex)
{
changed = true;
dtmp = delt;
delt = delt->next;
lbitset_elt_free (dtmp);
}
{
changed = true;
dtmp = delt;
delt = delt->next;
lbitset_elt_free (dtmp);
}
if (delt && delt->index == windex)
{
dtmp = delt;
delt = delt->next;
}
{
dtmp = delt;
delt = delt->next;
}
else
dtmp = lbitset_elt_calloc ();
dtmp = lbitset_elt_calloc ();
/* Do the operation, and if any bits are set, link it into the
linked list. */
linked list. */
srcp1 = stmp1->words;
srcp2 = stmp2->words;
dstp = dtmp->words;
switch (op)
{
default:
abort ();
{
default:
abort ();
case BITSET_OP_OR:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ | *srcp2++;
case BITSET_OP_OR:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ | *srcp2++;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
case BITSET_OP_AND:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ & *srcp2++;
case BITSET_OP_AND:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ & *srcp2++;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
case BITSET_OP_XOR:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ ^ *srcp2++;
case BITSET_OP_XOR:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ ^ *srcp2++;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
case BITSET_OP_ANDN:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ & ~(*srcp2++);
case BITSET_OP_ANDN:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
bitset_word tmp = *srcp1++ & ~(*srcp2++);
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
}
if (*dstp != tmp)
{
changed = true;
*dstp = tmp;
}
}
break;
}
if (!lbitset_elt_zero_p (dtmp))
{
dtmp->index = windex;
/* Perhaps this could be optimised... */
lbitset_elt_link (dst, dtmp);
}
{
dtmp->index = windex;
/* Perhaps this could be optimised... */
lbitset_elt_link (dst, dtmp);
}
else
{
lbitset_elt_free (dtmp);
}
{
lbitset_elt_free (dtmp);
}
}
/* If we have elements of DST left over, free them all. */
@@ -1390,17 +1390,17 @@ debug_lbitset (bitset bset)
{
fprintf (stderr, "Elt %lu\n", (unsigned long int) elt->index);
for (i = 0; i < LBITSET_ELT_WORDS; i++)
{
unsigned int j;
bitset_word word;
{
unsigned int j;
bitset_word word;
word = elt->words[i];
word = elt->words[i];
fprintf (stderr, " Word %u:", i);
for (j = 0; j < LBITSET_WORD_BITS; j++)
if ((word & ((bitset_word) 1 << j)))
fprintf (stderr, " %u", j);
fprintf (stderr, "\n");
}
fprintf (stderr, " Word %u:", i);
for (j = 0; j < LBITSET_WORD_BITS; j++)
if ((word & ((bitset_word) 1 << j)))
fprintf (stderr, " %u", j);
fprintf (stderr, "\n");
}
}
}

View File

@@ -189,8 +189,8 @@ static struct timevar_time_def start_time;
static void get_time (struct timevar_time_def *);
static void timevar_accumulate (struct timevar_time_def *,
struct timevar_time_def *,
struct timevar_time_def *);
struct timevar_time_def *,
struct timevar_time_def *);
/* Fill the current times into TIME. The definition of this function
also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and
@@ -479,20 +479,20 @@ timevar_print (fp)
const float tiny = 5e-3;
/* Don't print the total execution time here; that goes at the
end. */
end. */
if ((timevar_id_t) id == TV_TOTAL)
continue;
continue;
/* Don't print timing variables that were never used. */
if (!tv->used)
continue;
continue;
/* Don't print timing variables if we're going to get a row of
zeroes. */
zeroes. */
if (tv->elapsed.user < tiny
&& tv->elapsed.sys < tiny
&& tv->elapsed.wall < tiny)
continue;
&& tv->elapsed.sys < tiny
&& tv->elapsed.wall < tiny)
continue;
/* The timing variable name. */
fprintf (fp, " %-22s:", tv->name);
@@ -500,22 +500,22 @@ timevar_print (fp)
#ifdef HAVE_USER_TIME
/* Print user-mode time for this process. */
fprintf (fp, "%7.2f (%2.0f%%) usr",
tv->elapsed.user,
(total->user == 0 ? 0 : tv->elapsed.user / total->user) * 100);
tv->elapsed.user,
(total->user == 0 ? 0 : tv->elapsed.user / total->user) * 100);
#endif /* HAVE_USER_TIME */
#ifdef HAVE_SYS_TIME
/* Print system-mode time for this process. */
fprintf (fp, "%7.2f (%2.0f%%) sys",
tv->elapsed.sys,
(total->sys == 0 ? 0 : tv->elapsed.sys / total->sys) * 100);
tv->elapsed.sys,
(total->sys == 0 ? 0 : tv->elapsed.sys / total->sys) * 100);
#endif /* HAVE_SYS_TIME */
#ifdef HAVE_WALL_TIME
/* Print wall clock time elapsed. */
fprintf (fp, "%7.2f (%2.0f%%) wall",
tv->elapsed.wall,
(total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
tv->elapsed.wall,
(total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
#endif /* HAVE_WALL_TIME */
putc ('\n', fp);
@@ -534,7 +534,7 @@ timevar_print (fp)
#endif
#endif /* defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME)
|| defined (HAVE_WALL_TIME) */
|| defined (HAVE_WALL_TIME) */
}
/* Returns time (user + system) used so far by the compiler process,
@@ -558,8 +558,8 @@ print_time (str, total)
{
long all_time = get_run_time ();
fprintf (stderr,
_("time in %s: %ld.%06ld (%ld%%)\n"),
str, total / 1000000, total % 1000000,
all_time == 0 ? 0
: (long) (((100.0 * (double) total) / (double) all_time) + .5));
_("time in %s: %ld.%06ld (%ld%%)\n"),
str, total / 1000000, total % 1000000,
all_time == 0 ? 0
: (long) (((100.0 * (double) total) / (double) all_time) + .5));
}

View File

@@ -38,9 +38,9 @@ static void vbitset_set (bitset, bitset_bindex);
static void vbitset_reset (bitset, bitset_bindex);
static bool vbitset_test (bitset, bitset_bindex);
static bitset_bindex vbitset_list (bitset, bitset_bindex *,
bitset_bindex, bitset_bindex *);
bitset_bindex, bitset_bindex *);
static bitset_bindex vbitset_list_reverse (bitset, bitset_bindex *,
bitset_bindex, bitset_bindex *);
bitset_bindex, bitset_bindex *);
#define VBITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
#define VBITSET_WORDS(X) ((X)->b.cdata)
@@ -69,38 +69,38 @@ vbitset_resize (bitset src, bitset_bindex n_bits)
bitset_windex size;
/* The bitset needs to grow. If we already have enough memory
allocated, then just zero what we need. */
allocated, then just zero what we need. */
if (newsize > VBITSET_ASIZE (src))
{
/* We need to allocate more memory. When oldsize is
non-zero this means that we are changing the size, so
grow the bitset 25% larger than requested to reduce
number of reallocations. */
{
/* We need to allocate more memory. When oldsize is
non-zero this means that we are changing the size, so
grow the bitset 25% larger than requested to reduce
number of reallocations. */
if (oldsize == 0)
size = newsize;
else
size = newsize + newsize / 4;
if (oldsize == 0)
size = newsize;
else
size = newsize + newsize / 4;
VBITSET_WORDS (src)
= realloc (VBITSET_WORDS (src), size * sizeof (bitset_word));
VBITSET_ASIZE (src) = size;
}
VBITSET_WORDS (src)
= realloc (VBITSET_WORDS (src), size * sizeof (bitset_word));
VBITSET_ASIZE (src) = size;
}
memset (VBITSET_WORDS (src) + oldsize, 0,
(newsize - oldsize) * sizeof (bitset_word));
(newsize - oldsize) * sizeof (bitset_word));
VBITSET_SIZE (src) = newsize;
}
else
{
/* The bitset needs to shrink. There's no point deallocating
the memory unless it is shrinking by a reasonable amount. */
the memory unless it is shrinking by a reasonable amount. */
if ((oldsize - newsize) >= oldsize / 2)
{
VBITSET_WORDS (src)
= realloc (VBITSET_WORDS (src), newsize * sizeof (bitset_word));
VBITSET_ASIZE (src) = newsize;
}
{
VBITSET_WORDS (src)
= realloc (VBITSET_WORDS (src), newsize * sizeof (bitset_word));
VBITSET_ASIZE (src) = newsize;
}
/* Need to prune any excess bits. FIXME. */
@@ -196,18 +196,18 @@ vbitset_list_reverse (src, list, num, next)
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
for (; word; bitcnt--)
{
if (word & BITSET_MSB)
{
list[count++] = bitoff + bitcnt;
if (count >= num)
{
*next = n_bits - (bitoff + bitcnt);
return count;
}
}
word <<= 1;
}
{
if (word & BITSET_MSB)
{
list[count++] = bitoff + bitcnt;
if (count >= num)
{
*next = n_bits - (bitoff + bitcnt);
return count;
}
}
word <<= 1;
}
bitoff -= BITSET_WORD_BITS;
bitcnt = BITSET_WORD_BITS - 1;
}
@@ -243,80 +243,80 @@ vbitset_list (src, list, num, next)
{
/* Many bitsets are zero, so make this common case fast. */
for (windex = 0; windex < size && !srcp[windex]; windex++)
continue;
continue;
if (windex >= size)
return 0;
return 0;
/* If num is 1, we could speed things up with a binary search
of the current word. */
of the current word. */
bitoff = windex * BITSET_WORD_BITS;
}
else
{
if (bitno >= BITSET_SIZE_ (src))
return 0;
return 0;
windex = bitno / BITSET_WORD_BITS;
bitno = bitno % BITSET_WORD_BITS;
if (bitno)
{
/* Handle the case where we start within a word.
Most often, this is executed with large bitsets
with many set bits where we filled the array
on the previous call to this function. */
{
/* Handle the case where we start within a word.
Most often, this is executed with large bitsets
with many set bits where we filled the array
on the previous call to this function. */
bitoff = windex * BITSET_WORD_BITS;
word = srcp[windex] >> bitno;
for (bitno = bitoff + bitno; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
windex++;
}
bitoff = windex * BITSET_WORD_BITS;
word = srcp[windex] >> bitno;
for (bitno = bitoff + bitno; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
windex++;
}
bitoff = windex * BITSET_WORD_BITS;
}
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
{
if (!(word = srcp[windex]))
continue;
continue;
if ((count + BITSET_WORD_BITS) < num)
{
for (bitno = bitoff; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
{
for (bitno = bitoff; word; bitno++)
{
if (word & 1)
list[count++] = bitno;
word >>= 1;
}
}
else
{
for (bitno = bitoff; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
}
{
for (bitno = bitoff; word; bitno++)
{
if (word & 1)
{
list[count++] = bitno;
if (count >= num)
{
*next = bitno + 1;
return count;
}
}
word >>= 1;
}
}
}
*next = bitoff;
@@ -398,7 +398,7 @@ vbitset_copy1 (bitset dst, bitset src)
memcpy (dstp, srcp, sizeof (bitset_word) * ssize);
memset (dstp + sizeof (bitset_word) * ssize, 0,
sizeof (bitset_word) * (dsize - ssize));
sizeof (bitset_word) * (dsize - ssize));
}
@@ -423,7 +423,7 @@ vbitset_not (bitset dst, bitset src)
vbitset_unused_clear (dst);
memset (dstp + sizeof (bitset_word) * ssize, 0,
sizeof (bitset_word) * (dsize - ssize));
sizeof (bitset_word) * (dsize - ssize));
}
@@ -438,19 +438,19 @@ vbitset_equal_p (bitset dst, bitset src)
for (i = 0; i < min (ssize, dsize); i++)
if (*srcp++ != *dstp++)
return 0;
return 0;
if (ssize > dsize)
{
for (; i < ssize; i++)
if (*srcp++)
return 0;
if (*srcp++)
return 0;
}
else
{
for (; i < dsize; i++)
if (*dstp++)
return 0;
if (*dstp++)
return 0;
}
return 1;
@@ -468,13 +468,13 @@ vbitset_subset_p (bitset dst, bitset src)
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
if (*dstp != (*srcp | *dstp))
return 0;
return 0;
if (ssize > dsize)
{
for (; i < ssize; i++)
if (*srcp++)
return 0;
if (*srcp++)
return 0;
}
return 1;
@@ -492,7 +492,7 @@ vbitset_disjoint_p (bitset dst, bitset src)
for (i = 0; i < min (ssize, dsize); i++)
if (*srcp++ & *dstp++)
return 0;
return 0;
return 1;
}
@@ -551,10 +551,10 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
bitset_word tmp = *src1p++ & *src2p++;
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
{
changed = 1;
*dstp = tmp;
}
}
if (ssize2 > ssize1)
@@ -566,10 +566,10 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
for (; i < ssize1; i++, dstp++)
{
if (*dstp != 0)
{
changed = 1;
*dstp = 0;
}
{
changed = 1;
*dstp = 0;
}
}
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
@@ -604,14 +604,14 @@ vbitset_andn (bitset dst, bitset src1, bitset src2)
if (ssize2 > ssize1)
{
for (; i < ssize2; i++)
*dstp++ = 0;
*dstp++ = 0;
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
}
else
{
for (; i < ssize1; i++)
*dstp++ = *src1p++;
*dstp++ = *src1p++;
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
}
@@ -644,37 +644,37 @@ vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
bitset_word tmp = *src1p++ & ~(*src2p++);
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
{
changed = 1;
*dstp = tmp;
}
}
if (ssize2 > ssize1)
{
for (; i < ssize2; i++, dstp++)
{
if (*dstp != 0)
{
changed = 1;
*dstp = 0;
}
}
{
if (*dstp != 0)
{
changed = 1;
*dstp = 0;
}
}
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
}
else
{
for (; i < ssize1; i++, dstp++)
{
bitset_word tmp = *src1p++;
{
bitset_word tmp = *src1p++;
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
}
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
}
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
}
@@ -745,10 +745,10 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
bitset_word tmp = *src1p++ | *src2p++;
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
{
changed = 1;
*dstp = tmp;
}
}
if (ssize2 > ssize1)
@@ -762,10 +762,10 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
bitset_word tmp = *src1p++;
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
{
changed = 1;
*dstp = tmp;
}
}
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
@@ -836,10 +836,10 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
bitset_word tmp = *src1p++ ^ *src2p++;
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
{
changed = 1;
*dstp = tmp;
}
}
if (ssize2 > ssize1)
@@ -853,10 +853,10 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
bitset_word tmp = *src1p++;
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
{
changed = 1;
*dstp = tmp;
}
}
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
@@ -926,10 +926,10 @@ vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
{
changed = 1;
*dstp = tmp;
}
}
return changed;
}
@@ -993,10 +993,10 @@ vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
{
changed = 1;
*dstp = tmp;
}
}
return changed;
}
@@ -1060,10 +1060,10 @@ vbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
{
changed = 1;
*dstp = tmp;
}
}
return changed;
}

View File

@@ -21,7 +21,7 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_C_COMPILER], [
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <limits.h>
int test_array[CHAR_BIT];]])],
int test_array[CHAR_BIT];]])],
[],
[AC_MSG_FAILURE([cannot compile a simple C program])])
])

View File

@@ -26,25 +26,25 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_CXX_COMPILER],
bison_cv_cxx_works=no
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
using namespace std;],
[#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
using namespace std;],
[std::cerr << "";
cout << "";
typedef std::pair<unsigned int, int> uipair;
std::map<unsigned int, int> m;
std::map<unsigned int, int>::iterator i;
m.insert (uipair (4, -4));
for (i = m.begin (); i != m.end (); ++i)
if (i->first != 4)
return 1;])],
typedef std::pair<unsigned int, int> uipair;
std::map<unsigned int, int> m;
std::map<unsigned int, int>::iterator i;
m.insert (uipair (4, -4));
for (i = m.begin (); i != m.end (); ++i)
if (i->first != 4)
return 1;])],
[AS_IF([AC_TRY_COMMAND([$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD])],
[AS_IF([test "$cross_compiling" = yes],
[bison_cv_cxx_works=cross],
[AS_IF([AC_TRY_COMMAND(./conftest$ac_exeext)],
[bison_cv_cxx_works=yes])])])
[AS_IF([test "$cross_compiling" = yes],
[bison_cv_cxx_works=cross],
[AS_IF([AC_TRY_COMMAND(./conftest$ac_exeext)],
[bison_cv_cxx_works=yes])])])
rm -f conftest$ac_exeext])
AC_LANG_POP([C++])])

View File

@@ -62,7 +62,7 @@ state_list_append (symbol_number sym, size_t core_size, item_number *core)
if (trace_flag & trace_automaton)
fprintf (stderr, "state_list_append (state = %d, symbol = %d (%s))\n",
nstates, sym, symbols[sym]->tag);
nstates, sym, symbols[sym]->tag);
node->next = NULL;
node->state = s;
@@ -100,13 +100,13 @@ allocate_itemsets (void)
symbols. */
size_t count = 0;
size_t *symbol_count = xcalloc (nsyms + nuseless_nonterminals,
sizeof *symbol_count);
sizeof *symbol_count);
for (r = 0; r < nrules; ++r)
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
{
count++;
symbol_count[*rhsp]++;
count++;
symbol_count[*rhsp]++;
}
/* See comments before new_itemsets. All the vectors of items
@@ -187,15 +187,15 @@ new_itemsets (state *s)
for (i = 0; i < nitemset; ++i)
if (item_number_is_symbol_number (ritem[itemset[i]]))
{
symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
if (!kernel_size[sym])
{
shift_symbol[nshifts] = sym;
nshifts++;
}
symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
if (!kernel_size[sym])
{
shift_symbol[nshifts] = sym;
nshifts++;
}
kernel_base[sym][kernel_size[sym]] = itemset[i] + 1;
kernel_size[sym]++;
kernel_base[sym][kernel_size[sym]] = itemset[i] + 1;
kernel_size[sym]++;
}
}
@@ -214,7 +214,7 @@ get_state (symbol_number sym, size_t core_size, item_number *core)
if (trace_flag & trace_automaton)
fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
sym, symbols[sym]->tag);
sym, symbols[sym]->tag);
s = state_hash_lookup (core_size, core);
if (!s)
@@ -228,7 +228,7 @@ get_state (symbol_number sym, size_t core_size, item_number *core)
/*---------------------------------------------------------------.
| Use the information computed by new_itemsets to find the state |
| numbers reached by each shift transition from S. |
| numbers reached by each shift transition from S. |
| |
| SHIFTSET is set up as a vector of those states. |
`---------------------------------------------------------------*/
@@ -248,7 +248,7 @@ append_states (state *s)
symbol_number sym = shift_symbol[i];
int j;
for (j = i; 0 < j && sym < shift_symbol[j - 1]; j--)
shift_symbol[j] = shift_symbol[j - 1];
shift_symbol[j] = shift_symbol[j - 1];
shift_symbol[j] = sym;
}
@@ -277,16 +277,16 @@ save_reductions (state *s)
{
item_number item = ritem[itemset[i]];
if (item_number_is_rule_number (item))
{
rule_number r = item_number_as_rule_number (item);
redset[count++] = &rules[r];
if (r == 0)
{
/* This is "reduce 0", i.e., accept. */
aver (!final_state);
final_state = s;
}
}
{
rule_number r = item_number_as_rule_number (item);
redset[count++] = &rules[r];
if (r == 0)
{
/* This is "reduce 0", i.e., accept. */
aver (!final_state);
final_state = s;
}
}
}
/* Make a reductions structure and copy the data into it. */
@@ -308,14 +308,14 @@ set_states (void)
state_list *this = first_state;
/* Pessimization, but simplification of the code: make sure all
the states have valid transitions and reductions members,
even if reduced to 0. It is too soon for errs, which are
computed later, but set_conflicts. */
the states have valid transitions and reductions members,
even if reduced to 0. It is too soon for errs, which are
computed later, but set_conflicts. */
state *s = this->state;
if (!s->transitions)
state_transitions_set (s, 0, 0);
state_transitions_set (s, 0, 0);
if (!s->reductions)
state_reductions_set (s, 0, 0);
state_reductions_set (s, 0, 0);
states[s->number] = s;
@@ -349,9 +349,9 @@ generate_states (void)
{
state *s = list->state;
if (trace_flag & trace_automaton)
fprintf (stderr, "Processing state %d (reached by %s)\n",
s->number,
symbols[s->accessing_symbol]->tag);
fprintf (stderr, "Processing state %d (reached by %s)\n",
s->number,
symbols[s->accessing_symbol]->tag);
/* Set up itemset for the transitions out of this state. itemset gets a
vector of all the items that could be accepted next. */
closure (s->items, s->nitems);
@@ -363,7 +363,7 @@ generate_states (void)
append_states (s);
/* Create the shifts structures for the shifts to those states,
now that the state numbers transitioning to are known. */
now that the state numbers transitioning to are known. */
state_transitions_set (s, nshifts, shiftset);
}

View File

@@ -62,7 +62,7 @@ print_closure (char const *title, item_number *array, size_t size)
item_number *rp;
fprintf (stderr, " %2d: .", array[i]);
for (rp = &ritem[array[i]]; *rp >= 0; ++rp)
fprintf (stderr, " %s", symbols[*rp]->tag);
fprintf (stderr, " %s", symbols[*rp]->tag);
fprintf (stderr, " (rule %d)\n", -*rp - 1);
}
fputs ("\n\n", stderr);
@@ -80,10 +80,10 @@ print_firsts (void)
bitset_iterator iter;
fprintf (stderr, "\t%s firsts\n", symbols[i]->tag);
BITSET_FOR_EACH (iter, FIRSTS (i), j, 0)
{
fprintf (stderr, "\t\t%s\n",
symbols[j + ntokens]->tag);
}
{
fprintf (stderr, "\t\t%s\n",
symbols[j + ntokens]->tag);
}
}
fprintf (stderr, "\n\n");
}
@@ -101,10 +101,10 @@ print_fderives (void)
bitset_iterator iter;
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
BITSET_FOR_EACH (iter, FDERIVES (i), r, 0)
{
fprintf (stderr, "\t\t%3d ", r);
rule_rhs_print (&rules[r], stderr);
}
{
fprintf (stderr, "\t\t%3d ", r);
rule_rhs_print (&rules[r], stderr);
}
}
fprintf (stderr, "\n\n");
}
@@ -130,9 +130,9 @@ set_firsts (void)
for (i = ntokens; i < nsyms; i++)
for (j = 0; derives[i - ntokens][j]; ++j)
{
item_number sym = derives[i - ntokens][j]->rhs[0];
if (ISVAR (sym))
bitset_set (FIRSTS (i), sym - ntokens);
item_number sym = derives[i - ntokens][j]->rhs[0];
if (ISVAR (sym))
bitset_set (FIRSTS (i), sym - ntokens);
}
if (trace_flag & trace_sets)
@@ -168,8 +168,8 @@ set_fderives (void)
for (i = ntokens; i < nsyms; ++i)
for (j = ntokens; j < nsyms; ++j)
if (bitset_test (FIRSTS (i), j - ntokens))
for (k = 0; derives[j - ntokens][k]; ++k)
bitset_set (FDERIVES (i), derives[j - ntokens][k]->number);
for (k = 0; derives[j - ntokens][k]; ++k)
bitset_set (FDERIVES (i), derives[j - ntokens][k]->number);
if (trace_flag & trace_sets)
print_fderives ();
@@ -219,11 +219,11 @@ closure (item_number *core, size_t n)
{
item_number itemno = rules[ruleno].rhs - ritem;
while (c < n && core[c] < itemno)
{
itemset[nitemset] = core[c];
nitemset++;
c++;
}
{
itemset[nitemset] = core[c];
nitemset++;
c++;
}
itemset[nitemset] = itemno;
nitemset++;
};

View File

@@ -47,8 +47,8 @@ static unsigned *indent_ptr = 0;
static
void
error_message (location *loc,
const char *prefix,
const char *message, va_list args)
const char *prefix,
const char *message, va_list args)
{
unsigned pos = 0;
@@ -81,12 +81,12 @@ error_message (location *loc,
}
/** Wrap error_message() with varargs handling. */
#define ERROR_MESSAGE(Loc, Prefix, Message) \
{ \
va_list args; \
va_start (args, Message); \
error_message (Loc, Prefix, Message, args); \
va_end (args); \
#define ERROR_MESSAGE(Loc, Prefix, Message) \
{ \
va_list args; \
va_start (args, Message); \
error_message (Loc, Prefix, Message, args); \
va_end (args); \
}

View File

@@ -21,7 +21,7 @@
# include "location.h"
# ifdef __cplusplus
# ifdef __cplusplus
extern "C" {
# endif
@@ -86,7 +86,7 @@ void fatal_at (location loc, char const *format, ...)
/** Whether an error was reported. */
extern bool complaint_issued;
# ifdef __cplusplus
# ifdef __cplusplus
}
# endif

View File

@@ -64,75 +64,75 @@ enum conflict_resolution
static inline void
log_resolution (rule *r, symbol_number token,
enum conflict_resolution resolution)
enum conflict_resolution resolution)
{
if (report_flag & report_solved_conflicts)
{
/* The description of the resolution. */
switch (resolution)
{
case shift_resolution:
case right_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
_(" Conflict between rule %d and token %s"
" resolved as shift"),
r->number,
symbols[token]->tag);
break;
{
case shift_resolution:
case right_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
_(" Conflict between rule %d and token %s"
" resolved as shift"),
r->number,
symbols[token]->tag);
break;
case reduce_resolution:
case left_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
_(" Conflict between rule %d and token %s"
" resolved as reduce"),
r->number,
symbols[token]->tag);
break;
case reduce_resolution:
case left_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
_(" Conflict between rule %d and token %s"
" resolved as reduce"),
r->number,
symbols[token]->tag);
break;
case nonassoc_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
_(" Conflict between rule %d and token %s"
" resolved as an error"),
r->number,
symbols[token]->tag);
break;
}
case nonassoc_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
_(" Conflict between rule %d and token %s"
" resolved as an error"),
r->number,
symbols[token]->tag);
break;
}
/* The reason. */
switch (resolution)
{
case shift_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
" (%s < %s)",
r->prec->tag,
symbols[token]->tag);
break;
{
case shift_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
" (%s < %s)",
r->prec->tag,
symbols[token]->tag);
break;
case reduce_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
" (%s < %s)",
symbols[token]->tag,
r->prec->tag);
break;
case reduce_resolution:
obstack_fgrow2 (&solved_conflicts_obstack,
" (%s < %s)",
symbols[token]->tag,
r->prec->tag);
break;
case left_resolution:
obstack_fgrow1 (&solved_conflicts_obstack,
" (%%left %s)",
symbols[token]->tag);
break;
case left_resolution:
obstack_fgrow1 (&solved_conflicts_obstack,
" (%%left %s)",
symbols[token]->tag);
break;
case right_resolution:
obstack_fgrow1 (&solved_conflicts_obstack,
" (%%right %s)",
symbols[token]->tag);
break;
case right_resolution:
obstack_fgrow1 (&solved_conflicts_obstack,
" (%%right %s)",
symbols[token]->tag);
break;
case nonassoc_resolution:
obstack_fgrow1 (&solved_conflicts_obstack,
" (%%nonassoc %s)",
symbols[token]->tag);
break;
}
case nonassoc_resolution:
obstack_fgrow1 (&solved_conflicts_obstack,
" (%%nonassoc %s)",
symbols[token]->tag);
break;
}
obstack_sgrow (&solved_conflicts_obstack, ".\n");
}
@@ -226,7 +226,7 @@ flush_shift (state *s, int token)
bitset_reset (lookahead_set, token);
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
&& TRANSITION_SYMBOL (trans, i) == token)
&& TRANSITION_SYMBOL (trans, i) == token)
TRANSITION_DISABLE (trans, i);
}
@@ -268,23 +268,23 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors, int *nerrs)
for (i = 0; i < ntokens; i++)
if (bitset_test (lookahead_tokens, i)
&& bitset_test (lookahead_set, i)
&& symbols[i]->prec)
&& bitset_test (lookahead_set, i)
&& symbols[i]->prec)
{
/* Shift-reduce conflict occurs for token number i
and it has a precedence.
The precedence of shifting is that of token i. */
if (symbols[i]->prec < redprec)
{
log_resolution (redrule, i, reduce_resolution);
flush_shift (s, i);
}
else if (symbols[i]->prec > redprec)
{
log_resolution (redrule, i, shift_resolution);
flush_reduce (lookahead_tokens, i);
}
else
/* Shift-reduce conflict occurs for token number i
and it has a precedence.
The precedence of shifting is that of token i. */
if (symbols[i]->prec < redprec)
{
log_resolution (redrule, i, reduce_resolution);
flush_shift (s, i);
}
else if (symbols[i]->prec > redprec)
{
log_resolution (redrule, i, shift_resolution);
flush_reduce (lookahead_tokens, i);
}
else
/* Matching precedence levels.
For non-defined associativity, keep both: unexpected
associativity conflict.
@@ -292,32 +292,32 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors, int *nerrs)
For right associativity, keep only the shift.
For nonassociativity, keep neither. */
switch (symbols[i]->assoc)
{
switch (symbols[i]->assoc)
{
case undef_assoc:
abort ();
abort ();
case precedence_assoc:
break;
case right_assoc:
log_resolution (redrule, i, right_resolution);
flush_reduce (lookahead_tokens, i);
break;
case right_assoc:
log_resolution (redrule, i, right_resolution);
flush_reduce (lookahead_tokens, i);
break;
case left_assoc:
log_resolution (redrule, i, left_resolution);
flush_shift (s, i);
break;
case left_assoc:
log_resolution (redrule, i, left_resolution);
flush_shift (s, i);
break;
case non_assoc:
log_resolution (redrule, i, nonassoc_resolution);
flush_shift (s, i);
flush_reduce (lookahead_tokens, i);
/* Record an explicit error for this token. */
errors[(*nerrs)++] = symbols[i];
break;
}
case non_assoc:
log_resolution (redrule, i, nonassoc_resolution);
flush_shift (s, i);
flush_reduce (lookahead_tokens, i);
/* Record an explicit error for this token. */
errors[(*nerrs)++] = symbols[i];
break;
}
}
}
@@ -350,7 +350,7 @@ set_conflicts (state *s, symbol **errors)
precedence. */
for (i = 0; i < reds->num; ++i)
if (reds->rules[i]->prec && reds->rules[i]->prec->prec
&& !bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set))
&& !bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set))
resolve_sr_conflict (s, i, errors, &nerrs);
if (nerrs)
@@ -375,7 +375,7 @@ set_conflicts (state *s, symbol **errors)
for (i = 0; i < reds->num; ++i)
{
if (!bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set))
conflicts[s->number] = 1;
conflicts[s->number] = 1;
bitset_or (lookahead_set, lookahead_set, reds->lookahead_tokens[i]);
}
}
@@ -404,9 +404,9 @@ conflicts_solve (void)
set_conflicts (states[i], errors);
/* For uniformity of the code, make sure all the states have a valid
`errs' member. */
`errs' member. */
if (!states[i]->errs)
states[i]->errs = errs_new (0, 0);
states[i]->errs = errs_new (0, 0);
}
free (errors);
@@ -475,11 +475,11 @@ count_rr_conflicts (state *s, bool one_per_token)
int count = 0;
int j;
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookahead_tokens[j], i))
count++;
if (bitset_test (reds->lookahead_tokens[j], i))
count++;
if (count >= 2)
rrc_count += one_per_token ? 1 : count-1;
rrc_count += one_per_token ? 1 : count-1;
}
return rrc_count;
@@ -495,7 +495,7 @@ conflict_report (FILE *out, int src_num, int rrc_num)
{
if (src_num && rrc_num)
fprintf (out, _("conflicts: %d shift/reduce, %d reduce/reduce\n"),
src_num, rrc_num);
src_num, rrc_num);
else if (src_num)
fprintf (out, _("conflicts: %d shift/reduce\n"), src_num);
else if (rrc_num)
@@ -516,12 +516,12 @@ conflicts_output (FILE *out)
{
state *s = states[i];
if (conflicts[i])
{
fprintf (out, _("State %d "), i);
conflict_report (out, count_sr_conflicts (s),
count_rr_conflicts (s, true));
printed_sth = true;
}
{
fprintf (out, _("State %d "), i);
conflict_report (out, count_sr_conflicts (s),
count_rr_conflicts (s, true));
printed_sth = true;
}
}
if (printed_sth)
fputs ("\n\n", out);
@@ -531,7 +531,7 @@ conflicts_output (FILE *out)
| Total the number of S/R and R/R conflicts. Unlike the |
| code in conflicts_output, however, count EACH pair of |
| reductions for the same state and lookahead as one |
| conflict. |
| conflict. |
`--------------------------------------------------------*/
int
@@ -545,8 +545,8 @@ conflicts_total_count (void)
for (i = 0; i < nstates; i++)
if (conflicts[i])
{
count += count_sr_conflicts (states[i]);
count += count_rr_conflicts (states[i], false);
count += count_sr_conflicts (states[i]);
count += count_rr_conflicts (states[i], false);
}
return count;
}
@@ -576,10 +576,10 @@ conflicts_print (void)
for (i = 0; i < nstates; i++)
if (conflicts[i])
{
src_total += count_sr_conflicts (states[i]);
rrc_total += count_rr_conflicts (states[i], true);
}
{
src_total += count_sr_conflicts (states[i]);
rrc_total += count_rr_conflicts (states[i], true);
}
}
if (! glr_parser && rrc_total > 0 && expected_rr_conflicts != -1)
@@ -611,22 +611,22 @@ conflicts_print (void)
if (expected_sr_conflicts == -1 && expected_rr_conflicts == -1)
set_warning_issued ();
if (! yacc_flag)
fprintf (stderr, "%s: ", current_file);
fprintf (stderr, "%s: ", current_file);
conflict_report (stderr, src_total, rrc_total);
}
if (expected_sr_conflicts != -1 || expected_rr_conflicts != -1)
{
if (! src_ok)
complain (ngettext ("expected %d shift/reduce conflict",
"expected %d shift/reduce conflicts",
src_expected),
src_expected);
complain (ngettext ("expected %d shift/reduce conflict",
"expected %d shift/reduce conflicts",
src_expected),
src_expected);
if (! rrc_ok)
complain (ngettext ("expected %d reduce/reduce conflict",
"expected %d reduce/reduce conflicts",
rrc_expected),
rrc_expected);
complain (ngettext ("expected %d reduce/reduce conflict",
"expected %d reduce/reduce conflicts",
rrc_expected),
rrc_expected);
}
}

View File

@@ -49,10 +49,10 @@ print_derives (void)
rule **rp;
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
for (rp = derives[i - ntokens]; *rp; ++rp)
{
fprintf (stderr, "\t\t%3d ", (*rp)->user_number);
rule_rhs_print (*rp, stderr);
}
{
fprintf (stderr, "\t\t%3d ", (*rp)->user_number);
rule_rhs_print (*rp, stderr);
}
}
fputs ("\n\n", stderr);
@@ -96,10 +96,10 @@ derives_compute (void)
rule_list *p = dset[i - ntokens];
derives[i - ntokens] = q;
while (p)
{
*q++ = p->value;
p = p->next;
}
{
*q++ = p->value;
p = p->next;
}
*q++ = NULL;
}

View File

@@ -200,7 +200,7 @@ compute_exts_from_src (const char *ext)
static void
file_name_split (const char *file_name,
const char **base, const char **tab, const char **ext)
const char **base, const char **tab, const char **ext)
{
*base = last_component (file_name);
@@ -215,9 +215,9 @@ file_name_split (const char *file_name,
size_t baselen = *ext - *base;
size_t dottablen = 4;
if (dottablen < baselen
&& (strncmp (*ext - dottablen, ".tab", dottablen) == 0
|| strncmp (*ext - dottablen, "_tab", dottablen) == 0))
*tab = *ext - dottablen;
&& (strncmp (*ext - dottablen, ".tab", dottablen) == 0
|| strncmp (*ext - dottablen, "_tab", dottablen) == 0))
*tab = *ext - dottablen;
}
}
@@ -239,44 +239,44 @@ compute_file_name_parts (void)
/* ALL_BUT_EXT goes up the EXT, excluding it. */
all_but_ext =
xstrndup (spec_outfile,
(strlen (spec_outfile) - (ext ? strlen (ext) : 0)));
xstrndup (spec_outfile,
(strlen (spec_outfile) - (ext ? strlen (ext) : 0)));
/* ALL_BUT_TAB_EXT goes up to TAB, excluding it. */
all_but_tab_ext =
xstrndup (spec_outfile,
(strlen (spec_outfile)
- (tab ? strlen (tab) : (ext ? strlen (ext) : 0))));
xstrndup (spec_outfile,
(strlen (spec_outfile)
- (tab ? strlen (tab) : (ext ? strlen (ext) : 0))));
if (ext)
compute_exts_from_src (ext);
compute_exts_from_src (ext);
}
else
{
file_name_split (grammar_file, &base, &tab, &ext);
if (spec_file_prefix)
{
/* If --file-prefix=foo was specified, ALL_BUT_TAB_EXT = `foo'. */
dir_prefix =
{
/* If --file-prefix=foo was specified, ALL_BUT_TAB_EXT = `foo'. */
dir_prefix =
xstrndup (spec_file_prefix,
last_component (spec_file_prefix) - spec_file_prefix);
all_but_tab_ext = xstrdup (spec_file_prefix);
}
all_but_tab_ext = xstrdup (spec_file_prefix);
}
else if (yacc_flag)
{
/* If --yacc, then the output is `y.tab.c'. */
dir_prefix = xstrdup ("");
all_but_tab_ext = xstrdup ("y");
}
{
/* If --yacc, then the output is `y.tab.c'. */
dir_prefix = xstrdup ("");
all_but_tab_ext = xstrdup ("y");
}
else
{
/* Otherwise, ALL_BUT_TAB_EXT is computed from the input
grammar: `foo/bar.yy' => `bar'. */
dir_prefix = xstrdup ("");
all_but_tab_ext =
xstrndup (base, (strlen (base) - (ext ? strlen (ext) : 0)));
}
{
/* Otherwise, ALL_BUT_TAB_EXT is computed from the input
grammar: `foo/bar.yy' => `bar'. */
dir_prefix = xstrdup ("");
all_but_tab_ext =
xstrndup (base, (strlen (base) - (ext ? strlen (ext) : 0)));
}
if (language->add_tab)
all_but_ext = concat2 (all_but_tab_ext, TAB_EXT);
@@ -285,7 +285,7 @@ compute_file_name_parts (void)
/* Compute the extensions from the grammar file name. */
if (ext && !yacc_flag)
compute_exts_from_gf (ext);
compute_exts_from_gf (ext);
}
}
@@ -312,20 +312,20 @@ compute_output_file_names (void)
if (defines_flag)
{
if (! spec_defines_file)
spec_defines_file = concat2 (all_but_ext, header_extension);
spec_defines_file = concat2 (all_but_ext, header_extension);
}
if (graph_flag)
{
if (! spec_graph_file)
spec_graph_file = concat2 (all_but_tab_ext, ".dot");
spec_graph_file = concat2 (all_but_tab_ext, ".dot");
output_file_name_check (&spec_graph_file);
}
if (xml_flag)
{
if (! spec_xml_file)
spec_xml_file = concat2 (all_but_tab_ext, ".xml");
spec_xml_file = concat2 (all_but_tab_ext, ".xml");
output_file_name_check (&spec_xml_file);
}

View File

@@ -76,10 +76,10 @@ static struct obstack obstack_for_string;
#define STRING_GROW \
obstack_grow (&obstack_for_string, yytext, yyleng)
#define STRING_FINISH \
do { \
obstack_1grow (&obstack_for_string, '\0'); \
last_string = obstack_finish (&obstack_for_string); \
#define STRING_FINISH \
do { \
obstack_1grow (&obstack_for_string, '\0'); \
last_string = obstack_finish (&obstack_for_string); \
} while (0)
#define STRING_FREE \

View File

@@ -52,7 +52,7 @@ bool graph_flag;
bool xml_flag;
bool no_lines_flag;
bool token_table_flag;
bool yacc_flag; /* for -y */
bool yacc_flag; /* for -y */
bool nondeterministic_parser = false;
bool glr_parser = false;
@@ -94,32 +94,32 @@ char *program_name;
*/
static void
flags_argmatch (const char *option,
const char * const keys[], const int values[],
int all, int *flags, char *args)
const char * const keys[], const int values[],
int all, int *flags, char *args)
{
if (args)
{
args = strtok (args, ",");
while (args)
{
int no = strncmp (args, "no-", 3) == 0 ? 3 : 0;
int value = XARGMATCH (option, args + no, keys, values);
if (value == 0)
{
if (no)
*flags |= all;
else
*flags &= ~all;
}
else
{
if (no)
*flags &= ~value;
else
*flags |= value;
}
args = strtok (NULL, ",");
}
{
int no = strncmp (args, "no-", 3) == 0 ? 3 : 0;
int value = XARGMATCH (option, args + no, keys, values);
if (value == 0)
{
if (no)
*flags |= all;
else
*flags &= ~all;
}
else
{
if (no)
*flags &= ~value;
else
*flags |= value;
}
args = strtok (NULL, ",");
}
}
else
*flags |= all;
@@ -135,9 +135,9 @@ flags_argmatch (const char *option,
* \arg FlagName_all the all value.
* \arg FlagName_flag the flag to update.
*/
#define FLAGS_ARGMATCH(FlagName, Args) \
#define FLAGS_ARGMATCH(FlagName, Args) \
flags_argmatch ("--" #FlagName, FlagName ## _args, FlagName ## _types, \
FlagName ## _all, &FlagName ## _flag, Args)
FlagName ## _all, &FlagName ## _flag, Args)
/*----------------------.
@@ -265,13 +265,13 @@ usage (int status)
{
if (status != 0)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
program_name);
else
{
/* For ../build-aux/cross-options.pl to work, use the format:
^ -S, --long[=ARGS] (whitespace)
A --long option is required.
Otherwise, add exceptions to ../build-aux/cross-options.pl. */
^ -S, --long[=ARGS] (whitespace)
A --long option is required.
Otherwise, add exceptions to ../build-aux/cross-options.pl. */
printf (_("Usage: %s [OPTION]... FILE\n"), program_name);
fputs (_("\
@@ -379,14 +379,14 @@ version (void)
putc ('\n', stdout);
fprintf (stdout,
_("Copyright (C) %d Free Software Foundation, Inc.\n"),
PACKAGE_COPYRIGHT_YEAR);
_("Copyright (C) %d Free Software Foundation, Inc.\n"),
PACKAGE_COPYRIGHT_YEAR);
fputs (_("\
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"),
stdout);
stdout);
}
@@ -415,12 +415,12 @@ language_argmatch (char const *arg, int prio, location loc)
{
int i;
for (i = 0; valid_languages[i].language[0]; i++)
if (c_strcasecmp (arg, valid_languages[i].language) == 0)
{
language_prio = prio;
language = &valid_languages[i];
return;
}
if (c_strcasecmp (arg, valid_languages[i].language) == 0)
{
language_prio = prio;
language = &valid_languages[i];
return;
}
msg = _("invalid language `%s'");
}
else if (language_prio == prio)
@@ -474,25 +474,25 @@ enum
static struct option const long_options[] =
{
/* Operation modes. */
{ "help", no_argument, 0, 'h' },
{ "version", no_argument, 0, 'V' },
{ "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION },
{ "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION },
{ "help", no_argument, 0, 'h' },
{ "version", no_argument, 0, 'V' },
{ "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION },
{ "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION },
{ "warnings", optional_argument, 0, 'W' },
/* Parser. */
{ "name-prefix", required_argument, 0, 'p' },
{ "name-prefix", required_argument, 0, 'p' },
{ "include", required_argument, 0, 'I' },
/* Output. */
{ "file-prefix", required_argument, 0, 'b' },
{ "output", required_argument, 0, 'o' },
{ "output-file", required_argument, 0, 'o' },
{ "graph", optional_argument, 0, 'g' },
{ "file-prefix", required_argument, 0, 'b' },
{ "output", required_argument, 0, 'o' },
{ "output-file", required_argument, 0, 'o' },
{ "graph", optional_argument, 0, 'g' },
{ "xml", optional_argument, 0, 'x' },
{ "report", required_argument, 0, 'r' },
{ "report", required_argument, 0, 'r' },
{ "report-file", required_argument, 0, REPORT_FILE_OPTION },
{ "verbose", no_argument, 0, 'v' },
{ "verbose", no_argument, 0, 'v' },
/* Hidden. */
{ "trace", optional_argument, 0, 'T' },
@@ -502,13 +502,13 @@ static struct option const long_options[] =
/* Operation modes. */
{ "fixed-output-files", no_argument, 0, 'y' },
{ "yacc", no_argument, 0, 'y' },
{ "yacc", no_argument, 0, 'y' },
/* Parser. */
{ "debug", no_argument, 0, 't' },
{ "define", required_argument, 0, 'D' },
{ "debug", no_argument, 0, 't' },
{ "define", required_argument, 0, 'D' },
{ "force-define", required_argument, 0, 'F' },
{ "locations", no_argument, 0, LOCATIONS_OPTION },
{ "locations", no_argument, 0, LOCATIONS_OPTION },
{ "no-lines", no_argument, 0, 'l' },
{ "raw", no_argument, 0, 0 },
{ "skeleton", required_argument, 0, 'S' },
@@ -545,15 +545,15 @@ getargs (int argc, char *argv[])
int c;
while ((c = getopt_long (argc, argv, short_options, long_options, NULL))
!= -1)
!= -1)
switch (c)
{
/* ASCII Sorting for short options (i.e., upper case then
lower case), and then long-only options. */
case 0:
/* Certain long options cause getopt_long to return 0. */
break;
/* Certain long options cause getopt_long to return 0. */
break;
case 'D': /* -DNAME[=VALUE]. */
case 'F': /* -FNAME[=VALUE]. */
@@ -567,37 +567,37 @@ getargs (int argc, char *argv[])
c == 'D' ? MUSCLE_PERCENT_DEFINE_D
: MUSCLE_PERCENT_DEFINE_F);
}
break;
break;
case 'I':
include = AS_FILE_NAME (optarg);
break;
include = AS_FILE_NAME (optarg);
break;
case 'L':
language_argmatch (optarg, command_line_prio,
command_line_location ());
break;
language_argmatch (optarg, command_line_prio,
command_line_location ());
break;
case 'S':
skeleton_arg (AS_FILE_NAME (optarg), command_line_prio,
command_line_location ());
break;
skeleton_arg (AS_FILE_NAME (optarg), command_line_prio,
command_line_location ());
break;
case 'T':
FLAGS_ARGMATCH (trace, optarg);
break;
FLAGS_ARGMATCH (trace, optarg);
break;
case 'V':
version ();
exit (EXIT_SUCCESS);
version ();
exit (EXIT_SUCCESS);
case 'W':
FLAGS_ARGMATCH (warnings, optarg);
break;
FLAGS_ARGMATCH (warnings, optarg);
break;
case 'b':
spec_file_prefix = AS_FILE_NAME (optarg);
break;
spec_file_prefix = AS_FILE_NAME (optarg);
break;
case 'd':
/* Here, the -d and --defines options are differentiated. */
@@ -607,81 +607,81 @@ getargs (int argc, char *argv[])
break;
case 'g':
graph_flag = true;
if (optarg)
spec_graph_file = xstrdup (AS_FILE_NAME (optarg));
break;
graph_flag = true;
if (optarg)
spec_graph_file = xstrdup (AS_FILE_NAME (optarg));
break;
case 'h':
usage (EXIT_SUCCESS);
usage (EXIT_SUCCESS);
case 'k':
token_table_flag = true;
break;
token_table_flag = true;
break;
case 'l':
no_lines_flag = true;
break;
no_lines_flag = true;
break;
case 'o':
spec_outfile = AS_FILE_NAME (optarg);
break;
spec_outfile = AS_FILE_NAME (optarg);
break;
case 'p':
spec_name_prefix = optarg;
break;
spec_name_prefix = optarg;
break;
case 'r':
FLAGS_ARGMATCH (report, optarg);
break;
FLAGS_ARGMATCH (report, optarg);
break;
case 't':
muscle_percent_define_insert ("parse.trace",
command_line_location (), "",
MUSCLE_PERCENT_DEFINE_D);
break;
break;
case 'v':
report_flag |= report_states;
break;
report_flag |= report_states;
break;
case 'x':
xml_flag = true;
if (optarg)
spec_xml_file = xstrdup (AS_FILE_NAME (optarg));
break;
xml_flag = true;
if (optarg)
spec_xml_file = xstrdup (AS_FILE_NAME (optarg));
break;
case 'y':
yacc_flag = true;
break;
yacc_flag = true;
break;
case LOCATIONS_OPTION:
muscle_percent_define_ensure ("locations",
command_line_location (), true);
break;
break;
case PRINT_LOCALEDIR_OPTION:
printf ("%s\n", LOCALEDIR);
exit (EXIT_SUCCESS);
printf ("%s\n", LOCALEDIR);
exit (EXIT_SUCCESS);
case PRINT_DATADIR_OPTION:
printf ("%s\n", compute_pkgdatadir ());
exit (EXIT_SUCCESS);
printf ("%s\n", compute_pkgdatadir ());
exit (EXIT_SUCCESS);
case REPORT_FILE_OPTION:
spec_verbose_file = xstrdup (AS_FILE_NAME (optarg));
break;
spec_verbose_file = xstrdup (AS_FILE_NAME (optarg));
break;
default:
usage (EXIT_FAILURE);
usage (EXIT_FAILURE);
}
if (argc - optind != 1)
{
if (argc - optind < 1)
error (0, 0, _("missing operand after `%s'"), argv[argc - 1]);
error (0, 0, _("missing operand after `%s'"), argv[argc - 1]);
else
error (0, 0, _("extra operand `%s'"), argv[optind + 1]);
error (0, 0, _("extra operand `%s'"), argv[optind + 1]);
usage (EXIT_FAILURE);
}

View File

@@ -35,12 +35,12 @@ extern int skeleton_prio;
/* for -I */
extern char const *include;
extern bool defines_flag; /* for -d */
extern bool graph_flag; /* for -g */
extern bool xml_flag; /* for -x */
extern bool no_lines_flag; /* for -l */
extern bool token_table_flag; /* for -k */
extern bool yacc_flag; /* for -y */
extern bool defines_flag; /* for -d */
extern bool graph_flag; /* for -g */
extern bool xml_flag; /* for -x */
extern bool no_lines_flag; /* for -l */
extern bool token_table_flag; /* for -k */
extern bool yacc_flag; /* for -y */
/* GLR_PARSER is true if the input file says to use the GLR

View File

@@ -78,7 +78,7 @@ rule_lhs_print (rule *r, symbol *previous_lhs, FILE *out)
{
int n;
for (n = strlen (previous_lhs->tag); n > 0; --n)
fputc (' ', out);
fputc (' ', out);
fputc ('|', out);
}
}
@@ -106,7 +106,7 @@ rule_rhs_print (rule *r, FILE *out)
{
item_number *rp;
for (rp = r->rhs; *rp >= 0; rp++)
fprintf (out, " %s", symbols[*rp]->tag);
fprintf (out, " %s", symbols[*rp]->tag);
fputc ('\n', out);
}
else
@@ -123,8 +123,8 @@ rule_rhs_print_xml (rule *r, FILE *out, int level)
item_number *rp;
xml_puts (out, level, "<rhs>");
for (rp = r->rhs; *rp >= 0; rp++)
xml_printf (out, level + 1, "<symbol>%s</symbol>",
xml_escape (symbols[*rp]->tag));
xml_printf (out, level + 1, "<symbol>%s</symbol>",
xml_escape (symbols[*rp]->tag));
xml_puts (out, level, "</rhs>");
}
else
@@ -165,7 +165,7 @@ ritem_longest_rhs (void)
{
int length = rule_rhs_length (&rules[r]);
if (length > max)
max = length;
max = length;
}
return max;
@@ -173,7 +173,7 @@ ritem_longest_rhs (void)
void
grammar_rules_partial_print (FILE *out, const char *title,
rule_filter filter)
rule_filter filter)
{
rule_number r;
bool first = true;
@@ -183,11 +183,11 @@ grammar_rules_partial_print (FILE *out, const char *title,
for (r = 0; r < nrules + nuseless_productions; r++)
{
if (filter && !filter (&rules[r]))
continue;
continue;
if (first)
fprintf (out, "%s\n\n", title);
fprintf (out, "%s\n\n", title);
else if (previous_lhs && previous_lhs != rules[r].lhs)
fputc ('\n', out);
fputc ('\n', out);
first = false;
rule_lhs_print (&rules[r], previous_lhs, out);
rule_rhs_print (&rules[r], out);
@@ -212,7 +212,7 @@ grammar_rules_print_xml (FILE *out, int level)
for (r = 0; r < nrules + nuseless_productions; r++)
{
if (first)
xml_puts (out, level + 1, "<rules>");
xml_puts (out, level + 1, "<rules>");
first = false;
{
char const *usefulness;
@@ -245,8 +245,8 @@ grammar_dump (FILE *out, const char *title)
{
fprintf (out, "%s\n\n", title);
fprintf (out,
"ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
ntokens, nvars, nsyms, nrules, nritems);
"ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
ntokens, nvars, nsyms, nrules, nritems);
fprintf (out, "Variables\n---------\n\n");
@@ -256,9 +256,9 @@ grammar_dump (FILE *out, const char *title)
for (i = ntokens; i < nsyms; i++)
fprintf (out, "%5d %5d %5d %s\n",
i,
symbols[i]->prec, symbols[i]->assoc,
symbols[i]->tag);
i,
symbols[i]->prec, symbols[i]->assoc,
symbols[i]->tag);
fprintf (out, "\n\n");
}
@@ -268,25 +268,25 @@ grammar_dump (FILE *out, const char *title)
fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n");
for (i = 0; i < nrules + nuseless_productions; i++)
{
rule *rule_i = &rules[i];
item_number *rp = NULL;
unsigned int rhs_itemno = rule_i->rhs - ritem;
unsigned int rhs_count = 0;
/* Find the last RHS index in ritems. */
for (rp = rule_i->rhs; *rp >= 0; ++rp)
++rhs_count;
fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
i,
rule_i->prec ? rule_i->prec->prec : 0,
rule_i->prec ? rule_i->prec->assoc : 0,
rule_i->useful,
rhs_itemno,
rhs_itemno + rhs_count - 1,
rule_i->lhs->number);
/* Dumped the RHS. */
for (rp = rule_i->rhs; *rp >= 0; rp++)
fprintf (out, " %3d", *rp);
fprintf (out, " [%d]\n", item_number_as_rule_number (*rp));
rule *rule_i = &rules[i];
item_number *rp = NULL;
unsigned int rhs_itemno = rule_i->rhs - ritem;
unsigned int rhs_count = 0;
/* Find the last RHS index in ritems. */
for (rp = rule_i->rhs; *rp >= 0; ++rp)
++rhs_count;
fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
i,
rule_i->prec ? rule_i->prec->prec : 0,
rule_i->prec ? rule_i->prec->assoc : 0,
rule_i->useful,
rhs_itemno,
rhs_itemno + rhs_count - 1,
rule_i->lhs->number);
/* Dumped the RHS. */
for (rp = rule_i->rhs; *rp >= 0; rp++)
fprintf (out, " %3d", *rp);
fprintf (out, " [%d]\n", item_number_as_rule_number (*rp));
}
}
fprintf (out, "\n\n");
@@ -296,8 +296,8 @@ grammar_dump (FILE *out, const char *title)
rule_number r;
for (r = 0; r < nrules + nuseless_productions; r++)
{
fprintf (out, "%-5d ", r);
rule_print (&rules[r], out);
fprintf (out, "%-5d ", r);
rule_print (&rules[r], out);
}
}
fprintf (out, "\n\n");

View File

@@ -105,8 +105,8 @@
# include "location.h"
# include "symtab.h"
# define ISTOKEN(i) ((i) < ntokens)
# define ISVAR(i) ((i) >= ntokens)
# define ISTOKEN(i) ((i) < ntokens)
# define ISVAR(i) ((i) >= ntokens)
extern int nsyms;
extern int ntokens;
@@ -254,7 +254,7 @@ size_t ritem_longest_rhs (void);
/* Print the grammar's rules that match FILTER on OUT under TITLE. */
void grammar_rules_partial_print (FILE *out, const char *title,
rule_filter filter);
rule_filter filter);
/* Print the grammar's useful rules on OUT. */
void grammar_rules_print (FILE *out);

View File

@@ -61,7 +61,7 @@ output_node (int id, char const *label, FILE *fout)
void
output_edge (int source, int destination, char const *label,
char const *style, FILE *fout)
char const *style, FILE *fout)
{
fprintf (fout, " %d -> %d [style=%s", source, destination, style);
if (label)

View File

@@ -40,7 +40,7 @@ void output_node (int id, char const *label, FILE *fout);
/// \param style Dot style of the edge (e.g., "dotted" or "solid").
/// \param fout output stream.
void output_edge (int source, int destination, char const *label,
char const *style, FILE *fout);
char const *style, FILE *fout);
/// End a Dot graph.
/// \param fout output stream.

View File

@@ -85,14 +85,14 @@ set_goto_map (void)
transitions *sp = states[s]->transitions;
int i;
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
{
ngotos++;
{
ngotos++;
/* Abort if (ngotos + 1) would overflow. */
aver (ngotos != GOTO_NUMBER_MAXIMUM);
/* Abort if (ngotos + 1) would overflow. */
aver (ngotos != GOTO_NUMBER_MAXIMUM);
goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
}
goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
}
}
{
@@ -100,8 +100,8 @@ set_goto_map (void)
int i;
for (i = ntokens; i < nsyms; i++)
{
temp_map[i - ntokens] = k;
k += goto_map[i - ntokens];
temp_map[i - ntokens] = k;
k += goto_map[i - ntokens];
}
for (i = ntokens; i < nsyms; i++)
@@ -119,11 +119,11 @@ set_goto_map (void)
transitions *sp = states[s]->transitions;
int i;
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
{
goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
from_state[k] = s;
to_state[k] = sp->states[i]->number;
}
{
goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
from_state[k] = s;
to_state[k] = sp->states[i]->number;
}
}
free (temp_map);
@@ -147,11 +147,11 @@ map_goto (state_number s0, symbol_number sym)
middle = (low + high) / 2;
s = from_state[middle];
if (s == s0)
return middle;
return middle;
else if (s < s0)
low = middle + 1;
low = middle + 1;
else
high = middle - 1;
high = middle - 1;
}
}
@@ -174,24 +174,24 @@ initialize_F (void)
int j;
FOR_EACH_SHIFT (sp, j)
bitset_set (goto_follows[i], TRANSITION_SYMBOL (sp, j));
bitset_set (goto_follows[i], TRANSITION_SYMBOL (sp, j));
for (; j < sp->num; j++)
{
symbol_number sym = TRANSITION_SYMBOL (sp, j);
if (nullable[sym - ntokens])
edge[nedges++] = map_goto (stateno, sym);
}
{
symbol_number sym = TRANSITION_SYMBOL (sp, j);
if (nullable[sym - ntokens])
edge[nedges++] = map_goto (stateno, sym);
}
if (nedges == 0)
reads[i] = NULL;
reads[i] = NULL;
else
{
reads[i] = xnmalloc (nedges + 1, sizeof reads[i][0]);
memcpy (reads[i], edge, nedges * sizeof edge[0]);
reads[i][nedges] = END_NODE;
nedges = 0;
}
{
reads[i] = xnmalloc (nedges + 1, sizeof reads[i][0]);
memcpy (reads[i], edge, nedges * sizeof edge[0]);
reads[i][nedges] = END_NODE;
nedges = 0;
}
}
relation_digraph (reads, ngotos, &goto_follows);
@@ -232,53 +232,53 @@ build_relations (void)
rule **rulep;
for (rulep = derives[symbol1 - ntokens]; *rulep; rulep++)
{
bool done;
int length = 1;
item_number const *rp;
state *s = states[from_state[i]];
states1[0] = s->number;
{
bool done;
int length = 1;
item_number const *rp;
state *s = states[from_state[i]];
states1[0] = s->number;
for (rp = (*rulep)->rhs; ! item_number_is_rule_number (*rp); rp++)
{
s = transitions_to (s->transitions,
item_number_as_symbol_number (*rp));
states1[length++] = s->number;
}
for (rp = (*rulep)->rhs; ! item_number_is_rule_number (*rp); rp++)
{
s = transitions_to (s->transitions,
item_number_as_symbol_number (*rp));
states1[length++] = s->number;
}
if (!s->consistent)
add_lookback_edge (s, *rulep, i);
if (!s->consistent)
add_lookback_edge (s, *rulep, i);
length--;
done = false;
while (!done)
{
done = true;
/* Each rhs ends in a rule number, and there is a
sentinel (ritem[-1]=0) before the first rhs, so it is safe to
decrement RP here. */
rp--;
if (ISVAR (*rp))
{
/* Downcasting from item_number to symbol_number. */
edge[nedges++] = map_goto (states1[--length],
item_number_as_symbol_number (*rp));
if (nullable[*rp - ntokens])
done = false;
}
}
}
length--;
done = false;
while (!done)
{
done = true;
/* Each rhs ends in a rule number, and there is a
sentinel (ritem[-1]=0) before the first rhs, so it is safe to
decrement RP here. */
rp--;
if (ISVAR (*rp))
{
/* Downcasting from item_number to symbol_number. */
edge[nedges++] = map_goto (states1[--length],
item_number_as_symbol_number (*rp));
if (nullable[*rp - ntokens])
done = false;
}
}
}
if (nedges == 0)
includes[i] = NULL;
includes[i] = NULL;
else
{
int j;
includes[i] = xnmalloc (nedges + 1, sizeof includes[i][0]);
for (j = 0; j < nedges; j++)
includes[i][j] = edge[j];
includes[i][nedges] = END_NODE;
}
{
int j;
includes[i] = xnmalloc (nedges + 1, sizeof includes[i][0]);
for (j = 0; j < nedges; j++)
includes[i][j] = edge[j];
includes[i][nedges] = END_NODE;
}
}
free (edge);
@@ -398,10 +398,10 @@ initialize_LA (void)
state_lookahead_tokens_count (states[i],
default_reduction_only_for_accept);
if (count)
{
states[i]->reductions->lookahead_tokens = pLA;
pLA += count;
}
{
states[i]->reductions->lookahead_tokens = pLA;
pLA += count;
}
}
}
@@ -423,21 +423,21 @@ lookahead_tokens_print (FILE *out)
int n_lookahead_tokens = 0;
if (reds->lookahead_tokens)
for (k = 0; k < reds->num; ++k)
if (reds->lookahead_tokens[k])
++n_lookahead_tokens;
for (k = 0; k < reds->num; ++k)
if (reds->lookahead_tokens[k])
++n_lookahead_tokens;
fprintf (out, "State %d: %d lookahead tokens\n",
i, n_lookahead_tokens);
i, n_lookahead_tokens);
if (reds->lookahead_tokens)
for (j = 0; j < reds->num; ++j)
BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0)
{
fprintf (out, " on %d (%s) -> rule %d\n",
k, symbols[k]->tag,
reds->rules[j]->number);
};
for (j = 0; j < reds->num; ++j)
BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0)
{
fprintf (out, " on %d (%s) -> rule %d\n",
k, symbols[k]->tag,
reds->rules[j]->number);
};
}
fprintf (out, "Lookahead tokens: END\n");
}

View File

@@ -32,91 +32,91 @@ bin_SCRIPTS = $(YACC_SCRIPT)
EXTRA_SCRIPTS = src/yacc
src_bison_CFLAGS = $(AM_CFLAGS) $(WERROR_CFLAGS)
src_bison_SOURCES = \
src/AnnotationList.c \
src/AnnotationList.h \
src/InadequacyList.c \
src/InadequacyList.h \
src/LR0.c \
src/LR0.h \
src/Sbitset.c \
src/Sbitset.h \
src/assoc.c \
src/assoc.h \
src/closure.c \
src/closure.h \
src/complain.c \
src/complain.h \
src/conflicts.c \
src/conflicts.h \
src/derives.c \
src/derives.h \
src/files.c \
src/files.h \
src/flex-scanner.h \
src/getargs.c \
src/getargs.h \
src/gram.c \
src/gram.h \
src/graphviz.c \
src/graphviz.h \
src/lalr.c \
src/lalr.h \
src/ielr.c \
src/ielr.h \
src/location.c \
src/location.h \
src/main.c \
src/muscle-tab.c \
src/muscle-tab.h \
src/named-ref.c \
src/named-ref.h \
src/nullable.c \
src/nullable.h \
src/output.c \
src/output.h \
src/parse-gram.h \
src/parse-gram.y \
src/print-xml.c \
src/print-xml.h \
src/print.c \
src/print.h \
src/print_graph.c \
src/print_graph.h \
src/reader.c \
src/reader.h \
src/reduce.c \
src/reduce.h \
src/relation.c \
src/relation.h \
src/scan-code-c.c \
src/scan-code.h \
src/scan-gram-c.c \
src/scan-gram.h \
src/scan-skel-c.c \
src/scan-skel.h \
src/state.c \
src/state.h \
src/symlist.c \
src/symlist.h \
src/symtab.c \
src/symtab.h \
src/system.h \
src/tables.c \
src/tables.h \
src/uniqstr.c \
src_bison_SOURCES = \
src/AnnotationList.c \
src/AnnotationList.h \
src/InadequacyList.c \
src/InadequacyList.h \
src/LR0.c \
src/LR0.h \
src/Sbitset.c \
src/Sbitset.h \
src/assoc.c \
src/assoc.h \
src/closure.c \
src/closure.h \
src/complain.c \
src/complain.h \
src/conflicts.c \
src/conflicts.h \
src/derives.c \
src/derives.h \
src/files.c \
src/files.h \
src/flex-scanner.h \
src/getargs.c \
src/getargs.h \
src/gram.c \
src/gram.h \
src/graphviz.c \
src/graphviz.h \
src/lalr.c \
src/lalr.h \
src/ielr.c \
src/ielr.h \
src/location.c \
src/location.h \
src/main.c \
src/muscle-tab.c \
src/muscle-tab.h \
src/named-ref.c \
src/named-ref.h \
src/nullable.c \
src/nullable.h \
src/output.c \
src/output.h \
src/parse-gram.h \
src/parse-gram.y \
src/print-xml.c \
src/print-xml.h \
src/print.c \
src/print.h \
src/print_graph.c \
src/print_graph.h \
src/reader.c \
src/reader.h \
src/reduce.c \
src/reduce.h \
src/relation.c \
src/relation.h \
src/scan-code-c.c \
src/scan-code.h \
src/scan-gram-c.c \
src/scan-gram.h \
src/scan-skel-c.c \
src/scan-skel.h \
src/state.c \
src/state.h \
src/symlist.c \
src/symlist.h \
src/symtab.c \
src/symtab.h \
src/system.h \
src/tables.c \
src/tables.h \
src/uniqstr.c \
src/uniqstr.h
EXTRA_src_bison_SOURCES = \
src/scan-code.l \
src/scan-gram.l \
EXTRA_src_bison_SOURCES = \
src/scan-code.l \
src/scan-gram.l \
src/scan-skel.l
BUILT_SOURCES += \
src/parse-gram.c \
src/parse-gram.h \
src/scan-code.c \
src/scan-gram.c \
BUILT_SOURCES += \
src/parse-gram.c \
src/parse-gram.h \
src/scan-code.c \
src/scan-gram.c \
src/scan-skel.c
MOSTLYCLEANFILES += src/yacc

View File

@@ -42,7 +42,7 @@ add_column_width (int column, char const *buf, size_t bufsize)
if (buf)
{
if (INT_MAX / 2 <= bufsize)
return INT_MAX;
return INT_MAX;
width = mbsnwidth (buf, bufsize, 0);
}
else
@@ -69,19 +69,19 @@ location_compute (location *loc, boundary *cur, char const *token, size_t size)
switch (*p)
{
case '\n':
line += line < INT_MAX;
column = 1;
p0 = p + 1;
break;
line += line < INT_MAX;
column = 1;
p0 = p + 1;
break;
case '\t':
column = add_column_width (column, p0, p - p0);
column = add_column_width (column, NULL, 8 - ((column - 1) & 7));
p0 = p + 1;
break;
column = add_column_width (column, p0, p - p0);
column = add_column_width (column, NULL, 8 - ((column - 1) & 7));
p0 = p + 1;
break;
default:
break;
break;
}
cur->line = line;

View File

@@ -73,8 +73,8 @@ static inline bool
equal_boundaries (boundary a, boundary b)
{
return (a.column == b.column
&& a.line == b.line
&& UNIQSTR_EQ (a.file, b.file));
&& a.line == b.line
&& UNIQSTR_EQ (a.file, b.file));
}
/* A location, that is, a region of source code. */
@@ -96,7 +96,7 @@ extern location const empty_location;
/* Set *LOC and adjust scanner cursor to account for token TOKEN of
size SIZE. */
void location_compute (location *loc,
boundary *cur, char const *token, size_t size);
boundary *cur, char const *token, size_t size);
/* Print location to file. Return number of actually printed
characters. */

View File

@@ -80,7 +80,7 @@ muscle_init (void)
obstack_init (&muscle_obstack);
muscle_table = hash_initialize (HT_INITIAL_CAPACITY, NULL, hash_muscle,
hash_compare_muscles, muscle_entry_free);
hash_compare_muscles, muscle_entry_free);
/* Version and input file. */
MUSCLE_INSERT_STRING ("version", VERSION);
@@ -179,7 +179,7 @@ muscle_syncline_grow (char const *key, location loc)
char *extension = NULL;
obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line);
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
quotearg_style (c_quoting_style, loc.start.file));
quotearg_style (c_quoting_style, loc.start.file));
obstack_sgrow (&muscle_obstack, "]])[");
obstack_1grow (&muscle_obstack, 0);
extension = obstack_finish (&muscle_obstack);
@@ -202,7 +202,7 @@ muscle_code_grow (const char *key, const char *val, location loc)
void muscle_pair_list_grow (const char *muscle,
const char *a1, const char *a2)
const char *a1, const char *a2)
{
char *pair;
obstack_sgrow (&muscle_obstack, "[[[");

View File

@@ -32,40 +32,40 @@ void muscle_free (void);
/* An obstack dedicated to receive muscle keys and values. */
extern struct obstack muscle_obstack;
#define MUSCLE_INSERT_BOOL(Key, Value) \
do { \
int v__ = Value; \
MUSCLE_INSERT_INT (Key, v__); \
#define MUSCLE_INSERT_BOOL(Key, Value) \
do { \
int v__ = Value; \
MUSCLE_INSERT_INT (Key, v__); \
} while(0)
#define MUSCLE_INSERT_INT(Key, Value) \
do { \
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
#define MUSCLE_INSERT_INT(Key, Value) \
do { \
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
do { \
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
do { \
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
/* Key -> Value, but don't apply escaping to Value. */
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
do { \
obstack_sgrow (&muscle_obstack, Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
do { \
obstack_sgrow (&muscle_obstack, Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
/* Key -> Value, applying M4 escaping to Value. */
#define MUSCLE_INSERT_STRING(Key, Value) \
do { \
#define MUSCLE_INSERT_STRING(Key, Value) \
do { \
MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \
@@ -74,21 +74,21 @@ do { \
for (p__ = Value; *p__; p__++) \
switch (*p__) \
{ \
case '$': obstack_sgrow (Obstack, "$]["); break; \
case '@': obstack_sgrow (Obstack, "@@" ); break; \
case '[': obstack_sgrow (Obstack, "@{" ); break; \
case ']': obstack_sgrow (Obstack, "@}" ); break; \
case '$': obstack_sgrow (Obstack, "$]["); break; \
case '@': obstack_sgrow (Obstack, "@@" ); break; \
case '[': obstack_sgrow (Obstack, "@{" ); break; \
case ']': obstack_sgrow (Obstack, "@}" ); break; \
default: obstack_1grow (Obstack, *p__); break; \
} \
} while(0)
#define MUSCLE_INSERT_C_STRING(Key, Value) \
do { \
MUSCLE_OBSTACK_SGROW (&muscle_obstack, \
quotearg_style (c_quoting_style, \
Value)); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
#define MUSCLE_INSERT_C_STRING(Key, Value) \
do { \
MUSCLE_OBSTACK_SGROW (&muscle_obstack, \
quotearg_style (c_quoting_style, \
Value)); \
obstack_1grow (&muscle_obstack, 0); \
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
} while(0)
/* Append VALUE to the current value of KEY. If KEY did not already
@@ -109,7 +109,7 @@ void muscle_code_grow (const char *key, const char *value, location loc);
muscle values are output *double* quoted, one needs to strip the first level
of quotes to reach the list itself. */
void muscle_pair_list_grow (const char *muscle,
const char *a1, const char *a2);
const char *a1, const char *a2);
/* In the format `[[file_name:line.column]], [[file_name:line.column]]', append
LOC to MUSCLE. Use digraphs for special characters in each file name. */

View File

@@ -48,7 +48,7 @@ nullable_print (FILE *out)
fputs ("NULLABLE\n", out);
for (i = ntokens; i < nsyms; i++)
fprintf (out, "\t%s: %s\n", symbols[i]->tag,
nullable[i - ntokens] ? "yes" : "no");
nullable[i - ntokens] ? "yes" : "no");
fputs ("\n\n", out);
}
@@ -77,52 +77,52 @@ nullable_compute (void)
for (ruleno = 0; ruleno < nrules; ++ruleno)
if (rules[ruleno].useful)
{
rule *rules_ruleno = &rules[ruleno];
if (rules_ruleno->rhs[0] >= 0)
{
/* This rule has a non empty RHS. */
item_number *rp = NULL;
bool any_tokens = false;
for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
if (ISTOKEN (*rp))
any_tokens = true;
rule *rules_ruleno = &rules[ruleno];
if (rules_ruleno->rhs[0] >= 0)
{
/* This rule has a non empty RHS. */
item_number *rp = NULL;
bool any_tokens = false;
for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
if (ISTOKEN (*rp))
any_tokens = true;
/* This rule has only nonterminals: schedule it for the second
pass. */
if (!any_tokens)
for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
{
rcount[ruleno]++;
p->next = rsets[*rp - ntokens];
p->value = rules_ruleno;
rsets[*rp - ntokens] = p;
p++;
}
}
else
{
/* This rule has an empty RHS. */
aver (item_number_as_rule_number (rules_ruleno->rhs[0])
== ruleno);
if (rules_ruleno->useful
&& ! nullable[rules_ruleno->lhs->number - ntokens])
{
nullable[rules_ruleno->lhs->number - ntokens] = true;
*s2++ = rules_ruleno->lhs->number;
}
}
/* This rule has only nonterminals: schedule it for the second
pass. */
if (!any_tokens)
for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
{
rcount[ruleno]++;
p->next = rsets[*rp - ntokens];
p->value = rules_ruleno;
rsets[*rp - ntokens] = p;
p++;
}
}
else
{
/* This rule has an empty RHS. */
aver (item_number_as_rule_number (rules_ruleno->rhs[0])
== ruleno);
if (rules_ruleno->useful
&& ! nullable[rules_ruleno->lhs->number - ntokens])
{
nullable[rules_ruleno->lhs->number - ntokens] = true;
*s2++ = rules_ruleno->lhs->number;
}
}
}
while (s1 < s2)
for (p = rsets[*s1++ - ntokens]; p; p = p->next)
{
rule *r = p->value;
if (--rcount[r->number] == 0)
if (r->useful && ! nullable[r->lhs->number - ntokens])
{
nullable[r->lhs->number - ntokens] = true;
*s2++ = r->lhs->number;
}
rule *r = p->value;
if (--rcount[r->number] == 0)
if (r->useful && ! nullable[r->lhs->number - ntokens])
{
nullable[r->lhs->number - ntokens] = true;
*s2++ = r->lhs->number;
}
}
free (squeue);

View File

@@ -54,51 +54,51 @@ static struct obstack format_obstack;
`-------------------------------------------------------------------*/
#define GENERATE_MUSCLE_INSERT_TABLE(Name, Type) \
\
static void \
Name (char const *name, \
Type *table_data, \
Type first, \
int begin, \
int end) \
{ \
Type min = first; \
Type max = first; \
long int lmin; \
long int lmax; \
int i; \
int j = 1; \
\
obstack_fgrow1 (&format_obstack, "%6d", first); \
for (i = begin; i < end; ++i) \
{ \
obstack_1grow (&format_obstack, ','); \
if (j >= 10) \
{ \
obstack_sgrow (&format_obstack, "\n "); \
j = 1; \
} \
else \
++j; \
obstack_fgrow1 (&format_obstack, "%6d", table_data[i]); \
if (table_data[i] < min) \
min = table_data[i]; \
if (max < table_data[i]) \
max = table_data[i]; \
} \
obstack_1grow (&format_obstack, 0); \
muscle_insert (name, obstack_finish (&format_obstack)); \
\
lmin = min; \
lmax = max; \
/* Build `NAME_min' and `NAME_max' in the obstack. */ \
obstack_fgrow1 (&format_obstack, "%s_min", name); \
obstack_1grow (&format_obstack, 0); \
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
obstack_fgrow1 (&format_obstack, "%s_max", name); \
obstack_1grow (&format_obstack, 0); \
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
#define GENERATE_MUSCLE_INSERT_TABLE(Name, Type) \
\
static void \
Name (char const *name, \
Type *table_data, \
Type first, \
int begin, \
int end) \
{ \
Type min = first; \
Type max = first; \
long int lmin; \
long int lmax; \
int i; \
int j = 1; \
\
obstack_fgrow1 (&format_obstack, "%6d", first); \
for (i = begin; i < end; ++i) \
{ \
obstack_1grow (&format_obstack, ','); \
if (j >= 10) \
{ \
obstack_sgrow (&format_obstack, "\n "); \
j = 1; \
} \
else \
++j; \
obstack_fgrow1 (&format_obstack, "%6d", table_data[i]); \
if (table_data[i] < min) \
min = table_data[i]; \
if (max < table_data[i]) \
max = table_data[i]; \
} \
obstack_1grow (&format_obstack, 0); \
muscle_insert (name, obstack_finish (&format_obstack)); \
\
lmin = min; \
lmax = max; \
/* Build `NAME_min' and `NAME_max' in the obstack. */ \
obstack_fgrow1 (&format_obstack, "%s_min", name); \
obstack_1grow (&format_obstack, 0); \
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
obstack_fgrow1 (&format_obstack, "%s_max", name); \
obstack_1grow (&format_obstack, 0); \
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
}
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_unsigned_int_table, unsigned int)
@@ -149,9 +149,9 @@ prepare_symbols (void)
MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number);
muscle_insert_symbol_number_table ("translate",
token_translations,
token_translations[0],
1, max_user_token_number + 1);
token_translations,
token_translations[0],
1, max_user_token_number + 1);
/* tname -- token names. */
{
@@ -163,23 +163,23 @@ prepare_symbols (void)
set_quoting_flags (qo, QA_SPLIT_TRIGRAPHS);
for (i = 0; i < nsyms; i++)
{
char *cp = quotearg_alloc (symbols[i]->tag, -1, qo);
/* Width of the next token, including the two quotes, the
comma and the space. */
int width = strlen (cp) + 2;
char *cp = quotearg_alloc (symbols[i]->tag, -1, qo);
/* Width of the next token, including the two quotes, the
comma and the space. */
int width = strlen (cp) + 2;
if (j + width > 75)
{
obstack_sgrow (&format_obstack, "\n ");
j = 1;
}
if (j + width > 75)
{
obstack_sgrow (&format_obstack, "\n ");
j = 1;
}
if (i)
obstack_1grow (&format_obstack, ' ');
MUSCLE_OBSTACK_SGROW (&format_obstack, cp);
if (i)
obstack_1grow (&format_obstack, ' ');
MUSCLE_OBSTACK_SGROW (&format_obstack, cp);
free (cp);
obstack_1grow (&format_obstack, ',');
j += width;
obstack_1grow (&format_obstack, ',');
j += width;
}
free (qo);
obstack_sgrow (&format_obstack, " ]b4_null[");
@@ -196,7 +196,7 @@ prepare_symbols (void)
for (i = 0; i < ntokens; ++i)
values[i] = symbols[i]->user_token_number;
muscle_insert_int_table ("toknum", values,
values[0], 1, ntokens);
values[0], 1, ntokens);
free (values);
}
}
@@ -264,7 +264,7 @@ prepare_states (void)
for (i = 0; i < nstates; ++i)
values[i] = states[i]->accessing_symbol;
muscle_insert_symbol_number_table ("stos", values,
0, 1, nstates);
0, 1, nstates);
free (values);
MUSCLE_INSERT_INT ("last", high);
@@ -354,11 +354,11 @@ user_actions_output (FILE *out)
for (r = 0; r < nrules; ++r)
if (rules[r].action)
{
fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ",
rules[r].is_predicate ? "predicate_" : "",
r + 1, rules[r].action_location.start.line);
escaped_output (out, rules[r].action_location.start.file);
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ",
rules[r].is_predicate ? "predicate_" : "",
r + 1, rules[r].action_location.start.line);
escaped_output (out, rules[r].action_location.start.file);
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
}
fputs ("])\n\n", out);
}
@@ -377,11 +377,11 @@ merger_output (FILE *out)
for (n = 1, p = merge_functions; p != NULL; n += 1, p = p->next)
{
if (p->type[0] == '\0')
fprintf (out, " case %d: *yy0 = %s (*yy0, *yy1); break;\n",
n, p->name);
fprintf (out, " case %d: *yy0 = %s (*yy0, *yy1); break;\n",
n, p->name);
else
fprintf (out, " case %d: yy0->%s = %s (*yy0, *yy1); break;\n",
n, p->type, p->name);
fprintf (out, " case %d: yy0->%s = %s (*yy0, *yy1); break;\n",
n, p->type, p->name);
}
fputs ("]])\n\n", out);
}
@@ -503,30 +503,30 @@ prepare_actions (void)
lookahead token type. */
muscle_insert_rule_number_table ("defact", yydefact,
yydefact[0], 1, nstates);
yydefact[0], 1, nstates);
/* Figure out what to do after reducing with each rule, depending on
the saved state from before the beginning of parsing the data
that matched this rule. */
muscle_insert_state_number_table ("defgoto", yydefgoto,
yydefgoto[0], 1, nsyms - ntokens);
yydefgoto[0], 1, nsyms - ntokens);
/* Output PACT. */
muscle_insert_base_table ("pact", base,
base[0], 1, nstates);
base[0], 1, nstates);
MUSCLE_INSERT_INT ("pact_ninf", base_ninf);
/* Output PGOTO. */
muscle_insert_base_table ("pgoto", base,
base[nstates], nstates + 1, nvectors);
base[nstates], nstates + 1, nvectors);
muscle_insert_base_table ("table", table,
table[0], 1, high + 1);
table[0], 1, high + 1);
MUSCLE_INSERT_INT ("table_ninf", table_ninf);
muscle_insert_base_table ("check", check,
check[0], 1, high + 1);
check[0], 1, high + 1);
/* GLR parsing slightly modifies YYTABLE and YYCHECK (and thus
YYPACT) so that in states with unresolved conflicts, the default
@@ -538,9 +538,9 @@ prepare_actions (void)
that case. Nevertheless, it seems even better to be able to use
the GLR skeletons even without the non-deterministic tables. */
muscle_insert_unsigned_int_table ("conflict_list_heads", conflict_table,
conflict_table[0], 1, high + 1);
conflict_table[0], 1, high + 1);
muscle_insert_unsigned_int_table ("conflicting_rules", conflict_list,
0, 1, conflict_list_cnt);
0, 1, conflict_list_cnt);
}
@@ -587,8 +587,8 @@ output_skeleton (void)
while (pkgdatadirlen && pkgdatadir[pkgdatadirlen - 1] == '/')
pkgdatadirlen--;
full_skeleton = xmalloc (pkgdatadirlen + 1
+ (skeleton_size < sizeof m4sugar
? sizeof m4sugar : skeleton_size));
+ (skeleton_size < sizeof m4sugar
? sizeof m4sugar : skeleton_size));
strncpy (full_skeleton, pkgdatadir, pkgdatadirlen);
full_skeleton[pkgdatadirlen] = '/';
strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar);
@@ -669,7 +669,7 @@ output_skeleton (void)
in = fdopen (filter_fd[0], "r");
if (! in)
error (EXIT_FAILURE, get_errno (),
"fdopen");
"fdopen");
scan_skel (in);
/* scan_skel should have read all of M4's output. Otherwise, when we
close the pipe, we risk letting M4 report a broken-pipe to the

View File

@@ -113,7 +113,7 @@
static YYLTYPE lloc_default (YYLTYPE const *, int);
#define YY_LOCATION_PRINT(File, Loc) \
location_print (File, Loc)
location_print (File, Loc)
static void version_check (location const *loc, char const *version);
@@ -121,7 +121,7 @@ static void version_check (location const *loc, char const *version);
FIXME: depends on the undocumented availability of YYLLOC. */
#undef yyerror
#define yyerror(Msg) \
gram_error (&yylloc, Msg)
gram_error (&yylloc, Msg)
static void gram_error (location const *, char const *);
static char const *char_name (char);
@@ -493,7 +493,7 @@ YYID (yyi)
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
&& (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
@@ -520,8 +520,8 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
&& defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|| (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
&& defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
@@ -547,15 +547,15 @@ union yyalloc
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (YYID (0))
#endif
@@ -568,13 +568,13 @@ union yyalloc
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
# define YYCOPY(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
while (YYID (0))
# endif
# endif
@@ -599,7 +599,7 @@ union yyalloc
#define YYUNDEFTOK 2
#define YYMAXUTOK 311
#define YYTRANSLATE(YYX) \
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
@@ -875,14 +875,14 @@ static const yytype_uint8 yyr2[] =
};
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2)
#define YYEOF 0
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2)
#define YYEOF 0
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
/* Like YYERROR except do call yyerror. This remains here temporarily
@@ -892,7 +892,7 @@ static const yytype_uint8 yyr2[] =
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
discussed. */
#define YYFAIL goto yyerrlab
#define YYFAIL goto yyerrlab
#if defined YYFAIL
/* This is here to suppress warnings from the GCC cpp's
-Wunused-macros. Normally we don't worry about that warning, but
@@ -902,26 +902,26 @@ static const yytype_uint8 yyr2[] =
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (1); \
YY_LAC_DISCARD ("YYBACKUP"); \
goto yybackup; \
} \
else \
{ \
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (1); \
YY_LAC_DISCARD ("YYBACKUP"); \
goto yybackup; \
} \
else \
{ \
yyerror (YY_("syntax error: cannot back up")); \
YYERROR; \
} \
YYERROR; \
} \
while (YYID (0))
#define YYTERROR 1
#define YYERRCODE 256
#define YYTERROR 1
#define YYERRCODE 256
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
@@ -930,22 +930,22 @@ while (YYID (0))
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (YYID (N)) \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
while (YYID (0))
#endif
@@ -956,10 +956,10 @@ while (YYID (0))
#ifndef YY_LOCATION_PRINT
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
(Loc).last_line, (Loc).last_column)
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
(Loc).last_line, (Loc).last_column)
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
@@ -982,21 +982,21 @@ while (YYID (0))
# define YYFPRINTF fprintf
# endif
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
} while (YYID (0))
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \
Type, Value, Location); \
YYFPRINTF (stderr, "\n"); \
} \
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \
Type, Value, Location); \
YYFPRINTF (stderr, "\n"); \
} \
} while (YYID (0))
@@ -1221,7 +1221,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
break;
default:
break;
break;
}
}
@@ -1279,10 +1279,10 @@ yy_stack_print (yybottom, yytop)
YYFPRINTF (stderr, "\n");
}
# define YY_STACK_PRINT(Bottom, Top) \
do { \
if (yydebug) \
yy_stack_print ((Bottom), (Top)); \
# define YY_STACK_PRINT(Bottom, Top) \
do { \
if (yydebug) \
yy_stack_print ((Bottom), (Top)); \
} while (YYID (0))
@@ -1320,9 +1320,9 @@ yy_reduce_print (yyssp, yyvsp, yylsp, yyrule)
}
}
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug) \
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug) \
yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \
} while (YYID (0))
@@ -1338,7 +1338,7 @@ int yydebug;
/* YYINITDEPTH -- initial size of the parser's stacks. */
#ifndef YYINITDEPTH
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif
@@ -1657,27 +1657,27 @@ yytnamerr (char *yyres, const char *yystr)
char const *yyp = yystr;
for (;;)
switch (*++yyp)
{
case '\'':
case ',':
goto do_not_strip_quotes;
switch (*++yyp)
{
case '\'':
case ',':
goto do_not_strip_quotes;
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
/* Fall through. */
default:
if (yyres)
yyres[yyn] = *yyp;
yyn++;
break;
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
/* Fall through. */
default:
if (yyres)
yyres[yyn] = *yyp;
yyn++;
break;
case '"':
if (yyres)
yyres[yyn] = '\0';
return yyn;
}
case '"':
if (yyres)
yyres[yyn] = '\0';
return yyn;
}
do_not_strip_quotes: ;
}
@@ -1858,7 +1858,7 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp)
switch (yytype)
{
default:
break;
break;
}
}
@@ -2043,26 +2043,26 @@ YYLTYPE yylloc;
#ifdef yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
YYLTYPE *yyls1 = yyls;
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
YYLTYPE *yyls1 = yyls;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yyls1, yysize * sizeof (*yylsp),
&yystacksize);
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yyls1, yysize * sizeof (*yylsp),
&yystacksize);
yyls = yyls1;
yyss = yyss1;
yyvs = yyvs1;
yyls = yyls1;
yyss = yyss1;
yyvs = yyvs1;
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
@@ -2070,23 +2070,23 @@ YYLTYPE yylloc;
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
yystacksize = YYMAXDEPTH;
{
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
YYSTACK_RELOCATE (yyls_alloc, yyls);
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
YYSTACK_RELOCATE (yyls_alloc, yyls);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
#endif /* no yyoverflow */
@@ -2096,10 +2096,10 @@ YYLTYPE yylloc;
yylsp = yyls + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
(unsigned long int) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
@@ -2503,7 +2503,7 @@ yyreduce:
{
symbol_list *list;
for (list = (yyvsp[0].list); list; list = list->next)
symbol_list_destructor_set (list, (yyvsp[-1].code), (yylsp[-1]));
symbol_list_destructor_set (list, (yyvsp[-1].code), (yylsp[-1]));
symbol_list_free ((yyvsp[0].list));
}
/* Line 1740 of yacc.c */
@@ -2516,7 +2516,7 @@ yyreduce:
{
symbol_list *list;
for (list = (yyvsp[0].list); list; list = list->next)
symbol_list_printer_set (list, (yyvsp[-1].code), (yylsp[-1]));
symbol_list_printer_set (list, (yyvsp[-1].code), (yylsp[-1]));
symbol_list_free ((yyvsp[0].list));
}
/* Line 1740 of yacc.c */
@@ -2640,7 +2640,7 @@ yyreduce:
symbol_list *list;
tag_seen = true;
for (list = (yyvsp[0].list); list; list = list->next)
symbol_type_set (list->content.sym, (yyvsp[-1].uniqstr), (yylsp[-1]));
symbol_type_set (list->content.sym, (yyvsp[-1].uniqstr), (yylsp[-1]));
symbol_list_free ((yyvsp[0].list));
}
/* Line 1740 of yacc.c */
@@ -2654,10 +2654,10 @@ yyreduce:
symbol_list *list;
++current_prec;
for (list = (yyvsp[0].list); list; list = list->next)
{
symbol_type_set (list->content.sym, current_type, (yylsp[-1]));
symbol_precedence_set (list->content.sym, current_prec, (yyvsp[-2].assoc), (yylsp[-2]));
}
{
symbol_type_set (list->content.sym, current_type, (yylsp[-1]));
symbol_precedence_set (list->content.sym, current_prec, (yyvsp[-2].assoc), (yylsp[-2]));
}
symbol_list_free ((yyvsp[0].list));
current_type = NULL;
}
@@ -2917,7 +2917,7 @@ yyreduce:
/* Line 1740 of yacc.c */
#line 605 "src/parse-gram.y"
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location,
current_lhs_named_ref); }
current_lhs_named_ref); }
/* Line 1740 of yacc.c */
#line 2923 "src/parse-gram.c"
break;
@@ -3178,20 +3178,20 @@ yyerrlab:
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
error, discard it. */
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval, &yylloc);
yychar = YYEMPTY;
}
{
yydestruct ("Error: discarding",
yytoken, &yylval, &yylloc);
yychar = YYEMPTY;
}
}
/* Else will try to reuse lookahead token after shifting the error
@@ -3224,29 +3224,29 @@ yyerrorlab:
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
YYABORT;
YYABORT;
yyerror_range[1] = *yylsp;
yydestruct ("Error: popping",
yystos[yystate], yyvsp, yylsp);
yystos[yystate], yyvsp, yylsp);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
@@ -3311,7 +3311,7 @@ yyreturn:
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp, yylsp);
yystos[*yyssp], yyvsp, yylsp);
YYPOPSTACK (1);
}
#ifndef yyoverflow
@@ -3355,8 +3355,8 @@ lloc_default (YYLTYPE const *rhs, int n)
for (i = 1; i <= n; i++)
if (! equal_boundaries (rhs[i].start, rhs[i].end))
{
loc.start = rhs[i].start;
break;
loc.start = rhs[i].start;
break;
}
return loc;
@@ -3399,9 +3399,9 @@ add_param (param_type type, char *decl, location loc)
size_t name_len;
for (name_len = 1;
memchr (alphanum, name_start[name_len], sizeof alphanum);
name_len++)
continue;
memchr (alphanum, name_start[name_len], sizeof alphanum);
name_len++)
continue;
name = xmalloc (name_len + 1);
memcpy (name, name_start, name_len);
@@ -3423,7 +3423,7 @@ version_check (location const *loc, char const *version)
if (strverscmp (version, PACKAGE_VERSION) > 0)
{
complain_at (*loc, "require bison %s, but have %s",
version, PACKAGE_VERSION);
version, PACKAGE_VERSION);
exit (63);
}
}

View File

@@ -37,7 +37,7 @@
static YYLTYPE lloc_default (YYLTYPE const *, int);
#define YY_LOCATION_PRINT(File, Loc) \
location_print (File, Loc)
location_print (File, Loc)
static void version_check (location const *loc, char const *version);
@@ -45,7 +45,7 @@ static void version_check (location const *loc, char const *version);
FIXME: depends on the undocumented availability of YYLLOC. */
#undef yyerror
#define yyerror(Msg) \
gram_error (&yylloc, Msg)
gram_error (&yylloc, Msg)
static void gram_error (location const *, char const *);
static char const *char_name (char);
@@ -191,9 +191,9 @@ static char const *char_name (char);
%type <chars> STRING "%{...%}" EPILOGUE braceless content.opt
%type <code> "{...}" "%?{...}"
%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
STRING
STRING
%printer { fprintf (stderr, "{\n%s\n}", $$); }
braceless content.opt "{...}" "%{...%}" EPILOGUE
braceless content.opt "{...}" "%{...%}" EPILOGUE
%type <uniqstr> BRACKETED_ID ID ID_COLON PERCENT_FLAG TAG variable
%printer { fputs ($$, stderr); } <uniqstr>
@@ -270,9 +270,9 @@ input:
;
/*------------------------------------.
| Declarations: before the first %%. |
`------------------------------------*/
/*------------------------------------.
| Declarations: before the first %%. |
`------------------------------------*/
prologue_declarations:
/* Nothing */
@@ -312,7 +312,7 @@ prologue_declaration:
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
}
| "%expect" INT { expected_sr_conflicts = $2; }
| "%expect-rr" INT { expected_rr_conflicts = $2; }
| "%expect-rr" INT { expected_rr_conflicts = $2; }
| "%file-prefix" STRING { spec_file_prefix = $2; }
| "%file-prefix" "=" STRING { spec_file_prefix = $3; } /* deprecated */
| "%glr-parser"
@@ -329,11 +329,11 @@ prologue_declaration:
muscle_code_grow ("initial_action", action.code, @2);
code_scanner_last_string_free ();
}
| "%language" STRING { language_argmatch ($2, grammar_prio, @1); }
| "%language" STRING { language_argmatch ($2, grammar_prio, @1); }
| "%name-prefix" STRING { spec_name_prefix = $2; }
| "%name-prefix" "=" STRING { spec_name_prefix = $3; } /* deprecated */
| "%no-lines" { no_lines_flag = true; }
| "%nondeterministic-parser" { nondeterministic_parser = true; }
| "%nondeterministic-parser" { nondeterministic_parser = true; }
| "%output" STRING { spec_outfile = $2; }
| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */
| "%param" { current_param = $1; } params { current_param = param_none; }
@@ -389,14 +389,14 @@ grammar_declaration:
{
symbol_list *list;
for (list = $3; list; list = list->next)
symbol_list_destructor_set (list, $2, @2);
symbol_list_destructor_set (list, $2, @2);
symbol_list_free ($3);
}
| "%printer" "{...}" generic_symlist
{
symbol_list *list;
for (list = $3; list; list = list->next)
symbol_list_printer_set (list, $2, @2);
symbol_list_printer_set (list, $2, @2);
symbol_list_free ($3);
}
| "%default-prec"
@@ -461,7 +461,7 @@ symbol_declaration:
symbol_list *list;
tag_seen = true;
for (list = $3; list; list = list->next)
symbol_type_set (list->content.sym, $2, @2);
symbol_type_set (list->content.sym, $2, @2);
symbol_list_free ($3);
}
;
@@ -472,10 +472,10 @@ precedence_declaration:
symbol_list *list;
++current_prec;
for (list = $3; list; list = list->next)
{
symbol_type_set (list->content.sym, current_type, @2);
symbol_precedence_set (list->content.sym, current_prec, $1, @1);
}
{
symbol_type_set (list->content.sym, current_type, @2);
symbol_precedence_set (list->content.sym, current_prec, $1, @1);
}
symbol_list_free ($3);
current_type = NULL;
}
@@ -566,9 +566,9 @@ symbol_defs.1:
;
/*------------------------------------------.
| The grammar section: between the two %%. |
`------------------------------------------*/
/*------------------------------------------.
| The grammar section: between the two %%. |
`------------------------------------------*/
grammar:
rules_or_grammar_declaration
@@ -603,7 +603,7 @@ rhses.1:
rhs:
/* Nothing. */
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location,
current_lhs_named_ref); }
current_lhs_named_ref); }
| rhs symbol named_ref.opt
{ grammar_current_rule_symbol_append ($2, @2, $3); }
| rhs "{...}" named_ref.opt
@@ -735,8 +735,8 @@ lloc_default (YYLTYPE const *rhs, int n)
for (i = 1; i <= n; i++)
if (! equal_boundaries (rhs[i].start, rhs[i].end))
{
loc.start = rhs[i].start;
break;
loc.start = rhs[i].start;
break;
}
return loc;
@@ -779,9 +779,9 @@ add_param (param_type type, char *decl, location loc)
size_t name_len;
for (name_len = 1;
memchr (alphanum, name_start[name_len], sizeof alphanum);
name_len++)
continue;
memchr (alphanum, name_start[name_len], sizeof alphanum);
name_len++)
continue;
name = xmalloc (name_len + 1);
memcpy (name, name_start, name_len);
@@ -803,7 +803,7 @@ version_check (location const *loc, char const *version)
if (strverscmp (version, PACKAGE_VERSION) > 0)
{
complain_at (*loc, "require bison %s, but have %s",
version, PACKAGE_VERSION);
version, PACKAGE_VERSION);
exit (63);
}
}

View File

@@ -82,36 +82,36 @@ print_core (FILE *out, int level, state *s)
sp1 = sp = ritem + sitems[i];
while (*sp >= 0)
sp++;
sp++;
r = item_number_as_rule_number (*sp);
sp = rules[r].rhs;
/* Display the lookahead tokens? */
if (item_number_is_rule_number (*sp1))
{
reductions *reds = s->reductions;
int red = state_reduction_find (s, &rules[r]);
/* Print item with lookaheads if there are. */
if (reds->lookahead_tokens && red != -1)
{
xml_printf (out, level + 1,
"<item rule-number=\"%d\" point=\"%d\">",
rules[r].number, sp1 - sp);
state_rule_lookahead_tokens_print_xml (s, &rules[r],
out, level + 2);
xml_puts (out, level + 1, "</item>");
printed = true;
}
}
{
reductions *reds = s->reductions;
int red = state_reduction_find (s, &rules[r]);
/* Print item with lookaheads if there are. */
if (reds->lookahead_tokens && red != -1)
{
xml_printf (out, level + 1,
"<item rule-number=\"%d\" point=\"%d\">",
rules[r].number, sp1 - sp);
state_rule_lookahead_tokens_print_xml (s, &rules[r],
out, level + 2);
xml_puts (out, level + 1, "</item>");
printed = true;
}
}
if (!printed)
{
xml_printf (out, level + 1,
"<item rule-number=\"%d\" point=\"%d\"/>",
rules[r].number,
sp1 - sp);
}
{
xml_printf (out, level + 1,
"<item rule-number=\"%d\" point=\"%d\"/>",
rules[r].number,
sp1 - sp);
}
}
xml_puts (out, level, "</itemset>");
}
@@ -132,7 +132,7 @@ print_transitions (state *s, FILE *out, int level)
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i))
{
n++;
n++;
}
/* Nothing to report. */
@@ -146,28 +146,28 @@ print_transitions (state *s, FILE *out, int level)
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
&& TRANSITION_IS_SHIFT (trans, i))
&& TRANSITION_IS_SHIFT (trans, i))
{
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
char const *tag = sym->tag;
state *s1 = trans->states[i];
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
char const *tag = sym->tag;
state *s1 = trans->states[i];
xml_printf (out, level + 1,
"<transition type=\"shift\" symbol=\"%s\" state=\"%d\"/>",
xml_escape (tag), s1->number);
xml_printf (out, level + 1,
"<transition type=\"shift\" symbol=\"%s\" state=\"%d\"/>",
xml_escape (tag), s1->number);
}
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
&& !TRANSITION_IS_SHIFT (trans, i))
&& !TRANSITION_IS_SHIFT (trans, i))
{
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
char const *tag = sym->tag;
state *s1 = trans->states[i];
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
char const *tag = sym->tag;
state *s1 = trans->states[i];
xml_printf (out, level + 1,
"<transition type=\"goto\" symbol=\"%s\" state=\"%d\"/>",
xml_escape (tag), s1->number);
xml_printf (out, level + 1,
"<transition type=\"goto\" symbol=\"%s\" state=\"%d\"/>",
xml_escape (tag), s1->number);
}
xml_puts (out, level, "</transitions>");
@@ -200,10 +200,10 @@ print_errs (FILE *out, int level, state *s)
for (i = 0; i < errp->num; ++i)
if (errp->symbols[i])
{
char const *tag = errp->symbols[i]->tag;
xml_printf (out, level + 1,
"<error symbol=\"%s\">nonassociative</error>",
xml_escape (tag));
char const *tag = errp->symbols[i]->tag;
xml_printf (out, level + 1,
"<error symbol=\"%s\">nonassociative</error>",
xml_escape (tag));
}
xml_puts (out, level, "</errors>");
}
@@ -217,19 +217,19 @@ print_errs (FILE *out, int level, state *s)
static void
print_reduction (FILE *out, int level, char const *lookahead_token,
rule *r, bool enabled)
rule *r, bool enabled)
{
if (r->number)
xml_printf (out, level,
"<reduction symbol=\"%s\" rule=\"%d\" enabled=\"%s\"/>",
xml_escape (lookahead_token),
r->number,
enabled ? "true" : "false");
"<reduction symbol=\"%s\" rule=\"%d\" enabled=\"%s\"/>",
xml_escape (lookahead_token),
r->number,
enabled ? "true" : "false");
else
xml_printf (out, level,
"<reduction symbol=\"%s\" rule=\"accept\" enabled=\"%s\"/>",
xml_escape (lookahead_token),
enabled ? "true" : "false");
"<reduction symbol=\"%s\" rule=\"accept\" enabled=\"%s\"/>",
xml_escape (lookahead_token),
enabled ? "true" : "false");
}
@@ -268,22 +268,22 @@ print_reductions (FILE *out, int level, state *s)
if (reds->lookahead_tokens)
for (i = 0; i < ntokens; i++)
{
bool count = bitset_test (no_reduce_set, i);
bool count = bitset_test (no_reduce_set, i);
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookahead_tokens[j], i))
{
if (! count)
{
if (reds->rules[j] != default_reduction)
report = true;
count = true;
}
else
{
report = true;
}
}
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookahead_tokens[j], i))
{
if (! count)
{
if (reds->rules[j] != default_reduction)
report = true;
count = true;
}
else
{
report = true;
}
}
}
/* Nothing to report. */
@@ -298,36 +298,36 @@ print_reductions (FILE *out, int level, state *s)
if (reds->lookahead_tokens)
for (i = 0; i < ntokens; i++)
{
bool defaulted = false;
bool count = bitset_test (no_reduce_set, i);
bool defaulted = false;
bool count = bitset_test (no_reduce_set, i);
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookahead_tokens[j], i))
{
if (! count)
{
if (reds->rules[j] != default_reduction)
print_reduction (out, level + 1, symbols[i]->tag,
reds->rules[j], true);
else
defaulted = true;
count = true;
}
else
{
if (defaulted)
print_reduction (out, level + 1, symbols[i]->tag,
default_reduction, true);
defaulted = false;
print_reduction (out, level + 1, symbols[i]->tag,
reds->rules[j], false);
}
}
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookahead_tokens[j], i))
{
if (! count)
{
if (reds->rules[j] != default_reduction)
print_reduction (out, level + 1, symbols[i]->tag,
reds->rules[j], true);
else
defaulted = true;
count = true;
}
else
{
if (defaulted)
print_reduction (out, level + 1, symbols[i]->tag,
default_reduction, true);
defaulted = false;
print_reduction (out, level + 1, symbols[i]->tag,
reds->rules[j], false);
}
}
}
if (default_reduction)
print_reduction (out, level + 1,
"$default", default_reduction, true);
"$default", default_reduction, true);
xml_puts (out, level, "</reductions>");
}
@@ -390,7 +390,7 @@ print_grammar (FILE *out, int level)
for (i = 0; i < max_user_token_number + 1; i++)
if (token_translations[i] != undeftoken->number)
{
char const *tag = symbols[token_translations[i]]->tag;
char const *tag = symbols[token_translations[i]]->tag;
int precedence = symbols[token_translations[i]]->prec;
assoc associativity = symbols[token_translations[i]]->assoc;
xml_indent (out, level + 2);
@@ -414,9 +414,9 @@ print_grammar (FILE *out, int level)
{
char const *tag = symbols[i]->tag;
xml_printf (out, level + 2,
"<nonterminal symbol-number=\"%d\" name=\"%s\""
"<nonterminal symbol-number=\"%d\" name=\"%s\""
" usefulness=\"%s\"/>",
i, xml_escape (tag),
i, xml_escape (tag),
reduce_nonterminal_useless_in_grammar (i)
? "useless-in-grammar" : "useful");
}
@@ -512,7 +512,7 @@ print_xml (void)
fputc ('\n', out);
xml_printf (out, level + 1, "<filename>%s</filename>",
xml_escape (grammar_file));
xml_escape (grammar_file));
/* print grammar */
print_grammar (out, level + 1);

View File

@@ -97,7 +97,7 @@ print_core (FILE *out, state *s)
sp1 = sp = ritem + sitems[i];
while (*sp >= 0)
sp++;
sp++;
r = item_number_as_rule_number (*sp);
@@ -105,15 +105,15 @@ print_core (FILE *out, state *s)
previous_lhs = rules[r].lhs;
for (sp = rules[r].rhs; sp < sp1; sp++)
fprintf (out, " %s", symbols[*sp]->tag);
fprintf (out, " %s", symbols[*sp]->tag);
fputs (" .", out);
for (/* Nothing */; *sp >= 0; ++sp)
fprintf (out, " %s", symbols[*sp]->tag);
fprintf (out, " %s", symbols[*sp]->tag);
/* Display the lookahead tokens? */
if (report_flag & report_lookahead_tokens
&& item_number_is_rule_number (*sp1))
state_rule_lookahead_tokens_print (s, &rules[r], out);
state_rule_lookahead_tokens_print (s, &rules[r], out);
fputc ('\n', out);
}
@@ -135,10 +135,10 @@ print_transitions (state *s, FILE *out, bool display_transitions_p)
/* Compute the width of the lookahead token column. */
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
{
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
max_length (&width, sym->tag);
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
max_length (&width, sym->tag);
}
/* Nothing to report. */
@@ -151,20 +151,20 @@ print_transitions (state *s, FILE *out, bool display_transitions_p)
/* Report lookahead tokens and shifts. */
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
{
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
const char *tag = sym->tag;
state *s1 = trans->states[i];
int j;
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
const char *tag = sym->tag;
state *s1 = trans->states[i];
int j;
fprintf (out, " %s", tag);
for (j = width - strlen (tag); j > 0; --j)
fputc (' ', out);
if (display_transitions_p)
fprintf (out, _("shift, and go to state %d\n"), s1->number);
else
fprintf (out, _("go to state %d\n"), s1->number);
fprintf (out, " %s", tag);
for (j = width - strlen (tag); j > 0; --j)
fputc (' ', out);
if (display_transitions_p)
fprintf (out, _("shift, and go to state %d\n"), s1->number);
else
fprintf (out, _("go to state %d\n"), s1->number);
}
}
@@ -196,12 +196,12 @@ print_errs (FILE *out, state *s)
for (i = 0; i < errp->num; ++i)
if (errp->symbols[i])
{
const char *tag = errp->symbols[i]->tag;
int j;
fprintf (out, " %s", tag);
for (j = width - strlen (tag); j > 0; --j)
fputc (' ', out);
fputs (_("error (nonassociative)\n"), out);
const char *tag = errp->symbols[i]->tag;
int j;
fprintf (out, " %s", tag);
for (j = width - strlen (tag); j > 0; --j)
fputc (' ', out);
fputs (_("error (nonassociative)\n"), out);
}
}
@@ -214,8 +214,8 @@ print_errs (FILE *out, state *s)
static void
print_reduction (FILE *out, size_t width,
const char *lookahead_token,
rule *r, bool enabled)
const char *lookahead_token,
rule *r, bool enabled)
{
int j;
fprintf (out, " %s", lookahead_token);
@@ -267,22 +267,22 @@ print_reductions (FILE *out, state *s)
if (reds->lookahead_tokens)
for (i = 0; i < ntokens; i++)
{
bool count = bitset_test (no_reduce_set, i);
bool count = bitset_test (no_reduce_set, i);
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookahead_tokens[j], i))
{
if (! count)
{
if (reds->rules[j] != default_reduction)
max_length (&width, symbols[i]->tag);
count = true;
}
else
{
max_length (&width, symbols[i]->tag);
}
}
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookahead_tokens[j], i))
{
if (! count)
{
if (reds->rules[j] != default_reduction)
max_length (&width, symbols[i]->tag);
count = true;
}
else
{
max_length (&width, symbols[i]->tag);
}
}
}
/* Nothing to report. */
@@ -296,40 +296,40 @@ print_reductions (FILE *out, state *s)
if (reds->lookahead_tokens)
for (i = 0; i < ntokens; i++)
{
bool defaulted = false;
bool count = bitset_test (no_reduce_set, i);
bool defaulted = false;
bool count = bitset_test (no_reduce_set, i);
if (count)
default_reduction_only = false;
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookahead_tokens[j], i))
{
if (! count)
{
if (reds->rules[j] != default_reduction)
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookahead_tokens[j], i))
{
if (! count)
{
if (reds->rules[j] != default_reduction)
{
default_reduction_only = false;
print_reduction (out, width,
symbols[i]->tag,
reds->rules[j], true);
}
else
defaulted = true;
count = true;
}
else
{
else
defaulted = true;
count = true;
}
else
{
default_reduction_only = false;
if (defaulted)
print_reduction (out, width,
symbols[i]->tag,
default_reduction, true);
defaulted = false;
print_reduction (out, width,
symbols[i]->tag,
reds->rules[j], false);
}
}
if (defaulted)
print_reduction (out, width,
symbols[i]->tag,
default_reduction, true);
defaulted = false;
print_reduction (out, width,
symbols[i]->tag,
reds->rules[j], false);
}
}
}
if (default_reduction)
@@ -411,25 +411,25 @@ print_grammar (FILE *out)
for (i = 0; i < max_user_token_number + 1; i++)
if (token_translations[i] != undeftoken->number)
{
const char *tag = symbols[token_translations[i]]->tag;
rule_number r;
item_number *rhsp;
const char *tag = symbols[token_translations[i]]->tag;
rule_number r;
item_number *rhsp;
buffer[0] = 0;
column = strlen (tag);
fputs (tag, out);
END_TEST (65);
sprintf (buffer, " (%d)", i);
buffer[0] = 0;
column = strlen (tag);
fputs (tag, out);
END_TEST (65);
sprintf (buffer, " (%d)", i);
for (r = 0; r < nrules; r++)
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
if (item_number_as_symbol_number (*rhsp) == token_translations[i])
{
END_TEST (65);
sprintf (buffer + strlen (buffer), " %d", r);
break;
}
fprintf (out, "%s\n", buffer);
for (r = 0; r < nrules; r++)
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
if (item_number_as_symbol_number (*rhsp) == token_translations[i])
{
END_TEST (65);
sprintf (buffer + strlen (buffer), " %d", r);
break;
}
fprintf (out, "%s\n", buffer);
}
fputs ("\n\n", out);
@@ -442,17 +442,17 @@ print_grammar (FILE *out)
const char *tag = symbols[i]->tag;
for (r = 0; r < nrules; r++)
{
item_number *rhsp;
if (rules[r].lhs->number == i)
left_count++;
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
if (item_number_as_symbol_number (*rhsp) == i)
{
right_count++;
break;
}
}
{
item_number *rhsp;
if (rules[r].lhs->number == i)
left_count++;
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
if (item_number_as_symbol_number (*rhsp) == i)
{
right_count++;
break;
}
}
buffer[0] = 0;
fputs (tag, out);
@@ -461,38 +461,38 @@ print_grammar (FILE *out)
END_TEST (0);
if (left_count > 0)
{
END_TEST (65);
sprintf (buffer + strlen (buffer), _(" on left:"));
{
END_TEST (65);
sprintf (buffer + strlen (buffer), _(" on left:"));
for (r = 0; r < nrules; r++)
{
if (rules[r].lhs->number == i)
{
END_TEST (65);
sprintf (buffer + strlen (buffer), " %d", r);
}
}
}
for (r = 0; r < nrules; r++)
{
if (rules[r].lhs->number == i)
{
END_TEST (65);
sprintf (buffer + strlen (buffer), " %d", r);
}
}
}
if (right_count > 0)
{
if (left_count > 0)
sprintf (buffer + strlen (buffer), ",");
END_TEST (65);
sprintf (buffer + strlen (buffer), _(" on right:"));
for (r = 0; r < nrules; r++)
{
item_number *rhsp;
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
if (item_number_as_symbol_number (*rhsp) == i)
{
END_TEST (65);
sprintf (buffer + strlen (buffer), " %d", r);
break;
}
}
}
{
if (left_count > 0)
sprintf (buffer + strlen (buffer), ",");
END_TEST (65);
sprintf (buffer + strlen (buffer), _(" on right:"));
for (r = 0; r < nrules; r++)
{
item_number *rhsp;
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
if (item_number_as_symbol_number (*rhsp) == i)
{
END_TEST (65);
sprintf (buffer + strlen (buffer), " %d", r);
break;
}
}
}
fprintf (out, "%s\n", buffer);
}
}
@@ -508,7 +508,7 @@ print_results (void)
reduce_output (out);
grammar_rules_partial_print (out,
_("Rules useless in parser due to conflicts"),
_("Rules useless in parser due to conflicts"),
rule_useless_in_parser_p);
conflicts_output (out);

View File

@@ -66,43 +66,43 @@ print_core (struct obstack *oout, state *s)
sp1 = sp = ritem + sitems[i];
while (*sp >= 0)
sp++;
sp++;
r = item_number_as_rule_number (*sp);
obstack_fgrow1 (oout, "\n%s -> ", rules[r].lhs->tag);
for (sp = rules[r].rhs; sp < sp1; sp++)
obstack_fgrow1 (oout, "%s ", symbols[*sp]->tag);
obstack_fgrow1 (oout, "%s ", symbols[*sp]->tag);
obstack_1grow (oout, '.');
for (/* Nothing */; *sp >= 0; ++sp)
obstack_fgrow1 (oout, " %s", symbols[*sp]->tag);
obstack_fgrow1 (oout, " %s", symbols[*sp]->tag);
/* Experimental feature: display the lookahead tokens. */
if (report_flag & report_lookahead_tokens
&& item_number_is_rule_number (*sp1))
{
/* Find the reduction we are handling. */
reductions *reds = s->reductions;
int redno = state_reduction_find (s, &rules[r]);
{
/* Find the reduction we are handling. */
reductions *reds = s->reductions;
int redno = state_reduction_find (s, &rules[r]);
/* Print them if there are. */
if (reds->lookahead_tokens && redno != -1)
{
bitset_iterator biter;
int k;
char const *sep = "";
obstack_sgrow (oout, "[");
BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0)
{
obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag);
sep = ", ";
}
obstack_sgrow (oout, "]");
}
}
/* Print them if there are. */
if (reds->lookahead_tokens && redno != -1)
{
bitset_iterator biter;
int k;
char const *sep = "";
obstack_sgrow (oout, "[");
BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0)
{
obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag);
sep = ", ";
}
obstack_sgrow (oout, "]");
}
}
}
}
@@ -125,21 +125,21 @@ print_actions (state const *s, FILE *fgraph)
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i))
{
state *s1 = trans->states[i];
symbol_number sym = s1->accessing_symbol;
state *s1 = trans->states[i];
symbol_number sym = s1->accessing_symbol;
/* Shifts are solid, gotos are dashed, and error is dotted. */
char const *style =
(TRANSITION_IS_ERROR (trans, i) ? "dotted"
: TRANSITION_IS_SHIFT (trans, i) ? "solid"
: "dashed");
/* Shifts are solid, gotos are dashed, and error is dotted. */
char const *style =
(TRANSITION_IS_ERROR (trans, i) ? "dotted"
: TRANSITION_IS_SHIFT (trans, i) ? "solid"
: "dashed");
if (TRANSITION_IS_ERROR (trans, i)
&& strcmp (symbols[sym]->tag, "error") != 0)
abort ();
output_edge (s->number, s1->number,
TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
style, fgraph);
if (TRANSITION_IS_ERROR (trans, i)
&& strcmp (symbols[sym]->tag, "error") != 0)
abort ();
output_edge (s->number, s1->number,
TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
style, fgraph);
}
}

View File

@@ -95,7 +95,7 @@ get_merge_function (uniqstr name)
syms->next = xmalloc (sizeof syms->next[0]);
syms->next->name = uniqstr_new (name);
/* After all symbol type declarations have been parsed, packgram invokes
record_merge_function_type to set the type. */
record_merge_function_type to set the type. */
syms->next->type = NULL;
syms->next->next = NULL;
merge_functions = head.next;
@@ -130,17 +130,17 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc)
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
{
complain_at (declaration_loc,
_("result type clash on merge function `%s': <%s> != <%s>"),
merge_function->name, type, merge_function->type);
_("result type clash on merge function `%s': <%s> != <%s>"),
merge_function->name, type, merge_function->type);
complain_at (merge_function->type_declaration_location,
_("previous declaration"));
_("previous declaration"));
}
merge_function->type = uniqstr_new (type);
merge_function->type_declaration_location = declaration_loc;
}
/*--------------------------------------.
| Free all merge-function definitions. |
| Free all merge-function definitions. |
`--------------------------------------*/
void
@@ -199,8 +199,8 @@ assign_named_ref (symbol_list *p, named_ref *name)
if (name->id == sym->tag)
{
warn_at (name->loc,
_("duplicated symbol name for %s ignored"),
quote (sym->tag));
_("duplicated symbol name for %s ignored"),
quote (sym->tag));
named_ref_free (name);
}
else
@@ -221,7 +221,7 @@ static symbol_list *previous_rule_end = NULL;
void
grammar_current_rule_begin (symbol *lhs, location loc,
named_ref *lhs_name)
named_ref *lhs_name)
{
symbol_list* p;
@@ -292,19 +292,19 @@ grammar_rule_check (const symbol_list *r)
symbol *first_rhs = r->next->content.sym;
/* If $$ is being set in default way, report if any type mismatch. */
if (first_rhs)
{
char const *lhs_type = r->content.sym->type_name;
const char *rhs_type =
first_rhs->type_name ? first_rhs->type_name : "";
if (!UNIQSTR_EQ (lhs_type, rhs_type))
warn_at (r->location,
_("type clash on default action: <%s> != <%s>"),
lhs_type, rhs_type);
}
{
char const *lhs_type = r->content.sym->type_name;
const char *rhs_type =
first_rhs->type_name ? first_rhs->type_name : "";
if (!UNIQSTR_EQ (lhs_type, rhs_type))
warn_at (r->location,
_("type clash on default action: <%s> != <%s>"),
lhs_type, rhs_type);
}
/* Warn if there is no default for $$ but we need one. */
else
warn_at (r->location,
_("empty rule for typed nonterminal, and no action"));
warn_at (r->location,
_("empty rule for typed nonterminal, and no action"));
}
/* Check that symbol values that should be used are in fact used. */
@@ -386,7 +386,7 @@ grammar_midrule_action (void)
current_rule->action_props.code,
current_rule->action_props.location,
midrule, 0,
current_rule->action_props.is_predicate);
current_rule->action_props.is_predicate);
code_props_none_init (&current_rule->action_props);
if (previous_rule_end)
@@ -463,7 +463,7 @@ grammar_current_rule_merge_set (uniqstr name, location loc)
void
grammar_current_rule_symbol_append (symbol *sym, location loc,
named_ref *name)
named_ref *name)
{
symbol_list *p;
if (current_rule->action_props.code)
@@ -477,7 +477,7 @@ grammar_current_rule_symbol_append (symbol *sym, location loc,
void
grammar_current_rule_action_append (const char *action, location loc,
named_ref *name, bool is_predicate)
named_ref *name, bool is_predicate)
{
if (current_rule->action_props.code)
grammar_midrule_action ();
@@ -512,7 +512,7 @@ packgram (void)
int rule_length = 0;
symbol *ruleprec = p->ruleprec;
record_merge_function_type (p->merger, p->content.sym->type_name,
p->merger_declaration_location);
p->merger_declaration_location);
rules[ruleno].user_number = ruleno;
rules[ruleno].number = ruleno;
rules[ruleno].lhs = p->content.sym;
@@ -528,47 +528,47 @@ packgram (void)
rules[ruleno].is_predicate = p->action_props.is_predicate;
/* If the midrule's $$ is set or its $n is used, remove the `$' from the
symbol name so that it's a user-defined symbol so that the default
%destructor and %printer apply. */
symbol name so that it's a user-defined symbol so that the default
%destructor and %printer apply. */
if (p->midrule_parent_rule
&& (p->action_props.is_value_used
|| symbol_list_n_get (p->midrule_parent_rule,
p->midrule_parent_rhs_index)
|| symbol_list_n_get (p->midrule_parent_rule,
p->midrule_parent_rhs_index)
->action_props.is_value_used))
p->content.sym->tag += 1;
p->content.sym->tag += 1;
/* Don't check the generated rule 0. It has no action, so some rhs
symbols may appear unused, but the parsing algorithm ensures that
%destructor's are invoked appropriately. */
symbols may appear unused, but the parsing algorithm ensures that
%destructor's are invoked appropriately. */
if (p != grammar)
grammar_rule_check (p);
grammar_rule_check (p);
for (p = p->next; p && p->content.sym; p = p->next)
{
++rule_length;
{
++rule_length;
/* Don't allow rule_length == INT_MAX, since that might
cause confusion with strtol if INT_MAX == LONG_MAX. */
if (rule_length == INT_MAX)
fatal_at (rules[ruleno].location, _("rule is too long"));
/* Don't allow rule_length == INT_MAX, since that might
cause confusion with strtol if INT_MAX == LONG_MAX. */
if (rule_length == INT_MAX)
fatal_at (rules[ruleno].location, _("rule is too long"));
/* item_number = symbol_number.
But the former needs to contain more: negative rule numbers. */
ritem[itemno++] =
/* item_number = symbol_number.
But the former needs to contain more: negative rule numbers. */
ritem[itemno++] =
symbol_number_as_item_number (p->content.sym->number);
/* A rule gets by default the precedence and associativity
of its last token. */
if (p->content.sym->class == token_sym && default_prec)
rules[ruleno].prec = p->content.sym;
}
/* A rule gets by default the precedence and associativity
of its last token. */
if (p->content.sym->class == token_sym && default_prec)
rules[ruleno].prec = p->content.sym;
}
/* If this rule has a %prec,
the specified symbol's precedence replaces the default. */
if (ruleprec)
{
rules[ruleno].precsym = ruleprec;
rules[ruleno].prec = ruleprec;
}
{
rules[ruleno].precsym = ruleprec;
rules[ruleno].prec = ruleprec;
}
/* An item ends by the rule number (negated). */
ritem[itemno++] = rule_number_as_item_number (ruleno);
aver (itemno < ITEM_NUMBER_MAX);
@@ -576,7 +576,7 @@ packgram (void)
aver (ruleno < RULE_NUMBER_MAX);
if (p)
p = p->next;
p = p->next;
}
aver (itemno == nritems);
@@ -660,7 +660,7 @@ prepare_percent_define_front_end_variables (void)
/*-------------------------------------------------------------.
| Check the grammar that has just been read, and convert it to |
| internal form. |
| internal form. |
`-------------------------------------------------------------*/
static void

View File

@@ -44,16 +44,16 @@ char const *token_name (int type);
/* From reader.c. */
void grammar_start_symbol_set (symbol *sym, location loc);
void grammar_current_rule_begin (symbol *lhs, location loc,
named_ref *lhs_named_ref);
named_ref *lhs_named_ref);
void grammar_current_rule_end (location loc);
void grammar_midrule_action (void);
void grammar_current_rule_prec_set (symbol *precsym, location loc);
void grammar_current_rule_dprec_set (int dprec, location loc);
void grammar_current_rule_merge_set (uniqstr name, location loc);
void grammar_current_rule_symbol_append (symbol *sym, location loc,
named_ref *named_ref);
named_ref *named_ref);
void grammar_current_rule_action_append (const char *action, location loc,
named_ref *named_ref, bool);
named_ref *named_ref, bool);
void reader (void);
void free_merger_functions (void);

View File

@@ -115,14 +115,14 @@ useless_nonterminals (void)
{
bitset_copy (Np, N);
for (r = 0; r < nrules; r++)
if (!bitset_test (P, r)
&& useful_production (r, N))
{
bitset_set (Np, rules[r].lhs->number - ntokens);
bitset_set (P, r);
}
if (!bitset_test (P, r)
&& useful_production (r, N))
{
bitset_set (Np, rules[r].lhs->number - ntokens);
bitset_set (P, r);
}
if (bitset_equal_p (N, Np))
break;
break;
Ns = Np;
Np = N;
N = Ns;
@@ -169,37 +169,37 @@ inaccessable_symbols (void)
bitset_set (V, accept->number);
while (1)
{
rule_number r;
bitset_copy (Vp, V);
for (r = 0; r < nrules; r++)
{
if (!bitset_test (Pp, r)
&& bitset_test (P, r)
&& bitset_test (V, rules[r].lhs->number))
{
item_number *rhsp;
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens))
bitset_set (Vp, *rhsp);
bitset_set (Pp, r);
}
}
if (bitset_equal_p (V, Vp))
break;
Vs = Vp;
Vp = V;
V = Vs;
}
{
rule_number r;
bitset_copy (Vp, V);
for (r = 0; r < nrules; r++)
{
if (!bitset_test (Pp, r)
&& bitset_test (P, r)
&& bitset_test (V, rules[r].lhs->number))
{
item_number *rhsp;
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens))
bitset_set (Vp, *rhsp);
bitset_set (Pp, r);
}
}
if (bitset_equal_p (V, Vp))
break;
Vs = Vp;
Vp = V;
V = Vs;
}
}
bitset_free (V);
V = Vp;
/* Tokens 0, 1, and 2 are internal to Bison. Consider them useful. */
bitset_set (V, endtoken->number); /* end-of-input token */
bitset_set (V, errtoken->number); /* error token */
bitset_set (V, undeftoken->number); /* some undefined token */
bitset_set (V, endtoken->number); /* end-of-input token */
bitset_set (V, errtoken->number); /* error token */
bitset_set (V, undeftoken->number); /* some undefined token */
bitset_free (P);
P = Pp;
@@ -212,7 +212,7 @@ inaccessable_symbols (void)
symbol_number i;
for (i = ntokens; i < nsyms; i++)
if (bitset_test (V, i))
nuseful_nonterminals++;
nuseful_nonterminals++;
}
nuseless_nonterminals = nvars - nuseful_nonterminals;
@@ -221,7 +221,7 @@ inaccessable_symbols (void)
rule_number r;
for (r = 0; r < nrules; ++r)
if (rules[r].precsym != 0)
bitset_set (V1, rules[r].precsym->number);
bitset_set (V1, rules[r].precsym->number);
}
}
@@ -257,11 +257,11 @@ reduce_grammar_tables (void)
/* Renumber the rules markers in RITEMS. */
for (r = 0; r < nrules; ++r)
{
item_number *rhsp = rules[r].rhs;
for (/* Nothing. */; *rhsp >= 0; ++rhsp)
/* Nothing. */;
*rhsp = rule_number_as_item_number (r);
rules[r].number = r;
item_number *rhsp = rules[r].rhs;
for (/* Nothing. */; *rhsp >= 0; ++rhsp)
/* Nothing. */;
*rhsp = rule_number_as_item_number (r);
rules[r].number = r;
}
nrules -= nuseless_productions;
}
@@ -272,8 +272,8 @@ reduce_grammar_tables (void)
int length;
for (r = nrules; r < nrules + nuseless_productions; ++r)
{
length = rule_rhs_length (&rules[r]);
nritems -= length + 1;
length = rule_rhs_length (&rules[r]);
nritems -= length + 1;
}
}
}
@@ -299,9 +299,9 @@ nonterminals_reduce (void)
for (i = ntokens; i < nsyms; i++)
if (!bitset_test (V, i))
{
nontermmap[i - ntokens] = n++;
warn_at (symbols[i]->location, _("nonterminal useless in grammar: %s"),
symbols[i]->tag);
nontermmap[i - ntokens] = n++;
warn_at (symbols[i]->location, _("nonterminal useless in grammar: %s"),
symbols[i]->tag);
}
@@ -322,11 +322,11 @@ nonterminals_reduce (void)
rule_number r;
for (r = 0; r < nrules; ++r)
{
item_number *rhsp;
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
if (ISVAR (*rhsp))
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp
- ntokens]);
item_number *rhsp;
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
if (ISVAR (*rhsp))
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp
- ntokens]);
}
accept->number = nontermmap[accept->number - ntokens];
}
@@ -350,7 +350,7 @@ reduce_output (FILE *out)
int i;
fprintf (out, "%s\n\n", _("Nonterminals useless in grammar"));
for (i = 0; i < nuseless_nonterminals; ++i)
fprintf (out, " %s\n", symbols[nsyms + i]->tag);
fprintf (out, " %s\n", symbols[nsyms + i]->tag);
fputs ("\n\n", out);
}
@@ -359,19 +359,19 @@ reduce_output (FILE *out)
int i;
for (i = 0; i < ntokens; i++)
if (reduce_token_unused_in_grammar (i))
{
if (!b)
fprintf (out, "%s\n\n", _("Terminals unused in grammar"));
b = true;
fprintf (out, " %s\n", symbols[i]->tag);
}
{
if (!b)
fprintf (out, "%s\n\n", _("Terminals unused in grammar"));
b = true;
fprintf (out, " %s\n", symbols[i]->tag);
}
if (b)
fputs ("\n\n", out);
}
if (nuseless_productions > 0)
grammar_rules_partial_print (out, _("Rules useless in grammar"),
rule_useless_in_grammar_p);
rule_useless_in_grammar_p);
}
@@ -417,8 +417,8 @@ reduce_grammar (void)
if (!bitset_test (N, accept->number - ntokens))
fatal_at (startsymbol_location,
_("start symbol %s does not derive any sentence"),
startsymbol->tag);
_("start symbol %s does not derive any sentence"),
startsymbol->tag);
/* First reduce the nonterminals, as they renumber themselves in the
whole grammar. If you change the order, nonterms would be
@@ -434,7 +434,7 @@ reduce_grammar (void)
fprintf (stderr, "reduced %s defines %d terminals, %d nonterminals\
, and %d productions.\n",
grammar_file, ntokens, nvars, nrules);
grammar_file, ntokens, nvars, nrules);
}
}

View File

@@ -36,8 +36,8 @@ relation_print (relation r, relation_node size, FILE *out)
{
fprintf (out, "%3lu: ", (unsigned long int) i);
if (r[i])
for (j = 0; r[i][j] != END_NODE; ++j)
fprintf (out, "%3lu ", (unsigned long int) r[i][j]);
for (j = 0; r[i][j] != END_NODE; ++j)
fprintf (out, "%3lu ", (unsigned long int) r[i][j]);
fputc ('\n', out);
}
fputc ('\n', out);
@@ -70,25 +70,25 @@ traverse (relation_node i)
if (R[i])
for (j = 0; R[i][j] != END_NODE; ++j)
{
if (INDEX[R[i][j]] == 0)
traverse (R[i][j]);
if (INDEX[R[i][j]] == 0)
traverse (R[i][j]);
if (INDEX[i] > INDEX[R[i][j]])
INDEX[i] = INDEX[R[i][j]];
if (INDEX[i] > INDEX[R[i][j]])
INDEX[i] = INDEX[R[i][j]];
bitset_or (F[i], F[i], F[R[i][j]]);
bitset_or (F[i], F[i], F[R[i][j]]);
}
if (INDEX[i] == height)
for (;;)
{
j = VERTICES[top--];
INDEX[j] = infinity;
j = VERTICES[top--];
INDEX[j] = infinity;
if (i == j)
break;
if (i == j)
break;
bitset_copy (F[j], F[i]);
bitset_copy (F[j], F[i]);
}
}
@@ -144,17 +144,17 @@ relation_transpose (relation *R_arg, relation_node n)
for (i = 0; i < n; i++)
if (r[i])
for (j = 0; r[i][j] != END_NODE; ++j)
++nedges[r[i][j]];
++nedges[r[i][j]];
/* Allocate. */
for (i = 0; i < n; i++)
{
relation_node *sp = NULL;
if (nedges[i] > 0)
{
sp = xnmalloc (nedges[i] + 1, sizeof *sp);
sp[nedges[i]] = END_NODE;
}
{
sp = xnmalloc (nedges[i] + 1, sizeof *sp);
sp[nedges[i]] = END_NODE;
}
new_R[i] = sp;
end_R[i] = sp;
}
@@ -163,7 +163,7 @@ relation_transpose (relation *R_arg, relation_node n)
for (i = 0; i < n; i++)
if (r[i])
for (j = 0; r[i][j] != END_NODE; ++j)
*end_R[r[i][j]]++ = i;
*end_R[r[i][j]]++ = i;
free (nedges);
free (end_R);

View File

@@ -48,7 +48,7 @@ YY_DECL;
#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
static void handle_action_dollar (symbol_list *rule, char *cp,
location dollar_loc);
location dollar_loc);
static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
/* A string to be pushed to obstack after dollar/at has been handled. */
@@ -76,17 +76,17 @@ static bool untyped_var_seen;
/* POSIX says that a tag must be both an id and a C union member, but
historically almost any character is allowed in a tag. We disallow
NUL and newline, as this simplifies our implementation. */
tag [^\0\n>]+
tag [^\0\n>]+
/* Zero or more instances of backslash-newline. Following GCC, allow
white space between the backslash and the newline. */
splice (\\[ \f\t\v]*\n)*
splice (\\[ \f\t\v]*\n)*
/* C style identifier. Must start with letter. Will be used for
named symbol references. Shall be kept synchronized with
scan-gram.l "letter" and "id". */
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
id {letter}({letter}|[-0-9])*
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
id {letter}({letter}|[-0-9])*
ref -?[0-9]+|{id}|"["{id}"]"|"$"
%%
@@ -112,8 +112,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
is expected to return only once. This initialization is
therefore done once per action to translate. */
aver (sc_context == SC_SYMBOL_ACTION
|| sc_context == SC_RULE_ACTION
|| sc_context == INITIAL);
|| sc_context == SC_RULE_ACTION
|| sc_context == INITIAL);
BEGIN sc_context;
%}
@@ -133,8 +133,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
<SC_LINE_COMMENT>
{
"\n" STRING_GROW; BEGIN sc_context;
{splice} STRING_GROW;
"\n" STRING_GROW; BEGIN sc_context;
{splice} STRING_GROW;
}
@@ -144,17 +144,17 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
<SC_CHARACTER,SC_STRING>
{
{splice}|\\{splice}. STRING_GROW;
{splice}|\\{splice}. STRING_GROW;
}
<SC_CHARACTER>
{
"'" STRING_GROW; BEGIN sc_context;
"'" STRING_GROW; BEGIN sc_context;
}
<SC_STRING>
{
"\"" STRING_GROW; BEGIN sc_context;
"\"" STRING_GROW; BEGIN sc_context;
}
@@ -228,9 +228,9 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
if (outer_brace && !yacc_flag && language_prio == default_prio
&& skeleton_prio == default_prio && need_semicolon && ! in_cpp)
{
warn_at (*loc, _("a `;' might be needed at the end of action code"));
warn_at (*loc, _("future versions of Bison will not add the `;'"));
obstack_1grow (&obstack_for_string, ';');
warn_at (*loc, _("a `;' might be needed at the end of action code"));
warn_at (*loc, _("future versions of Bison will not add the `;'"));
obstack_1grow (&obstack_for_string, ';');
}
STRING_GROW;
@@ -281,20 +281,20 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
<*>
{
\$ obstack_sgrow (&obstack_for_string, "$][");
\@ obstack_sgrow (&obstack_for_string, "@@");
\[ obstack_sgrow (&obstack_for_string, "@{");
\] obstack_sgrow (&obstack_for_string, "@}");
\$ obstack_sgrow (&obstack_for_string, "$][");
\@ obstack_sgrow (&obstack_for_string, "@@");
\[ obstack_sgrow (&obstack_for_string, "@{");
\] obstack_sgrow (&obstack_for_string, "@}");
}
/*-----------------------------------------------------.
| By default, grow the string obstack with the input. |
`-----------------------------------------------------*/
<*>.|\n STRING_GROW;
<*>.|\n STRING_GROW;
/* End of processing. */
<*><<EOF>> {
<*><<EOF>> {
STRING_FINISH;
return last_string;
}
@@ -357,9 +357,9 @@ variant_table_grow (void)
if (variant_count > variant_table_size)
{
while (variant_count > variant_table_size)
variant_table_size = 2 * variant_table_size + 3;
variant_table_size = 2 * variant_table_size + 3;
variant_table = xnrealloc (variant_table, variant_table_size,
sizeof *variant_table);
sizeof *variant_table);
}
return &variant_table[variant_count - 1];
}
@@ -389,7 +389,7 @@ find_prefix_end (const char *prefix, char *begin, char *end)
static variant *
variant_add (uniqstr id, location id_loc, unsigned symbol_index,
char *cp, char *cp_end, bool explicit_bracketing)
char *cp, char *cp_end, bool explicit_bracketing)
{
char *prefix_end;
@@ -443,53 +443,53 @@ show_sub_messages (const char* cp, bool explicit_bracketing,
dollar_or_at, var->id, at_spec);
}
else
{
static struct obstack msg_buf;
const char *tail = explicit_bracketing ? "" :
cp + strlen (var->id);
const char *id = var->hidden_by ? var->hidden_by->id :
var->id;
location id_loc = var->hidden_by ? var->hidden_by->loc :
var->loc;
{
static struct obstack msg_buf;
const char *tail = explicit_bracketing ? "" :
cp + strlen (var->id);
const char *id = var->hidden_by ? var->hidden_by->id :
var->id;
location id_loc = var->hidden_by ? var->hidden_by->loc :
var->loc;
/* Create the explanation message. */
obstack_init (&msg_buf);
/* Create the explanation message. */
obstack_init (&msg_buf);
obstack_fgrow1 (&msg_buf, _("possibly meant: %c"), dollar_or_at);
if (contains_dot_or_dash (id))
obstack_fgrow1 (&msg_buf, "[%s]", id);
else
obstack_sgrow (&msg_buf, id);
obstack_sgrow (&msg_buf, tail);
obstack_fgrow1 (&msg_buf, _("possibly meant: %c"), dollar_or_at);
if (contains_dot_or_dash (id))
obstack_fgrow1 (&msg_buf, "[%s]", id);
else
obstack_sgrow (&msg_buf, id);
obstack_sgrow (&msg_buf, tail);
if (var->err & VARIANT_HIDDEN)
{
obstack_fgrow1 (&msg_buf, _(", hiding %c"), dollar_or_at);
if (contains_dot_or_dash (var->id))
obstack_fgrow1 (&msg_buf, "[%s]", var->id);
else
obstack_sgrow (&msg_buf, var->id);
obstack_sgrow (&msg_buf, tail);
}
if (var->err & VARIANT_HIDDEN)
{
obstack_fgrow1 (&msg_buf, _(", hiding %c"), dollar_or_at);
if (contains_dot_or_dash (var->id))
obstack_fgrow1 (&msg_buf, "[%s]", var->id);
else
obstack_sgrow (&msg_buf, var->id);
obstack_sgrow (&msg_buf, tail);
}
obstack_fgrow1 (&msg_buf, _(" at %s"), at_spec);
obstack_fgrow1 (&msg_buf, _(" at %s"), at_spec);
if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
{
const char *format =
_(", cannot be accessed from mid-rule action at $%d");
obstack_fgrow1 (&msg_buf, format, midrule_rhs_index);
}
obstack_1grow (&msg_buf, '\0');
obstack_1grow (&msg_buf, '\0');
if (is_warning)
warn_at_indent (id_loc, &indent, "%s",
(char *) obstack_finish (&msg_buf));
else
complain_at_indent (id_loc, &indent, "%s",
(char *) obstack_finish (&msg_buf));
obstack_free (&msg_buf, 0);
}
obstack_free (&msg_buf, 0);
}
}
}
@@ -509,8 +509,8 @@ show_sub_messages (const char* cp, bool explicit_bracketing,
accesses. */
static long int
parse_ref (char *cp, symbol_list *rule, int rule_length,
int midrule_rhs_index, char *text, location text_loc,
char dollar_or_at)
int midrule_rhs_index, char *text, location text_loc,
char dollar_or_at)
{
symbol_list *l;
char *cp_end;
@@ -526,13 +526,13 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
{
long int num = strtol (cp, &cp, 10);
if (1 - INT_MAX + rule_length <= num && num <= rule_length)
return num;
return num;
else
{
complain_at (text_loc, _("integer out of range: %s"),
{
complain_at (text_loc, _("integer out of range: %s"),
quote (text));
return INVALID_REF;
}
return INVALID_REF;
}
}
if ('[' == *cp)
@@ -540,7 +540,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
/* Ignore the brackets. */
char *p;
for (p = ++cp; *p != ']'; ++p)
continue;
continue;
cp_end = p;
explicit_bracketing = true;
@@ -550,13 +550,13 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
/* Take all characters of the name. */
char* p;
for (p = cp; *p; ++p)
if (is_dot_or_dash (*p))
{
ref_tail_fields = p;
break;
}
if (is_dot_or_dash (*p))
{
ref_tail_fields = p;
break;
}
for (p = cp; *p; ++p)
continue;
continue;
cp_end = p;
explicit_bracketing = false;
@@ -569,17 +569,17 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
for (symbol_index = 0, l = rule; !symbol_list_null (l);
++symbol_index, l = l->next)
{
variant *var;
if (l->content_type != SYMLIST_SYMBOL)
continue;
variant *var;
if (l->content_type != SYMLIST_SYMBOL)
continue;
var = variant_add (l->content.sym->tag, l->sym_loc,
var = variant_add (l->content.sym->tag, l->sym_loc,
symbol_index, cp, cp_end, explicit_bracketing);
if (var && l->named_ref)
var->hidden_by = l->named_ref;
if (var && l->named_ref)
var->hidden_by = l->named_ref;
if (l->named_ref)
variant_add (l->named_ref->id, l->named_ref->loc,
if (l->named_ref)
variant_add (l->named_ref->id, l->named_ref->loc,
symbol_index, cp, cp_end, explicit_bracketing);
}
}
@@ -592,7 +592,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
/* Check visibility from mid-rule actions. */
if (midrule_rhs_index != 0
&& (symbol_index == 0 || midrule_rhs_index < symbol_index))
&& (symbol_index == 0 || midrule_rhs_index < symbol_index))
var->err |= VARIANT_NOT_VISIBLE_FROM_MIDRULE;
/* Check correct bracketing. */
@@ -723,19 +723,19 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
{
type_name = ++cp;
while (*cp != '>')
++cp;
++cp;
/* The '>' symbol will be later replaced by '\0'. Original
'text' is needed for error messages. */
'text' is needed for error messages. */
gt_ptr = cp;
++cp;
if (untyped_var_seen)
complain_at (dollar_loc, _("explicit type given in untyped grammar"));
complain_at (dollar_loc, _("explicit type given in untyped grammar"));
tag_seen = true;
}
n = parse_ref (cp, effective_rule, effective_rule_length,
rule->midrule_parent_rhs_index, text, dollar_loc, '$');
rule->midrule_parent_rhs_index, text, dollar_loc, '$');
if (gt_ptr)
*gt_ptr = '\0';
@@ -747,54 +747,54 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
case LHS_REF:
if (!type_name)
type_name = symbol_list_n_type_name_get (rule, dollar_loc, 0);
type_name = symbol_list_n_type_name_get (rule, dollar_loc, 0);
if (!type_name)
{
if (union_seen | tag_seen)
{
if (rule->midrule_parent_rule)
complain_at (dollar_loc,
_("$$ for the midrule at $%d of `%s'"
" has no declared type"),
rule->midrule_parent_rhs_index,
effective_rule->content.sym->tag);
else
complain_at (dollar_loc, _("$$ of `%s' has no declared type"),
rule->content.sym->tag);
}
else
untyped_var_seen = true;
type_name = "";
}
{
if (union_seen | tag_seen)
{
if (rule->midrule_parent_rule)
complain_at (dollar_loc,
_("$$ for the midrule at $%d of `%s'"
" has no declared type"),
rule->midrule_parent_rhs_index,
effective_rule->content.sym->tag);
else
complain_at (dollar_loc, _("$$ of `%s' has no declared type"),
rule->content.sym->tag);
}
else
untyped_var_seen = true;
type_name = "";
}
obstack_fgrow1 (&obstack_for_string,
"]b4_lhs_value([%s])[", type_name);
"]b4_lhs_value([%s])[", type_name);
rule->action_props.is_value_used = true;
break;
default:
if (max_left_semantic_context < 1 - n)
max_left_semantic_context = 1 - n;
max_left_semantic_context = 1 - n;
if (!type_name && 0 < n)
type_name =
symbol_list_n_type_name_get (effective_rule, dollar_loc, n);
type_name =
symbol_list_n_type_name_get (effective_rule, dollar_loc, n);
if (!type_name)
{
if (union_seen | tag_seen)
complain_at (dollar_loc, _("$%s of `%s' has no declared type"),
cp, effective_rule->content.sym->tag);
else
untyped_var_seen = true;
type_name = "";
}
{
if (union_seen | tag_seen)
complain_at (dollar_loc, _("$%s of `%s' has no declared type"),
cp, effective_rule->content.sym->tag);
else
untyped_var_seen = true;
type_name = "";
}
obstack_fgrow3 (&obstack_for_string,
"]b4_rhs_value(%d, %d, [%s])[",
effective_rule_length, n, type_name);
"]b4_rhs_value(%d, %d, [%s])[",
effective_rule_length, n, type_name);
if (n > 0)
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
true;
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
true;
break;
}
}
@@ -827,7 +827,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
muscle_percent_define_ensure("locations", at_loc, true);
n = parse_ref (cp, effective_rule, effective_rule_length,
rule->midrule_parent_rhs_index, text, at_loc, '@');
rule->midrule_parent_rhs_index, text, at_loc, '@');
switch (n)
{
case INVALID_REF:
@@ -839,7 +839,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
default:
obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
effective_rule_length, n);
effective_rule_length, n);
break;
}
}
@@ -886,7 +886,7 @@ code_props const code_props_none = CODE_PROPS_NONE_INIT;
void
code_props_plain_init (code_props *self, char const *code,
location code_loc)
location code_loc)
{
self->kind = CODE_PROPS_PLAIN;
self->code = code;
@@ -911,7 +911,7 @@ code_props_symbol_action_init (code_props *self, char const *code,
void
code_props_rule_action_init (code_props *self, char const *code,
location code_loc, symbol_list *rule,
named_ref *name, bool is_predicate)
named_ref *name, bool is_predicate)
{
self->kind = CODE_PROPS_RULE_ACTION;
self->code = code;

View File

@@ -44,8 +44,8 @@
#define YY_DECL GRAM_LEX_DECL
#define YY_USER_INIT \
code_start = scanner_cursor = loc->start; \
#define YY_USER_INIT \
code_start = scanner_cursor = loc->start; \
/* Location of scanner cursor. */
static boundary scanner_cursor;
@@ -69,7 +69,7 @@ static size_t no_cr_read (FILE *, char *, size_t);
#define ROLLBACK_CURRENT_TOKEN \
do { \
scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0); \
scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0); \
yyless (0); \
} while (0)
@@ -118,21 +118,21 @@ static void unexpected_newline (boundary, char const *);
/* Bracketed identifiers support. */
%x SC_BRACKETED_ID SC_RETURN_BRACKETED_ID
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
id {letter}({letter}|[-0-9])*
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
id {letter}({letter}|[-0-9])*
directive %{id}
int [0-9]+
int [0-9]+
/* POSIX says that a tag must be both an id and a C union member, but
historically almost any character is allowed in a tag. We disallow
NUL, as this simplifies our implementation. We disallow angle
bracket to match them in nested pairs: several languages use them
for generics/template types. */
tag [^\0<>]+
tag [^\0<>]+
/* Zero or more instances of backslash-newline. Following GCC, allow
white space between the backslash and the newline. */
splice (\\[ \f\t\v]*\n)*
splice (\\[ \f\t\v]*\n)*
%%
%{
@@ -164,7 +164,7 @@ splice (\\[ \f\t\v]*\n)*
<INITIAL,SC_AFTER_IDENTIFIER,SC_BRACKETED_ID,SC_RETURN_BRACKETED_ID>
{
/* Comments and white space. */
"," warn_at (*loc, _("stray `,' treated as white space"));
"," warn_at (*loc, _("stray `,' treated as white space"));
[ \f\n\t\v] |
"//".* ;
"/*" {
@@ -186,7 +186,7 @@ splice (\\[ \f\t\v]*\n)*
`----------------------------*/
/* For directives that are also command line options, the regex must be
"%..."
"%..."
after "[-_]"s are removed, and the directive must match the --long
option name, with a single string argument. Otherwise, add exceptions
to ../build-aux/cross-options.pl. */
@@ -269,10 +269,10 @@ splice (\\[ \f\t\v]*\n)*
}
/* Characters. */
"'" token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER;
"'" token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER;
/* Strings. */
"\"" token_start = loc->start; BEGIN SC_ESCAPED_STRING;
"\"" token_start = loc->start; BEGIN SC_ESCAPED_STRING;
/* Prologue. */
"%{" code_start = loc->start; BEGIN SC_PROLOGUE;
@@ -340,7 +340,7 @@ splice (\\[ \f\t\v]*\n)*
<SC_ESCAPED_CHARACTER,SC_ESCAPED_STRING,SC_TAG>
{
\0 complain_at (*loc, _("invalid null character"));
\0 complain_at (*loc, _("invalid null character"));
}
@@ -353,16 +353,16 @@ splice (\\[ \f\t\v]*\n)*
"[" {
if (bracketed_id_str)
{
ROLLBACK_CURRENT_TOKEN;
BEGIN SC_RETURN_BRACKETED_ID;
*loc = id_loc;
return ID;
ROLLBACK_CURRENT_TOKEN;
BEGIN SC_RETURN_BRACKETED_ID;
*loc = id_loc;
return ID;
}
else
{
bracketed_id_start = loc->start;
bracketed_id_context_state = YY_START;
BEGIN SC_BRACKETED_ID;
bracketed_id_start = loc->start;
bracketed_id_context_state = YY_START;
BEGIN SC_BRACKETED_ID;
}
}
":" {
@@ -392,33 +392,33 @@ splice (\\[ \f\t\v]*\n)*
{id} {
if (bracketed_id_str)
{
complain_at (*loc, _("unexpected identifier in bracketed name: %s"),
quote (yytext));
complain_at (*loc, _("unexpected identifier in bracketed name: %s"),
quote (yytext));
}
else
{
bracketed_id_str = uniqstr_new (yytext);
bracketed_id_loc = *loc;
bracketed_id_str = uniqstr_new (yytext);
bracketed_id_loc = *loc;
}
}
"]" {
BEGIN bracketed_id_context_state;
if (bracketed_id_str)
{
if (INITIAL == bracketed_id_context_state)
{
val->uniqstr = bracketed_id_str;
bracketed_id_str = 0;
*loc = bracketed_id_loc;
return BRACKETED_ID;
}
if (INITIAL == bracketed_id_context_state)
{
val->uniqstr = bracketed_id_str;
bracketed_id_str = 0;
*loc = bracketed_id_loc;
return BRACKETED_ID;
}
}
else
complain_at (*loc, _("an identifier expected"));
}
. {
complain_at (*loc, _("invalid character in bracketed name: %s"),
quote (yytext));
quote (yytext));
}
<<EOF>> {
BEGIN bracketed_id_context_state;
@@ -446,7 +446,7 @@ splice (\\[ \f\t\v]*\n)*
<SC_YACC_COMMENT>
{
"*/" BEGIN context_state;
.|\n ;
.|\n ;
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
}
@@ -458,7 +458,7 @@ splice (\\[ \f\t\v]*\n)*
<SC_COMMENT>
{
"*"{splice}"/" STRING_GROW; BEGIN context_state;
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
}
@@ -468,9 +468,9 @@ splice (\\[ \f\t\v]*\n)*
<SC_LINE_COMMENT>
{
"\n" STRING_GROW; BEGIN context_state;
{splice} STRING_GROW;
<<EOF>> BEGIN context_state;
"\n" STRING_GROW; BEGIN context_state;
{splice} STRING_GROW;
<<EOF>> BEGIN context_state;
}
@@ -502,7 +502,7 @@ splice (\\[ \f\t\v]*\n)*
/*----------------------------------------------------------.
| Scanning a Bison character literal, decoding its escapes. |
| The initial quote is already eaten. |
| The initial quote is already eaten. |
`----------------------------------------------------------*/
<SC_ESCAPED_CHARACTER>
@@ -610,13 +610,13 @@ splice (\\[ \f\t\v]*\n)*
obstack_1grow (&obstack_for_string, c);
}
\\a obstack_1grow (&obstack_for_string, '\a');
\\b obstack_1grow (&obstack_for_string, '\b');
\\f obstack_1grow (&obstack_for_string, '\f');
\\n obstack_1grow (&obstack_for_string, '\n');
\\r obstack_1grow (&obstack_for_string, '\r');
\\t obstack_1grow (&obstack_for_string, '\t');
\\v obstack_1grow (&obstack_for_string, '\v');
\\a obstack_1grow (&obstack_for_string, '\a');
\\b obstack_1grow (&obstack_for_string, '\b');
\\f obstack_1grow (&obstack_for_string, '\f');
\\n obstack_1grow (&obstack_for_string, '\n');
\\r obstack_1grow (&obstack_for_string, '\r');
\\t obstack_1grow (&obstack_for_string, '\t');
\\v obstack_1grow (&obstack_for_string, '\v');
/* \\[\"\'?\\] would be shorter, but it confuses xgettext. */
\\("\""|"'"|"?"|"\\") obstack_1grow (&obstack_for_string, yytext[1]);
@@ -629,7 +629,7 @@ splice (\\[ \f\t\v]*\n)*
else
obstack_1grow (&obstack_for_string, c);
}
\\(.|\n) {
\\(.|\n) {
char const *p = yytext + 1;
/* Quote only if escaping won't make the character visible. */
if (isspace ((unsigned char) *p) && isprint ((unsigned char) *p))
@@ -646,21 +646,21 @@ splice (\\[ \f\t\v]*\n)*
<SC_CHARACTER,SC_STRING>
{
{splice}|\\{splice}[^\n\[\]] STRING_GROW;
{splice}|\\{splice}[^\n\[\]] STRING_GROW;
}
<SC_CHARACTER>
{
"'" STRING_GROW; BEGIN context_state;
\n unexpected_newline (token_start, "'"); BEGIN context_state;
<<EOF>> unexpected_eof (token_start, "'"); BEGIN context_state;
"'" STRING_GROW; BEGIN context_state;
\n unexpected_newline (token_start, "'"); BEGIN context_state;
<<EOF>> unexpected_eof (token_start, "'"); BEGIN context_state;
}
<SC_STRING>
{
"\"" STRING_GROW; BEGIN context_state;
\n unexpected_newline (token_start, "\""); BEGIN context_state;
<<EOF>> unexpected_eof (token_start, "\""); BEGIN context_state;
"\"" STRING_GROW; BEGIN context_state;
\n unexpected_newline (token_start, "\""); BEGIN context_state;
<<EOF>> unexpected_eof (token_start, "\""); BEGIN context_state;
}
@@ -730,11 +730,11 @@ splice (\\[ \f\t\v]*\n)*
--nesting;
if (nesting < 0)
{
STRING_FINISH;
loc->start = code_start;
val->code = last_string;
BEGIN INITIAL;
return BRACED_CODE;
STRING_FINISH;
loc->start = code_start;
val->code = last_string;
BEGIN INITIAL;
return BRACED_CODE;
}
}
}
@@ -745,11 +745,11 @@ splice (\\[ \f\t\v]*\n)*
--nesting;
if (nesting < 0)
{
STRING_FINISH;
loc->start = code_start;
val->code = last_string;
BEGIN INITIAL;
return BRACED_PREDICATE;
STRING_FINISH;
loc->start = code_start;
val->code = last_string;
BEGIN INITIAL;
return BRACED_PREDICATE;
}
else
obstack_1grow (&obstack_for_string, '}');
@@ -802,8 +802,8 @@ splice (\\[ \f\t\v]*\n)*
| By default, grow the string obstack with the input. |
`-----------------------------------------------------*/
<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PREDICATE,SC_PROLOGUE,SC_EPILOGUE,SC_STRING,SC_CHARACTER,SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>. |
<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PREDICATE,SC_PROLOGUE,SC_EPILOGUE>\n STRING_GROW;
<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PREDICATE,SC_PROLOGUE,SC_EPILOGUE,SC_STRING,SC_CHARACTER,SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>. |
<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PREDICATE,SC_PROLOGUE,SC_EPILOGUE>\n STRING_GROW;
%%
@@ -819,35 +819,35 @@ no_cr_read (FILE *fp, char *buf, size_t size)
{
char *w = memchr (buf, '\r', bytes_read);
if (w)
{
char const *r = ++w;
char const *lim = buf + bytes_read;
{
char const *r = ++w;
char const *lim = buf + bytes_read;
for (;;)
{
/* Found an '\r'. Treat it like '\n', but ignore any
'\n' that immediately follows. */
w[-1] = '\n';
if (r == lim)
{
int ch = getc (fp);
if (ch != '\n' && ungetc (ch, fp) != ch)
break;
}
else if (*r == '\n')
r++;
for (;;)
{
/* Found an '\r'. Treat it like '\n', but ignore any
'\n' that immediately follows. */
w[-1] = '\n';
if (r == lim)
{
int ch = getc (fp);
if (ch != '\n' && ungetc (ch, fp) != ch)
break;
}
else if (*r == '\n')
r++;
/* Copy until the next '\r'. */
do
{
if (r == lim)
return w - buf;
}
while ((*w++ = *r++) != '\r');
}
/* Copy until the next '\r'. */
do
{
if (r == lim)
return w - buf;
}
while ((*w++ = *r++) != '\r');
}
return w - buf;
}
return w - buf;
}
}
return bytes_read;
@@ -878,7 +878,7 @@ scan_integer (char const *number, int base, location loc)
/*------------------------------------------------------------------.
| Convert universal character name UCN to a single-byte character, |
| and return that character. Return -1 if UCN does not correspond |
| to a single-byte character. |
| to a single-byte character. |
`------------------------------------------------------------------*/
static int
@@ -906,22 +906,22 @@ convert_ucn_to_byte (char const *ucn)
about. */
static signed char const table[] =
{
'\0', -1, -1, -1, -1, -1, -1, '\a',
'\b', '\t', '\n', '\v', '\f', '\r', -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
' ', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', '{', '|', '}', '~'
'\0', -1, -1, -1, -1, -1, -1, '\a',
'\b', '\t', '\n', '\v', '\f', '\r', -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
' ', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', '{', '|', '}', '~'
};
code = code < sizeof table ? table[code] : -1;
@@ -955,8 +955,8 @@ handle_syncline (char *args, location loc)
/*----------------------------------------------------------------.
| For a token or comment starting at START, report message MSGID, |
| which should say that an end marker was found before |
| the expected TOKEN_END. |
| which should say that an end marker was found before |
| the expected TOKEN_END. |
`----------------------------------------------------------------*/
static void

View File

@@ -89,8 +89,8 @@ static void fail_for_invalid_at (char const *at);
/* This pattern must not match more than the previous @ patterns. */
@[^@{}`(\n]* fail_for_invalid_at (yytext);
\n out_lineno++; ECHO;
[^@\n]+ ECHO;
\n out_lineno++; ECHO;
[^@\n]+ ECHO;
<INITIAL><<EOF>> {
if (outname)

View File

@@ -28,9 +28,9 @@
#include "print-xml.h"
/*-------------------.
| Shifts and Gotos. |
`-------------------*/
/*-------------------.
| Shifts and Gotos. |
`-------------------*/
/*-----------------------------------------.
@@ -61,14 +61,14 @@ transitions_to (transitions *shifts, symbol_number sym)
{
aver (j < shifts->num);
if (TRANSITION_SYMBOL (shifts, j) == sym)
return shifts->states[j];
return shifts->states[j];
}
}
/*--------------------.
| Error transitions. |
`--------------------*/
/*--------------------.
| Error transitions. |
`--------------------*/
/*---------------------------------.
@@ -88,9 +88,9 @@ errs_new (int num, symbol **tokens)
/*-------------.
| Reductions. |
`-------------*/
/*-------------.
| Reductions. |
`-------------*/
/*---------------------------------------.
@@ -110,9 +110,9 @@ reductions_new (int num, rule **reds)
/*---------.
| States. |
`---------*/
/*---------.
| States. |
`---------*/
state_number nstates = 0;
@@ -128,7 +128,7 @@ state *final_state = NULL;
state *
state_new (symbol_number accessing_symbol,
size_t nitems, item_number *core)
size_t nitems, item_number *core)
{
state *res;
size_t items_size = nitems * sizeof *core;
@@ -264,17 +264,17 @@ state_rule_lookahead_tokens_print (state *s, rule *r, FILE *out)
char const *sep = "";
fprintf (out, " [");
BITSET_FOR_EACH (biter, reds->lookahead_tokens[red], k, 0)
{
fprintf (out, "%s%s", sep, symbols[k]->tag);
sep = ", ";
}
{
fprintf (out, "%s%s", sep, symbols[k]->tag);
sep = ", ";
}
fprintf (out, "]");
}
}
void
state_rule_lookahead_tokens_print_xml (state *s, rule *r,
FILE *out, int level)
FILE *out, int level)
{
/* Find the reduction we are handling. */
reductions *reds = s->reductions;
@@ -287,10 +287,10 @@ state_rule_lookahead_tokens_print_xml (state *s, rule *r,
int k;
xml_puts (out, level, "<lookaheads>");
BITSET_FOR_EACH (biter, reds->lookahead_tokens[red], k, 0)
{
xml_printf (out, level + 1, "<symbol>%s</symbol>",
xml_escape (symbols[k]->tag));
}
{
xml_printf (out, level + 1, "<symbol>%s</symbol>",
xml_escape (symbols[k]->tag));
}
xml_puts (out, level, "</lookaheads>");
}
}
@@ -353,10 +353,10 @@ void
state_hash_new (void)
{
state_table = hash_initialize (HT_INITIAL_CAPACITY,
NULL,
state_hasher,
state_comparator,
NULL);
NULL,
state_hasher,
state_comparator,
NULL);
}

View File

@@ -148,12 +148,12 @@ typedef struct
/* Iterate over each transition over a token (shifts). */
#define FOR_EACH_SHIFT(Transitions, Iter) \
for (Iter = 0; \
Iter < Transitions->num \
&& (TRANSITION_IS_DISABLED (Transitions, Iter) \
|| TRANSITION_IS_SHIFT (Transitions, Iter)); \
++Iter) \
#define FOR_EACH_SHIFT(Transitions, Iter) \
for (Iter = 0; \
Iter < Transitions->num \
&& (TRANSITION_IS_DISABLED (Transitions, Iter) \
|| TRANSITION_IS_SHIFT (Transitions, Iter)); \
++Iter) \
if (!TRANSITION_IS_DISABLED (Transitions, Iter))
@@ -228,7 +228,7 @@ extern state *final_state;
/* Create a new state with ACCESSING_SYMBOL for those items. */
state *state_new (symbol_number accessing_symbol,
size_t core_size, item_number *core);
size_t core_size, item_number *core);
state *state_new_isocore (state const *s);
/* Set the transitions of STATE. */
@@ -246,7 +246,7 @@ void state_errs_set (state *s, int num, symbol **errors);
reduce R. */
void state_rule_lookahead_tokens_print (state *s, rule *r, FILE *out);
void state_rule_lookahead_tokens_print_xml (state *s, rule *r,
FILE *out, int level);
FILE *out, int level);
/* Create/destroy the states hash table. */
void state_hash_new (void);

View File

@@ -123,7 +123,7 @@ symbol_list_syms_print (const symbol_list *l, FILE *f)
symbol_print (l->content.sym, f);
fprintf (stderr, l->action_props.is_value_used ? " used" : " unused");
if (l && l->content.sym)
fprintf (f, ", ");
fprintf (f, ", ");
}
}
@@ -190,7 +190,7 @@ symbol_list_n_get (symbol_list *l, int n)
l = l->next;
if (l == NULL
|| (l->content_type == SYMLIST_SYMBOL && l->content.sym == NULL))
return NULL;
return NULL;
}
return l;

View File

@@ -90,7 +90,7 @@ symbol_new (uniqstr tag, location loc)
if (nsyms == SYMBOL_NUMBER_MAXIMUM)
fatal (_("too many symbols in input grammar (limit is %d)"),
SYMBOL_NUMBER_MAXIMUM);
SYMBOL_NUMBER_MAXIMUM);
nsyms++;
return res;
}
@@ -117,8 +117,8 @@ semantic_type_new (uniqstr tag)
| Print a symbol. |
`-----------------*/
#define SYMBOL_ATTR_PRINT(Attr) \
if (s->Attr) \
#define SYMBOL_ATTR_PRINT(Attr) \
if (s->Attr) \
fprintf (f, " %s { %s }", #Attr, s->Attr)
#define SYMBOL_CODE_PRINT(Attr) \
@@ -211,7 +211,7 @@ symbol_type_set (symbol *sym, uniqstr type_name, location loc)
if (type_name)
{
if (sym->type_name)
symbol_redeclaration (sym, "%type", sym->type_location, loc);
symbol_redeclaration (sym, "%type", sym->type_location, loc);
uniqstr_assert (type_name);
sym->type_name = type_name;
sym->type_location = loc;
@@ -340,7 +340,7 @@ symbol_precedence_set (symbol *sym, int prec, assoc a, location loc)
if (a != undef_assoc)
{
if (sym->prec != 0)
symbol_redeclaration (sym, assoc_to_string (a), sym->prec_location,
symbol_redeclaration (sym, assoc_to_string (a), sym->prec_location,
loc);
sym->prec = prec;
sym->assoc = a;
@@ -375,7 +375,7 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring)
if (declaring)
{
if (sym->declared)
warn_at (loc, _("symbol %s redeclared"), sym->tag);
warn_at (loc, _("symbol %s redeclared"), sym->tag);
sym->declared = true;
}
}
@@ -404,7 +404,7 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
{
endtoken = sym;
/* It is always mapped to 0, so it was already counted in
NTOKENS. */
NTOKENS. */
if (endtoken->number != NUMBER_UNDEFINED)
--ntokens;
endtoken->number = 0;
@@ -423,9 +423,9 @@ symbol_check_defined (symbol *sym)
if (sym->class == unknown_sym)
{
complain_at
(sym->location,
_("symbol %s is used, but is not defined as a token and has no rules"),
sym->tag);
(sym->location,
_("symbol %s is used, but is not defined as a token and has no rules"),
sym->tag);
sym->class = nterm_sym;
sym->number = nvars++;
}
@@ -445,10 +445,10 @@ symbol_make_alias (symbol *sym, symbol *str, location loc)
{
if (str->alias)
warn_at (loc, _("symbol `%s' used more than once as a literal string"),
str->tag);
str->tag);
else if (sym->alias)
warn_at (loc, _("symbol `%s' given more than one literal string"),
sym->tag);
sym->tag);
else
{
str->class = token_sym;
@@ -481,42 +481,42 @@ symbol_check_alias_consistency (symbol *this)
if (str->type_name != sym->type_name)
{
if (str->type_name)
symbol_type_set (sym, str->type_name, str->type_location);
symbol_type_set (sym, str->type_name, str->type_location);
else
symbol_type_set (str, sym->type_name, sym->type_location);
symbol_type_set (str, sym->type_name, sym->type_location);
}
if (str->destructor.code || sym->destructor.code)
{
if (str->destructor.code)
symbol_destructor_set (sym, &str->destructor);
symbol_destructor_set (sym, &str->destructor);
else
symbol_destructor_set (str, &sym->destructor);
symbol_destructor_set (str, &sym->destructor);
}
if (str->printer.code || sym->printer.code)
{
if (str->printer.code)
symbol_printer_set (sym, &str->printer);
symbol_printer_set (sym, &str->printer);
else
symbol_printer_set (str, &sym->printer);
symbol_printer_set (str, &sym->printer);
}
if (sym->prec || str->prec)
{
if (str->prec)
symbol_precedence_set (sym, str->prec, str->assoc,
str->prec_location);
symbol_precedence_set (sym, str->prec, str->assoc,
str->prec_location);
else
symbol_precedence_set (str, sym->prec, sym->assoc,
sym->prec_location);
symbol_precedence_set (str, sym->prec, sym->assoc,
sym->prec_location);
}
}
static bool
symbol_check_alias_consistency_processor (void *this,
void *null ATTRIBUTE_UNUSED)
void *null ATTRIBUTE_UNUSED)
{
symbol_check_alias_consistency (this);
return true;
@@ -582,7 +582,7 @@ symbol_translation (symbol *this)
{
/* A token which translation has already been set? */
if (token_translations[this->user_token_number] != undeftoken->number)
user_token_number_redeclaration
user_token_number_redeclaration
(this->user_token_number,
symbols[token_translations[this->user_token_number]],
this);
@@ -670,15 +670,15 @@ void
symbols_new (void)
{
symbol_table = hash_initialize (HT_INITIAL_CAPACITY,
NULL,
hash_symbol_hasher,
hash_symbol_comparator,
free);
NULL,
hash_symbol_hasher,
hash_symbol_comparator,
free);
semantic_type_table = hash_initialize (HT_INITIAL_CAPACITY,
NULL,
hash_semantic_type_hasher,
hash_semantic_type_comparator,
free);
NULL,
hash_semantic_type_hasher,
hash_semantic_type_comparator,
free);
}
@@ -862,12 +862,12 @@ symbols_token_translations_init (void)
{
symbol *this = symbols[i];
if (this->user_token_number != USER_NUMBER_UNDEFINED)
{
if (this->user_token_number > max_user_token_number)
max_user_token_number = this->user_token_number;
if (this->user_token_number == 256)
num_256_available_p = false;
}
{
if (this->user_token_number > max_user_token_number)
max_user_token_number = this->user_token_number;
if (this->user_token_number == 256)
num_256_available_p = false;
}
}
/* If 256 is not used, assign it to error, to follow POSIX. */
@@ -883,13 +883,13 @@ symbols_token_translations_init (void)
{
symbol *this = symbols[i];
if (this->user_token_number == USER_NUMBER_UNDEFINED)
this->user_token_number = ++max_user_token_number;
this->user_token_number = ++max_user_token_number;
if (this->user_token_number > max_user_token_number)
max_user_token_number = this->user_token_number;
max_user_token_number = this->user_token_number;
}
token_translations = xnmalloc (max_user_token_number + 1,
sizeof *token_translations);
sizeof *token_translations);
/* Initialize all entries for literal tokens to the internal token
number for $undefined, which represents all invalid inputs. */
@@ -940,12 +940,12 @@ symbols_pack (void)
if (startsymbol->class == unknown_sym)
fatal_at (startsymbol_location,
_("the start symbol %s is undefined"),
startsymbol->tag);
_("the start symbol %s is undefined"),
startsymbol->tag);
else if (startsymbol->class == token_sym)
fatal_at (startsymbol_location,
_("the start symbol %s is a token"),
startsymbol->tag);
_("the start symbol %s is a token"),
startsymbol->tag);
}
@@ -961,7 +961,7 @@ default_tagged_destructor_set (code_props const *destructor)
complain_at (destructor->location,
_("redeclaration for default tagged %%destructor"));
complain_at (default_tagged_destructor.location,
_("previous declaration"));
_("previous declaration"));
}
default_tagged_destructor = *destructor;
}
@@ -974,7 +974,7 @@ default_tagless_destructor_set (code_props const *destructor)
complain_at (destructor->location,
_("redeclaration for default tagless %%destructor"));
complain_at (default_tagless_destructor.location,
_("previous declaration"));
_("previous declaration"));
}
default_tagless_destructor = *destructor;
}
@@ -987,7 +987,7 @@ default_tagged_printer_set (code_props const *printer)
complain_at (printer->location,
_("redeclaration for default tagged %%printer"));
complain_at (default_tagged_printer.location,
_("previous declaration"));
_("previous declaration"));
}
default_tagged_printer = *printer;
}
@@ -1000,7 +1000,7 @@ default_tagless_printer_set (code_props const *printer)
complain_at (printer->location,
_("redeclaration for default tagless %%printer"));
complain_at (default_tagless_printer.location,
_("previous declaration"));
_("previous declaration"));
}
default_tagless_printer = *printer;
}

View File

@@ -39,8 +39,8 @@
typedef enum
{
unknown_sym, /**< Undefined. */
token_sym, /**< Terminal. */
nterm_sym /**< Non-terminal. */
token_sym, /**< Terminal. */
nterm_sym /**< Non-terminal. */
} symbol_class;
@@ -166,7 +166,7 @@ void symbol_precedence_set (symbol *sym, int prec, assoc a, location loc);
/** Set the \c class associated with \c sym. */
void symbol_class_set (symbol *sym, symbol_class class, location loc,
bool declaring);
bool declaring);
/** Set the \c user_token_number associated with \c sym. */
void symbol_user_token_number_set (symbol *sym, int user_number, location loc);

View File

@@ -161,32 +161,32 @@ typedef size_t uintptr_t;
#define obstack_sgrow(Obs, Str) \
obstack_grow (Obs, Str, strlen (Str))
#define obstack_fgrow1(Obs, Format, Arg1) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1); \
obstack_grow (Obs, buf, strlen (buf)); \
#define obstack_fgrow1(Obs, Format, Arg1) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
#define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2); \
obstack_grow (Obs, buf, strlen (buf)); \
#define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
#define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2, Arg3); \
obstack_grow (Obs, buf, strlen (buf)); \
#define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2, Arg3); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
#define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
obstack_grow (Obs, buf, strlen (buf)); \
#define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
do { \
char buf[4096]; \
sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
obstack_grow (Obs, buf, strlen (buf)); \
} while (0)
@@ -213,14 +213,14 @@ do { \
| Free a linked list. |
`---------------------*/
#define LIST_FREE(Type, List) \
do { \
Type *_node, *_next; \
for (_node = List; _node; _node = _next) \
{ \
_next = _node->next; \
free (_node); \
} \
#define LIST_FREE(Type, List) \
do { \
Type *_node, *_next; \
for (_node = List; _node; _node = _next) \
{ \
_next = _node->next; \
free (_node); \
} \
} while (0)

View File

@@ -152,11 +152,11 @@ table_grow (int desired)
if (trace_flag & trace_resource)
fprintf (stderr, "growing table and check from: %d to %d\n",
old_size, table_size);
old_size, table_size);
table = xnrealloc (table, table_size, sizeof *table);
conflict_table = xnrealloc (conflict_table, table_size,
sizeof *conflict_table);
sizeof *conflict_table);
check = xnrealloc (check, table_size, sizeof *check);
for (/* Nothing. */; old_size < table_size; ++old_size)
@@ -172,12 +172,12 @@ table_grow (int desired)
/*-------------------------------------------------------------------.
| For GLR parsers, for each conflicted token in S, as indicated |
| by non-zero entries in CONFLROW, create a list of possible |
| reductions that are alternatives to the shift or reduction |
| by non-zero entries in CONFLROW, create a list of possible |
| reductions that are alternatives to the shift or reduction |
| currently recorded for that token in S. Store the alternative |
| reductions followed by a 0 in CONFLICT_LIST, updating |
| reductions followed by a 0 in CONFLICT_LIST, updating |
| CONFLICT_LIST_CNT, and storing an index to the start of the list |
| back into CONFLROW. |
| back into CONFLROW. |
`-------------------------------------------------------------------*/
static void
@@ -192,26 +192,26 @@ conflict_row (state *s)
for (j = 0; j < ntokens; j += 1)
if (conflrow[j])
{
conflrow[j] = conflict_list_cnt;
conflrow[j] = conflict_list_cnt;
/* Find all reductions for token J, and record all that do not
match ACTROW[J]. */
for (i = 0; i < reds->num; i += 1)
if (bitset_test (reds->lookahead_tokens[i], j)
&& (actrow[j]
!= rule_number_as_item_number (reds->rules[i]->number)))
{
aver (0 < conflict_list_free);
conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
conflict_list_cnt += 1;
conflict_list_free -= 1;
}
/* Find all reductions for token J, and record all that do not
match ACTROW[J]. */
for (i = 0; i < reds->num; i += 1)
if (bitset_test (reds->lookahead_tokens[i], j)
&& (actrow[j]
!= rule_number_as_item_number (reds->rules[i]->number)))
{
aver (0 < conflict_list_free);
conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
conflict_list_cnt += 1;
conflict_list_free -= 1;
}
/* Leave a 0 at the end. */
aver (0 < conflict_list_free);
conflict_list[conflict_list_cnt] = 0;
conflict_list_cnt += 1;
conflict_list_free -= 1;
/* Leave a 0 at the end. */
aver (0 < conflict_list_free);
conflict_list[conflict_list_cnt] = 0;
conflict_list_cnt += 1;
conflict_list_free -= 1;
}
}
@@ -222,9 +222,9 @@ conflict_row (state *s)
| default action (yydefact) for the state. In addition, ACTROW is |
| filled with what to do for each kind of token, index by symbol |
| number, with zero meaning do the default action. The value |
| ACTION_NUMBER_MINIMUM, a very negative number, means this |
| situation is an error. The parser recognizes this value |
| specially. |
| ACTION_NUMBER_MINIMUM, a very negative number, means this |
| situation is an error. The parser recognizes this value |
| specially. |
| |
| This is where conflicts are resolved. The loop over lookahead |
| rules considered lower-numbered rules last, and the last rule |
@@ -256,22 +256,22 @@ action_row (state *s)
int j;
bitset_iterator biter;
/* loop over all the rules available here which require
lookahead (in reverse order to give precedence to the first
rule) */
lookahead (in reverse order to give precedence to the first
rule) */
for (i = reds->num - 1; i >= 0; --i)
/* and find each token which the rule finds acceptable
to come next */
BITSET_FOR_EACH (biter, reds->lookahead_tokens[i], j, 0)
{
/* and record this rule as the rule to use if that
token follows. */
if (actrow[j] != 0)
{
conflicted = true;
conflrow[j] = 1;
}
actrow[j] = rule_number_as_item_number (reds->rules[i]->number);
}
/* and find each token which the rule finds acceptable
to come next */
BITSET_FOR_EACH (biter, reds->lookahead_tokens[i], j, 0)
{
/* and record this rule as the rule to use if that
token follows. */
if (actrow[j] != 0)
{
conflicted = true;
conflrow[j] = 1;
}
actrow[j] = rule_number_as_item_number (reds->rules[i]->number);
}
}
/* Now see which tokens are allowed for shifts in this state. For
@@ -283,16 +283,16 @@ action_row (state *s)
state *shift_state = trans->states[i];
if (actrow[sym] != 0)
{
conflicted = true;
conflrow[sym] = 1;
}
{
conflicted = true;
conflrow[sym] = 1;
}
actrow[sym] = state_number_as_int (shift_state->number);
/* Do not use any default reduction if there is a shift for
error */
error */
if (sym == errtoken->number)
nodefault = true;
nodefault = true;
}
/* See which tokens are an explicit error in this state (due to
@@ -321,43 +321,43 @@ action_row (state *s)
if (reds->num >= 1 && !nodefault)
{
if (s->consistent)
default_reduction = reds->rules[0];
default_reduction = reds->rules[0];
else
{
int max = 0;
for (i = 0; i < reds->num; i++)
{
int count = 0;
rule *r = reds->rules[i];
symbol_number j;
{
int max = 0;
for (i = 0; i < reds->num; i++)
{
int count = 0;
rule *r = reds->rules[i];
symbol_number j;
for (j = 0; j < ntokens; j++)
if (actrow[j] == rule_number_as_item_number (r->number))
count++;
for (j = 0; j < ntokens; j++)
if (actrow[j] == rule_number_as_item_number (r->number))
count++;
if (count > max)
{
max = count;
default_reduction = r;
}
}
if (count > max)
{
max = count;
default_reduction = r;
}
}
/* GLR parsers need space for conflict lists, so we can't
default conflicted entries. For non-conflicted entries
or as long as we are not building a GLR parser,
actions that match the default are replaced with zero,
which means "use the default". */
/* GLR parsers need space for conflict lists, so we can't
default conflicted entries. For non-conflicted entries
or as long as we are not building a GLR parser,
actions that match the default are replaced with zero,
which means "use the default". */
if (max > 0)
{
int j;
for (j = 0; j < ntokens; j++)
if (actrow[j]
if (max > 0)
{
int j;
for (j = 0; j < ntokens; j++)
if (actrow[j]
== rule_number_as_item_number (default_reduction->number)
&& ! (nondeterministic_parser && conflrow[j]))
actrow[j] = 0;
}
}
&& ! (nondeterministic_parser && conflrow[j]))
actrow[j] = 0;
}
}
}
/* If have no default reduction, the default is an error.
@@ -366,7 +366,7 @@ action_row (state *s)
if (!default_reduction)
for (i = 0; i < ntokens; i++)
if (actrow[i] == ACTION_NUMBER_MINIMUM)
actrow[i] = 0;
actrow[i] = 0;
if (conflicted)
conflict_row (s);
@@ -408,10 +408,10 @@ save_row (state_number s)
for (i = 0; i < ntokens; i++)
if (actrow[i] != 0)
{
*sp1++ = i;
*sp2++ = actrow[i];
if (nondeterministic_parser)
*sp3++ = conflrow[i];
*sp1++ = i;
*sp2++ = actrow[i];
if (nondeterministic_parser)
*sp3++ = conflrow[i];
}
tally[s] = count;
@@ -457,16 +457,16 @@ token_actions (void)
save_row (i);
/* Now that the parser was computed, we can find which rules are
really reduced, and which are not because of SR or RR
conflicts. */
really reduced, and which are not because of SR or RR
conflicts. */
if (!nondeterministic_parser)
{
for (j = 0; j < ntokens; ++j)
if (actrow[j] < 0 && actrow[j] != ACTION_NUMBER_MINIMUM)
rules[item_number_as_rule_number (actrow[j])].useful = true;
if (yydefact[i])
rules[yydefact[i] - 1].useful = true;
}
{
for (j = 0; j < ntokens; ++j)
if (actrow[j] < 0 && actrow[j] != ACTION_NUMBER_MINIMUM)
rules[item_number_as_rule_number (actrow[j])].useful = true;
if (yydefact[i])
rules[yydefact[i] - 1].useful = true;
}
}
free (actrow);
@@ -513,8 +513,8 @@ save_column (symbol_number sym, state_number default_state)
for (i = begin; i < end; i++)
if (to_state[i] != default_state)
{
*sp1++ = from_state[i];
*sp2++ = to_state[i];
*sp1++ = from_state[i];
*sp2++ = to_state[i];
}
tally[symno] = count;
@@ -548,8 +548,8 @@ default_goto (symbol_number sym, size_t state_count[])
for (s = 0; s < nstates; s++)
if (state_count[s] > max)
{
max = state_count[s];
default_state = s;
max = state_count[s];
default_state = s;
}
return default_state;
@@ -599,22 +599,22 @@ sort_actions (void)
for (i = 0; i < nvectors; i++)
if (tally[i] > 0)
{
int k;
int t = tally[i];
int w = width[i];
int j = nentries - 1;
int k;
int t = tally[i];
int w = width[i];
int j = nentries - 1;
while (j >= 0 && (width[order[j]] < w))
j--;
while (j >= 0 && (width[order[j]] < w))
j--;
while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
j--;
while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
j--;
for (k = nentries - 1; k > j; k--)
order[k + 1] = order[k];
for (k = nentries - 1; k > j; k--)
order[k + 1] = order[k];
order[j + 1] = i;
nentries++;
order[j + 1] = i;
nentries++;
}
}
@@ -645,8 +645,8 @@ matching_state (vector_number vector)
{
int j;
for (j = 0; j < t; j += 1)
if (conflict_tos[i][j] != 0)
return -1;
if (conflict_tos[i][j] != 0)
return -1;
}
for (prev = vector - 1; prev >= 0; prev--)
@@ -656,17 +656,17 @@ matching_state (vector_number vector)
int match = 1;
/* Given how ORDER was computed, if the WIDTH or TALLY is
different, there cannot be a matching state. */
different, there cannot be a matching state. */
if (width[j] != w || tally[j] != t)
return -1;
return -1;
for (k = 0; match && k < t; k++)
if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k]
|| (conflict_tos[j] != NULL && conflict_tos[j][k] != 0))
match = 0;
if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k]
|| (conflict_tos[j] != NULL && conflict_tos[j][k] != 0))
match = 0;
if (match)
return j;
return j;
}
return -1;
@@ -694,39 +694,39 @@ pack_vector (vector_number vector)
aver (j < table_size);
for (k = 0; ok && k < t; k++)
{
loc = j + state_number_as_int (from[k]);
if (table_size <= loc)
table_grow (loc);
{
loc = j + state_number_as_int (from[k]);
if (table_size <= loc)
table_grow (loc);
if (table[loc] != 0)
ok = false;
}
if (table[loc] != 0)
ok = false;
}
for (k = 0; ok && k < vector; k++)
if (pos[k] == j)
ok = false;
if (pos[k] == j)
ok = false;
if (ok)
{
for (k = 0; k < t; k++)
{
loc = j + from[k];
table[loc] = to[k];
if (nondeterministic_parser && conflict_to != NULL)
conflict_table[loc] = conflict_to[k];
check[loc] = from[k];
}
{
for (k = 0; k < t; k++)
{
loc = j + from[k];
table[loc] = to[k];
if (nondeterministic_parser && conflict_to != NULL)
conflict_table[loc] = conflict_to[k];
check[loc] = from[k];
}
while (table[lowzero] != 0)
lowzero++;
while (table[lowzero] != 0)
lowzero++;
if (loc > high)
high = loc;
if (loc > high)
high = loc;
aver (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
return j;
}
aver (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
return j;
}
}
}
@@ -784,11 +784,11 @@ pack_table (void)
base_number place;
if (s < 0)
/* A new set of state actions, or a nonterminal. */
place = pack_vector (i);
/* A new set of state actions, or a nonterminal. */
place = pack_vector (i);
else
/* Action of I were already coded for S. */
place = base[s];
/* Action of I were already coded for S. */
place = base[s];
pos[i] = place;
base[order[i]] = place;
@@ -817,7 +817,7 @@ tables_generate (void)
correlated. In particular the signedness is not taken into
account. But it's not useless. */
verify (sizeof nstates <= sizeof nvectors
&& sizeof nvars <= sizeof nvectors);
&& sizeof nvars <= sizeof nvectors);
nvectors = state_number_as_int (nstates) + nvars;

View File

@@ -80,7 +80,7 @@ uniqstr_assert (char const *str)
if (!hash_lookup (uniqstrs_table, str))
{
error (0, 0,
"not a uniqstr: %s", quotearg (str));
"not a uniqstr: %s", quotearg (str));
abort ();
}
}
@@ -128,10 +128,10 @@ void
uniqstrs_new (void)
{
uniqstrs_table = hash_initialize (HT_INITIAL_CAPACITY,
NULL,
hash_uniqstr,
hash_compare_uniqstr,
free);
NULL,
hash_uniqstr,
hash_compare_uniqstr,
free);
}

View File

@@ -298,11 +298,11 @@ input:
printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
}
| line input /* Right recursive to load the stack so that popping at
END can be exercised. */
END can be exercised. */
{
$$ = 2;
printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
$$, RANGE (@$), $1, RANGE (@1), $2, RANGE (@2));
}
;
@@ -1363,37 +1363,37 @@ AT_DATA([input.y],
start: test2 test1 test0 testc;
test2
: 'a' { semi; /* TEST:N:2 */ }
| 'b' { if (0) {no_semi} /* TEST:N:2 */ }
| 'c' { if (0) {semi;} /* TEST:N:2 */ }
| 'd' { semi; no_semi /* TEST:Y:2 */ }
| 'e' { semi(); no_semi() /* TEST:Y:2 */ }
| 'f' { semi[]; no_semi[] /* TEST:Y:2 */ }
| 'g' { semi++; no_semi++ /* TEST:Y:2 */ }
| 'h' { {no_semi} no_semi /* TEST:Y:2 */ }
| 'i' { {semi;} no_semi /* TEST:Y:2 */ }
: 'a' { semi; /* TEST:N:2 */ }
| 'b' { if (0) {no_semi} /* TEST:N:2 */ }
| 'c' { if (0) {semi;} /* TEST:N:2 */ }
| 'd' { semi; no_semi /* TEST:Y:2 */ }
| 'e' { semi(); no_semi() /* TEST:Y:2 */ }
| 'f' { semi[]; no_semi[] /* TEST:Y:2 */ }
| 'g' { semi++; no_semi++ /* TEST:Y:2 */ }
| 'h' { {no_semi} no_semi /* TEST:Y:2 */ }
| 'i' { {semi;} no_semi /* TEST:Y:2 */ }
;
test1
: 'a' { semi; // TEST:N:1 ;
} | 'b' { if (0) {no_semi} // TEST:N:1 ;
} | 'c' { if (0) {semi;} // TEST:N:1 ;
} | 'd' { semi; no_semi // TEST:Y:1 ;
} | 'e' { semi(); no_semi() // TEST:Y:1 ;
} | 'f' { semi[]; no_semi[] // TEST:Y:1 ;
} | 'g' { semi++; no_semi++ // TEST:Y:1 ;
} | 'h' { {no_semi} no_semi // TEST:Y:1 ;
} | 'i' { {semi;} no_semi // TEST:Y:1 ;
: 'a' { semi; // TEST:N:1 ;
} | 'b' { if (0) {no_semi} // TEST:N:1 ;
} | 'c' { if (0) {semi;} // TEST:N:1 ;
} | 'd' { semi; no_semi // TEST:Y:1 ;
} | 'e' { semi(); no_semi() // TEST:Y:1 ;
} | 'f' { semi[]; no_semi[] // TEST:Y:1 ;
} | 'g' { semi++; no_semi++ // TEST:Y:1 ;
} | 'h' { {no_semi} no_semi // TEST:Y:1 ;
} | 'i' { {semi;} no_semi // TEST:Y:1 ;
} ;
test0
: 'a' { semi; // TEST:N:1 {}
} | 'b' { if (0) {no_semi} // TEST:N:1 {}
} | 'c' { if (0) {semi;} // TEST:N:1 {}
} | 'd' { semi; no_semi // TEST:Y:1 {}
} | 'e' { semi(); no_semi() // TEST:Y:1 {}
} | 'f' { semi[]; no_semi[] // TEST:Y:1 {}
} | 'g' { semi++; no_semi++ // TEST:Y:1 {}
} | 'h' { {no_semi} no_semi // TEST:Y:1 {}
} | 'i' { {semi;} no_semi // TEST:Y:1 {}
: 'a' { semi; // TEST:N:1 {}
} | 'b' { if (0) {no_semi} // TEST:N:1 {}
} | 'c' { if (0) {semi;} // TEST:N:1 {}
} | 'd' { semi; no_semi // TEST:Y:1 {}
} | 'e' { semi(); no_semi() // TEST:Y:1 {}
} | 'f' { semi[]; no_semi[] // TEST:Y:1 {}
} | 'g' { semi++; no_semi++ // TEST:Y:1 {}
} | 'h' { {no_semi} no_semi // TEST:Y:1 {}
} | 'i' { {semi;} no_semi // TEST:Y:1 {}
} ;
testc

View File

@@ -1,4 +1,4 @@
# @configure_input@ -*- shell-script -*-
# @configure_input@ -*- shell-script -*-
# Configurable variable values for Bison test suite.
# Copyright (C) 2000-2011 Free Software Foundation, Inc.

View File

@@ -211,7 +211,7 @@ m4_define([AT_CHECK_DOXYGEN],
[m4_case([$1],
[Public], [m4_pushdef([AT_DOXYGEN_PRIVATE], [NO])],
[Private], [m4_pushdef([AT_DOXYGEN_PRIVATE], [YES])],
[m4_fatal([invalid argument: $1])])
[m4_fatal([invalid argument: $1])])
AT_SETUP([Doxygen $1 Documentation])
AT_DATA([input.yy],

View File

@@ -249,7 +249,7 @@ int yylex (]AT_LEX_FORMALS[);
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%precedence NEG /* negation--unary minus */
@@ -332,10 +332,10 @@ AT_YYERROR_SEES_LOC_IF([
AT_LOC_FIRST_LINE, AT_LOC_FIRST_COLUMN);
if (AT_LOC_FIRST_LINE != AT_LOC_LAST_LINE)
fprintf (stderr, "-%d.%d",
AT_LOC_LAST_LINE, AT_LOC_LAST_COLUMN - 1);
AT_LOC_LAST_LINE, AT_LOC_LAST_COLUMN - 1);
else if (AT_LOC_FIRST_COLUMN != AT_LOC_LAST_COLUMN - 1)
fprintf (stderr, "-%d",
AT_LOC_LAST_COLUMN - 1);
AT_LOC_LAST_COLUMN - 1);
fprintf (stderr, ": ");])
fprintf (stderr, "%s\n", s);
}])[

View File

@@ -92,35 +92,35 @@ $1
prog :
| prog stmt {
char *output;]AT_LOCATION_IF([
printf ("%d.%d-%d.%d: ",
@2.first_line, @2.first_column,
@2.last_line, @2.last_column);])[
output = node_to_string (]$[2);
printf ("%s\n", output);
free (output);
free_node (]$[2);
}
char *output;]AT_LOCATION_IF([
printf ("%d.%d-%d.%d: ",
@2.first_line, @2.first_column,
@2.last_line, @2.last_column);])[
output = node_to_string (]$[2);
printf ("%s\n", output);
free (output);
free_node (]$[2);
}
;
stmt : expr ';' $2 { $$ = ]$[1; }
stmt : expr ';' $2 { $$ = ]$[1; }
| decl $3
| error ';' { $$ = new_nterm ("<error>", 0, 0, 0); }
| '@' { YYACCEPT; }
| error ';' { $$ = new_nterm ("<error>", 0, 0, 0); }
| '@' { YYACCEPT; }
;
expr : ID
| TYPENAME '(' expr ')'
{ $$ = new_nterm ("<cast>(%s,%s)", ]$[3, ]$[1, 0); }
| expr '+' expr { $$ = new_nterm ("+(%s,%s)", ]$[1, ]$[3, 0); }
{ $$ = new_nterm ("<cast>(%s,%s)", ]$[3, ]$[1, 0); }
| expr '+' expr { $$ = new_nterm ("+(%s,%s)", ]$[1, ]$[3, 0); }
| expr '=' expr { $$ = new_nterm ("=(%s,%s)", ]$[1, ]$[3, 0); }
;
decl : TYPENAME declarator ';'
{ $$ = new_nterm ("<declare>(%s,%s)", ]$[1, ]$[2, 0); }
{ $$ = new_nterm ("<declare>(%s,%s)", ]$[1, ]$[2, 0); }
| TYPENAME declarator '=' expr ';'
{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", ]$[1,
]$[2, ]$[4); }
{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", ]$[1,
]$[2, ]$[4); }
;
declarator : ID
@@ -163,60 +163,60 @@ yylex (LEX_PARAMETERS)
while (1)
{
if (feof (stdin))
abort ();
abort ();
c = getchar ();
switch (c)
{
case EOF:
return 0;
case '\t':
colNum = (colNum + 7) & ~7;
break;
case ' ': case '\f':
colNum += 1;
break;
case '\n':
lineNum += 1;
colNum = 0;
break;
default:
{
int tok;
{
case EOF:
return 0;
case '\t':
colNum = (colNum + 7) & ~7;
break;
case ' ': case '\f':
colNum += 1;
break;
case '\n':
lineNum += 1;
colNum = 0;
break;
default:
{
int tok;
#if YYLSP_NEEDED
yylloc.first_line = yylloc.last_line = lineNum;
yylloc.first_column = colNum;
yylloc.first_line = yylloc.last_line = lineNum;
yylloc.first_column = colNum;
#endif
if (isalpha (c))
{
i = 0;
if (isalpha (c))
{
i = 0;
do
{
buffer[i++] = c;
colNum += 1;
if (i == sizeof buffer - 1)
abort ();
c = getchar ();
}
while (isalnum (c) || c == '_');
do
{
buffer[i++] = c;
colNum += 1;
if (i == sizeof buffer - 1)
abort ();
c = getchar ();
}
while (isalnum (c) || c == '_');
ungetc (c, stdin);
buffer[i++] = 0;
tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
yylval = new_term (strcpy ((char *) malloc (i), buffer));
}
else
{
colNum += 1;
tok = c;
yylval = 0;
}
ungetc (c, stdin);
buffer[i++] = 0;
tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
yylval = new_term (strcpy ((char *) malloc (i), buffer));
}
else
{
colNum += 1;
tok = c;
yylval = 0;
}
#if YYLSP_NEEDED
yylloc.last_column = colNum-1;
yylloc.last_column = colNum-1;
#endif
return tok;
}
}
return tok;
}
}
}
}
@@ -298,7 +298,7 @@ node_to_string (Node *node)
child1 = node_to_string (node->nterm.children[1]);
child2 = node_to_string (node->nterm.children[2]);
buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0)
+ strlen (child1) + strlen (child2) + 1);
+ strlen (child1) + strlen (child2) + 1);
sprintf (buffer, node->nterm.form, child0, child1, child2);
free (child0);
free (child1);
@@ -412,61 +412,61 @@ m4_define([_AT_VERBOSE_GLR_STDERR],
AT_SETUP([GLR: Resolve ambiguity, impure, no locations])
_AT_TEST_GLR_CXXTYPES([],
[%dprec 1], [%dprec 2])
[%dprec 1], [%dprec 2])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Resolve ambiguity, impure, locations])
_AT_TEST_GLR_CXXTYPES([%locations],[%dprec 1],[%dprec 2])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Resolve ambiguity, pure, no locations])
_AT_TEST_GLR_CXXTYPES([%define api.pure],
[%dprec 1], [%dprec 2])
[%dprec 1], [%dprec 2])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Resolve ambiguity, pure, locations])
_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
[%dprec 1], [%dprec 2])
[%dprec 1], [%dprec 2])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, impure, no locations])
_AT_TEST_GLR_CXXTYPES([],
[%merge <stmtMerge>], [%merge <stmtMerge>])
[%merge <stmtMerge>], [%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, impure, locations])
_AT_TEST_GLR_CXXTYPES([%locations],
[%merge <stmtMerge>], [%merge <stmtMerge>])
[%merge <stmtMerge>], [%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
_AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, pure, no locations])
_AT_TEST_GLR_CXXTYPES([%define api.pure],
[%merge <stmtMerge>], [%merge <stmtMerge>])
[%merge <stmtMerge>], [%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Merge conflicting parses, pure, locations])
_AT_TEST_GLR_CXXTYPES([%define api.pure %locations],
[%merge <stmtMerge>],[%merge <stmtMerge>])
[%merge <stmtMerge>],[%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
_AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR)
AT_CLEANUP
AT_SETUP([GLR: Verbose messages, resolve ambiguity, impure, no locations])
_AT_TEST_GLR_CXXTYPES([%error-verbose],
[%merge <stmtMerge>], [%merge <stmtMerge>])
[%merge <stmtMerge>], [%merge <stmtMerge>])
AT_PARSER_CHECK([[./types test-input]], 0,
_AT_AMBIG_GLR_OUTPUT, _AT_VERBOSE_GLR_STDERR)
_AT_AMBIG_GLR_OUTPUT, _AT_VERBOSE_GLR_STDERR)
AT_CLEANUP

File diff suppressed because it is too large Load Diff

View File

@@ -85,12 +85,12 @@ yylex (void)
{
int ch;
if (feof (stdin))
abort ();
abort ();
ch = getchar ();
if (ch == EOF)
return 0;
return 0;
else if (ch == 'B' || ch == 'P')
return ch;
return ch;
}
}
]])
@@ -341,7 +341,7 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
## Duplicate representation of merged trees. See ##
## Duplicate representation of merged trees. See ##
## <http://lists.gnu.org/archive/html/help-bison/2005-07/msg00013.html>. ##
## ------------------------------------------------------------------------- ##
@@ -444,7 +444,7 @@ AT_CLEANUP
## -------------------------------------------------------------------------- ##
## User destructor for unresolved GLR semantic value. See ##
## User destructor for unresolved GLR semantic value. See ##
## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00016.html>. ##
## -------------------------------------------------------------------------- ##
@@ -517,7 +517,7 @@ AT_CLEANUP
## -------------------------------------------------------------------------- ##
## User destructor after an error during a split parse. See ##
## User destructor after an error during a split parse. See ##
## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00029.html>. ##
## -------------------------------------------------------------------------- ##
@@ -584,7 +584,7 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
## Duplicated user destructor for lookahead. See ##
## Duplicated user destructor for lookahead. See ##
## <http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00035.html>. ##
## ------------------------------------------------------------------------- ##
@@ -675,7 +675,7 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
## Incorrect default location for empty right-hand sides. Adapted from bug ##
## report by Claudia Hermann. ##
## report by Claudia Hermann. ##
## See http://lists.gnu.org/archive/html/bug-bison/2005-10/msg00069.html and ##
## http://lists.gnu.org/archive/html/bug-bison/2005-10/msg00072.html ##
## ------------------------------------------------------------------------- ##
@@ -701,25 +701,25 @@ AT_DATA_GRAMMAR([glr-regr8.y],
%%
PortClause : T_PORT InterfaceDeclaration T_PORT
{ printf("%d/%d - %d/%d - %d/%d\n",
@1.first_column, @1.last_column,
@2.first_column, @2.last_column,
@3.first_column, @3.last_column); }
;
PortClause : T_PORT InterfaceDeclaration T_PORT
{ printf("%d/%d - %d/%d - %d/%d\n",
@1.first_column, @1.last_column,
@2.first_column, @2.last_column,
@3.first_column, @3.last_column); }
;
InterfaceDeclaration : OptConstantWord %dprec 1
| OptSignalWord %dprec 2
;
InterfaceDeclaration : OptConstantWord %dprec 1
| OptSignalWord %dprec 2
;
OptConstantWord : /* empty */
| T_CONSTANT
;
OptConstantWord : /* empty */
| T_CONSTANT
;
OptSignalWord : /* empty */
{ printf("empty: %d/%d\n", @$.first_column, @$.last_column); }
| T_SIGNAL
;
OptSignalWord : /* empty */
{ printf("empty: %d/%d\n", @$.first_column, @$.last_column); }
| T_SIGNAL
;
%%
@@ -774,7 +774,7 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
## No users destructors if stack 0 deleted. See ##
## No users destructors if stack 0 deleted. See ##
## <http://lists.gnu.org/archive/html/bison-patches/2005-09/msg00109.html>. ##
## ------------------------------------------------------------------------- ##
@@ -855,7 +855,7 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
## Corrupted semantic options if user action cuts parse. ##
## Corrupted semantic options if user action cuts parse. ##
## ------------------------------------------------------------------------- ##
AT_SETUP([Corrupted semantic options if user action cuts parse])
@@ -920,7 +920,7 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
## Undesirable destructors if user action cuts parse. ##
## Undesirable destructors if user action cuts parse. ##
## ------------------------------------------------------------------------- ##
AT_SETUP([Undesirable destructors if user action cuts parse])
@@ -989,7 +989,7 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
## Leaked semantic values if user action cuts parse. ##
## Leaked semantic values if user action cuts parse. ##
## ------------------------------------------------------------------------- ##
AT_SETUP([Leaked semantic values if user action cuts parse])
@@ -1120,7 +1120,7 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
## Incorrect lookahead during deterministic GLR. See ##
## Incorrect lookahead during deterministic GLR. See ##
## <http://lists.gnu.org/archive/html/help-bison/2005-07/msg00017.html> and ##
## <http://lists.gnu.org/archive/html/bison-patches/2006-01/msg00060.html>. ##
## ------------------------------------------------------------------------- ##
@@ -1221,10 +1221,10 @@ print_lookahead (char const *reduction)
{
printf ("'%c', yylval='", yychar);
if (yylval.value > ' ')
printf ("%c", yylval.value);
printf ("%c", yylval.value);
printf ("', yylloc=(%d,%d),(%d,%d)",
yylloc.first_line, yylloc.first_column,
yylloc.last_line, yylloc.last_column);
yylloc.first_line, yylloc.first_column,
yylloc.last_line, yylloc.last_column);
}
printf ("\n");
}
@@ -1258,7 +1258,7 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
## Incorrect lookahead during nondeterministic GLR. ##
## Incorrect lookahead during nondeterministic GLR. ##
## ------------------------------------------------------------------------- ##
AT_SETUP([Incorrect lookahead during nondeterministic GLR])
@@ -1318,7 +1318,7 @@ merge:
| conflict defstate_look 'a' nonconflict2 'b' defstate_shift %dprec 2 {
USE ($3); USE ($5);
print_lookahead ("merge <- conflict defstate_look 'a' nonconflict2 'b'"
" defstate_shift");
" defstate_shift");
}
;
@@ -1365,7 +1365,7 @@ alt1:
USE ($1);
if (yychar != 'd' && yychar != YYEOF)
{
fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
}
}
;
@@ -1374,7 +1374,7 @@ alt2:
USE ($1);
if (yychar != 'd' && yychar != YYEOF)
{
fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
}
}
;
@@ -1383,7 +1383,7 @@ alt3:
USE ($1);
if (yychar != 'd' && yychar != YYEOF)
{
fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
fprintf (stderr, "Incorrect lookahead during stack explosion.\n");
}
}
;
@@ -1391,8 +1391,8 @@ no_look:
{
if (yychar != YYEMPTY)
{
fprintf (stderr,
"Found lookahead where shouldn't during stack explosion.\n");
fprintf (stderr,
"Found lookahead where shouldn't during stack explosion.\n");
}
}
;
@@ -1430,10 +1430,10 @@ print_lookahead (char const *reduction)
{
printf ("'%c', yylval='", yychar);
if (yylval.value > ' ')
printf ("%c", yylval.value);
printf ("%c", yylval.value);
printf ("', yylloc=(%d,%d),(%d,%d)",
yylloc.first_line, yylloc.first_column,
yylloc.last_line, yylloc.last_column);
yylloc.first_line, yylloc.first_column,
yylloc.last_line, yylloc.last_column);
}
printf ("\n");
}
@@ -1478,7 +1478,7 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
## Leaked semantic values when reporting ambiguity. ##
## Leaked semantic values when reporting ambiguity. ##
## ------------------------------------------------------------------------- ##
AT_SETUP([Leaked semantic values when reporting ambiguity])
@@ -1571,7 +1571,7 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
## Leaked lookahead after nondeterministic parse syntax error. ##
## Leaked lookahead after nondeterministic parse syntax error. ##
## ------------------------------------------------------------------------- ##
AT_SETUP([Leaked lookahead after nondeterministic parse syntax error])
@@ -1640,7 +1640,7 @@ AT_CLEANUP
## ------------------------------------------------------------------------- ##
## Uninitialized location when reporting ambiguity. ##
## Uninitialized location when reporting ambiguity. ##
## ------------------------------------------------------------------------- ##
AT_SETUP([Uninitialized location when reporting ambiguity])
@@ -1690,7 +1690,7 @@ static void
yyerror (YYLTYPE *locp, char const *msg)
{
fprintf (stderr, "Error at %d.%d-%d.%d: %s.\n", locp->first_line,
locp->first_column, locp->last_line, locp->last_column, msg);
locp->first_column, locp->last_line, locp->last_column, msg);
}
static int

View File

@@ -418,8 +418,8 @@ AT_JAVA_COMPILE([[YYParser.java]])
# AT_CHECK_JAVA_MINIMAL_W_LEXER([1:DIRECTIVES], [2:LEX_THROWS],
# [3:YYLEX_ACTION], [4:LEXER_BODY], [5:PARSER_ACTION], [6:STYPE],
# [7:POSITION_TYPE], [8:LOCATION_TYPE])
# [3:YYLEX_ACTION], [4:LEXER_BODY], [5:PARSER_ACTION], [6:STYPE],
# [7:POSITION_TYPE], [8:LOCATION_TYPE])
# ---------------------------------------------------------------------
# Check that a mininal parser with DIRECTIVES and a "%code lexer".
# YYLEX is the body of yylex () which throws LEX_THROW.
@@ -454,7 +454,7 @@ m4_define([AT_CHECK_JAVA_MINIMAL_W_LEXER],
# Check that YYParser.java contains exactly COUNT lines matching ^LINE$
# with grep.
m4_define([AT_CHECK_JAVA_GREP],
[AT_CHECK([grep -c '^$1$' YYParser.java], [], [m4_default([$2], [1])
[AT_CHECK([grep -c '^$1$' YYParser.java], [], [m4_default([$2], [1])
])
])
@@ -647,74 +647,74 @@ AT_CLEANUP
AT_SETUP([Java throws specifications])
# %define throws - 0 1 2
# %define lex-throws - 0 1 2
# %code lexer 0 1
# %define throws - 0 1 2
# %define lex-throws - 0 1 2
# %code lexer 0 1
m4_define([AT_JT_lex_throws_define], [m4_case(AT_JT_lex_throws,
-1, [],
0, [[%define lex_throws ""]],
1, [[%define lex_throws "InterruptedException"]],
2, [[%define lex_throws "InterruptedException, IllegalAccessException"]])])
-1, [],
0, [[%define lex_throws ""]],
1, [[%define lex_throws "InterruptedException"]],
2, [[%define lex_throws "InterruptedException, IllegalAccessException"]])])
m4_define([AT_JT_yylex_throws], [m4_case(AT_JT_lex_throws,
-1, [[ throws java.io.IOException]],
0, [],
1, [[ throws InterruptedException]],
2, [[ throws InterruptedException, IllegalAccessException]])])
-1, [[ throws java.io.IOException]],
0, [],
1, [[ throws InterruptedException]],
2, [[ throws InterruptedException, IllegalAccessException]])])
m4_define([AT_JT_yylex_action], [m4_case(AT_JT_lex_throws,
-1, [[throw new java.io.IOException();]],
0, [[return EOF;]],
1, [[throw new InterruptedException();]],
2, [[throw new IllegalAccessException();]])])
-1, [[throw new java.io.IOException();]],
0, [[return EOF;]],
1, [[throw new InterruptedException();]],
2, [[throw new IllegalAccessException();]])])
m4_define([AT_JT_throws_define], [m4_case(AT_JT_throws,
-1, [],
0, [[%define throws ""]],
1, [[%define throws "ClassNotFoundException"]],
2, [[%define throws "ClassNotFoundException, InstantiationException"]])])
-1, [],
0, [[%define throws ""]],
1, [[%define throws "ClassNotFoundException"]],
2, [[%define throws "ClassNotFoundException, InstantiationException"]])])
m4_define([AT_JT_yyaction_throws], [m4_case(AT_JT_throws,
-1, [],
0, [],
1, [[ throws ClassNotFoundException]],
2, [[ throws ClassNotFoundException, InstantiationException]])])
-1, [],
0, [],
1, [[ throws ClassNotFoundException]],
2, [[ throws ClassNotFoundException, InstantiationException]])])
m4_define([AT_JT_parse_throws_2], [m4_case(AT_JT_throws,
-1, [],
0, [],
1, [[, ClassNotFoundException]],
2, [[, ClassNotFoundException, InstantiationException]])])
-1, [],
0, [],
1, [[, ClassNotFoundException]],
2, [[, ClassNotFoundException, InstantiationException]])])
m4_define([AT_JT_parse_throws],
[m4_if(m4_quote(AT_JT_yylex_throws), [],
[AT_JT_yyaction_throws],
[AT_JT_yylex_throws[]AT_JT_parse_throws_2])])
[m4_if(m4_quote(AT_JT_yylex_throws), [],
[AT_JT_yyaction_throws],
[AT_JT_yylex_throws[]AT_JT_parse_throws_2])])
m4_define([AT_JT_initial_action], [m4_case(AT_JT_throws,
-1, [],
0, [],
1, [[%initial-action {if (true) throw new ClassNotFoundException();}]],
2, [[%initial-action {if (true) throw new InstantiationException();}]])])
-1, [],
0, [],
1, [[%initial-action {if (true) throw new ClassNotFoundException();}]],
2, [[%initial-action {if (true) throw new InstantiationException();}]])])
m4_define([AT_JT_parse_action], [m4_case(AT_JT_throws,
-1, [],
0, [],
1, [[throw new ClassNotFoundException();]],
2, [[throw new ClassNotFoundException();]])])
-1, [],
0, [],
1, [[throw new ClassNotFoundException();]],
2, [[throw new ClassNotFoundException();]])])
m4_for([AT_JT_lexer], 0, 1, 1,
[m4_for([AT_JT_lex_throws], -1, 2, 1,
[m4_for([AT_JT_throws], -1, 2, 1,
[m4_if(AT_JT_lexer, 0,
[AT_CHECK_JAVA_MINIMAL([
[AT_CHECK_JAVA_MINIMAL([
AT_JT_throws_define
AT_JT_lex_throws_define
AT_JT_initial_action],
[AT_JT_parse_action])],
[AT_CHECK_JAVA_MINIMAL_W_LEXER([
[AT_CHECK_JAVA_MINIMAL_W_LEXER([
AT_JT_throws_define
AT_JT_lex_throws_define
AT_JT_initial_action],

View File

@@ -116,34 +116,34 @@ m4_pushdef([AT_TOKEN_PREFIX],
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
[$2])])
[$2])])
# yyerror always sees the locations (when activated), except if
# (yacc & pure & !param). FIXME: This is wrong. See the manual.
m4_pushdef([AT_YYERROR_SEES_LOC_IF],
[AT_LOCATION_IF([AT_YACC_IF([AT_PURE_IF([AT_PARAM_IF([$1], [$2])],
[$1])],
[$1])],
[$2])])
[$1])],
[$1])],
[$2])])
# The interface is pure: either because %define api.pure, or because we
# are using the C++ parsers.
m4_pushdef([AT_PURE_LEX_IF],
[AT_PURE_IF([$1],
[AT_SKEL_CC_IF([$1], [$2])])])
[AT_SKEL_CC_IF([$1], [$2])])])
AT_PURE_LEX_IF(
[m4_pushdef([AT_LOC], [(*llocp)])
m4_pushdef([AT_VAL], [(*lvalp)])
m4_pushdef([AT_LEX_FORMALS],
[YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])])
[YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])])
m4_pushdef([AT_LEX_ARGS],
[lvalp[]AT_LOCATION_IF([, llocp])])
[lvalp[]AT_LOCATION_IF([, llocp])])
m4_pushdef([AT_USE_LEX_ARGS],
[(void) lvalp;AT_LOCATION_IF([(void) llocp])])
[(void) lvalp;AT_LOCATION_IF([(void) llocp])])
m4_pushdef([AT_LEX_PRE_FORMALS],
[AT_LEX_FORMALS, ])
[AT_LEX_FORMALS, ])
m4_pushdef([AT_LEX_PRE_ARGS],
[AT_LEX_ARGS, ])
[AT_LEX_ARGS, ])
],
[m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]])
m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]])
@@ -417,7 +417,7 @@ m4_define([AT_QUELL_VALGRIND],
# assume that we are linking too; this is a hack.
m4_define([AT_COMPILE],
[AT_CHECK([$CC $CFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.c])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
0, [ignore], [ignore])])
0, [ignore], [ignore])])
# AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc])
# --------------------------------------------
@@ -428,7 +428,7 @@ m4_define([AT_COMPILE_CXX],
[AT_KEYWORDS(c++)
AT_CHECK([$BISON_CXX_WORKS], 0, ignore, ignore)
AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.cc])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
0, [ignore], [ignore])])
0, [ignore], [ignore])])
# AT_JAVA_COMPILE(SOURCES)
# ------------------------

View File

@@ -40,27 +40,27 @@ $(top_srcdir)/tests/package.m4: $(top_srcdir)/configure
## Test suite. ##
## ------------ ##
TESTSUITE_AT = \
tests/actions.at \
tests/c++.at \
tests/calc.at \
tests/conflicts.at \
tests/cxx-type.at \
tests/existing.at \
tests/glr-regression.at \
tests/headers.at \
tests/input.at \
tests/java.at \
tests/local.at \
tests/named-refs.at \
tests/output.at \
tests/push.at \
tests/reduce.at \
tests/regression.at \
tests/sets.at \
tests/skeletons.at \
tests/synclines.at \
tests/testsuite.at \
TESTSUITE_AT = \
tests/actions.at \
tests/c++.at \
tests/calc.at \
tests/conflicts.at \
tests/cxx-type.at \
tests/existing.at \
tests/glr-regression.at \
tests/headers.at \
tests/input.at \
tests/java.at \
tests/local.at \
tests/named-refs.at \
tests/output.at \
tests/push.at \
tests/reduce.at \
tests/regression.at \
tests/sets.at \
tests/skeletons.at \
tests/synclines.at \
tests/testsuite.at \
tests/torture.at
TESTSUITE = $(top_srcdir)/tests/testsuite

View File

@@ -44,7 +44,7 @@ int yylex (void);
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%precedence NEG /* negation--unary minus */
@@ -215,7 +215,7 @@ int yylex (void);
%token <ival> NUM "number"
%type <ival> exp
%nonassoc '=' /* comparison */
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
%precedence NEG /* negation--unary minus */

View File

@@ -42,65 +42,65 @@ AT_CLEANUP
])
AT_CHECK_OUTPUT([foo.y], [], [-dv],
[foo.output foo.tab.c foo.tab.h])
[foo.output foo.tab.c foo.tab.h])
# Some versions of Valgrind (at least valgrind-3.6.0.SVN-Debian) report
# "fgrep: write error: Bad file descriptor" when stdout is closed, so we
# skip this test group during maintainer-check-valgrind.
AT_CHECK_OUTPUT([foo.y], [], [-dv],
[foo.output foo.tab.c foo.tab.h],
[>&-], [],
[AT_CHECK([[case "$PREBISON" in *valgrind*) exit 77;; esac]])])
[foo.output foo.tab.c foo.tab.h],
[>&-], [],
[AT_CHECK([[case "$PREBISON" in *valgrind*) exit 77;; esac]])])
AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
[foo.c foo.h foo.output])
[foo.c foo.h foo.output])
AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],
[foo.output foo.tab.c foo.tab.h])
[foo.output foo.tab.c foo.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -y],
[y.output y.tab.c y.tab.h])
[y.output y.tab.c y.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -b bar],
[bar.output bar.tab.c bar.tab.h])
[bar.output bar.tab.c bar.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c],
[foo.c foo.dot foo.h foo.output])
[foo.c foo.dot foo.h foo.output])
AT_CHECK_OUTPUT([foo.y], [%defines %verbose], [],
[foo.output foo.tab.c foo.tab.h])
[foo.output foo.tab.c foo.tab.h])
AT_CHECK_OUTPUT([foo.y], [%defines %verbose %yacc],[],
[y.output y.tab.c y.tab.h])
[y.output y.tab.c y.tab.h])
AT_CHECK_OUTPUT([foo.yy], [%defines %verbose %yacc],[],
[y.output y.tab.c y.tab.h])
[y.output y.tab.c y.tab.h])
# Exercise %output and %file-prefix including deprecated `='
AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %defines %verbose], [],
[bar.output bar.tab.c bar.tab.h])
[bar.output bar.tab.c bar.tab.h])
AT_CHECK_OUTPUT([foo.y], [%output="bar.c" %defines %verbose %yacc],[],
[bar.output bar.c bar.h])
[bar.output bar.c bar.h])
AT_CHECK_OUTPUT([foo.y],
[%file-prefix="baz" %output "bar.c" %defines %verbose %yacc],
[],
[bar.output bar.c bar.h])
[%file-prefix="baz" %output "bar.c" %defines %verbose %yacc],
[],
[bar.output bar.c bar.h])
# Check priorities of extension control.
AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [],
[foo.output foo.tab.cc foo.tab.hh])
[foo.output foo.tab.cc foo.tab.hh])
AT_CHECK_OUTPUT([foo.yy], [%defines %verbose ], [-o foo.c],
[foo.c foo.h foo.output])
[foo.c foo.h foo.output])
AT_CHECK_OUTPUT([foo.yy], [],
[--defines=foo.hpp -o foo.c++],
[foo.c++ foo.hpp])
[--defines=foo.hpp -o foo.c++],
[foo.c++ foo.hpp])
AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"],
[-o foo.c++],
[foo.c++ foo.hpp])
[-o foo.c++],
[foo.c++ foo.hpp])
AT_CHECK_OUTPUT([foo.yy], [],
[-o foo.c++ --graph=foo.gph],
[foo.c++ foo.gph])
[-o foo.c++ --graph=foo.gph],
[foo.c++ foo.gph])
## ------------ ##
@@ -114,29 +114,29 @@ AT_CHECK([grep 'include .subdir/' $1.hh], 1, [])
])
AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
[foo.tab.cc foo.tab.hh foo.output stack.hh])
[foo.tab.cc foo.tab.hh foo.output stack.hh])
AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations], [],
[foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh])
[foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh])
AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
[foo.tab.cc foo.tab.hh foo.output stack.hh],
[], [AT_CHECK_NO_SUBDIR_PART([foo.tab])])
[foo.tab.cc foo.tab.hh foo.output stack.hh],
[], [AT_CHECK_NO_SUBDIR_PART([foo.tab])])
AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations],
[-o subdir/foo.cc],
[subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh],
[], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
[-o subdir/foo.cc],
[subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh],
[], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
AT_CHECK_OUTPUT([gram_dir/foo.yy],
[%skeleton "lalr1.cc" %defines %verbose %file-prefix "output_dir/foo"],
[],
[output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/foo.output output_dir/stack.hh])
[output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/foo.output output_dir/stack.hh])
AT_CHECK_OUTPUT([gram_dir/foo.yy],
[%skeleton "lalr1.cc" %defines %locations %verbose %file-prefix "output_dir/foo"],
[],
[output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/foo.output output_dir/location.hh output_dir/stack.hh output_dir/position.hh])
[output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/foo.output output_dir/location.hh output_dir/stack.hh output_dir/position.hh])
# AT_CHECK_CONFLICTING_OUTPUT(INPUT-FILE, DIRECTIVES, FLAGS, STDERR,

View File

@@ -532,7 +532,7 @@ AT_SETUP([Web2c Report])
AT_KEYWORDS([report])
AT_DATA([input.y],
[[%token undef_id_tok const_id_tok
[[%token undef_id_tok const_id_tok
%start CONST_DEC_PART
@@ -542,12 +542,12 @@ CONST_DEC_PART:
;
CONST_DEC_LIST:
CONST_DEC
CONST_DEC
| CONST_DEC_LIST CONST_DEC
;
CONST_DEC:
{ } undef_id_tok '=' const_id_tok ';'
{ } undef_id_tok '=' const_id_tok ';'
;
%%
]])
@@ -1062,7 +1062,7 @@ static int yylex (void);
start:
{
printf ("Bison would once convert this action to a midrule because of the"
" subsequent braced code.\n");
" subsequent braced code.\n");
}
;

View File

@@ -288,15 +288,15 @@ mv stdout expout
# Get the final state in the report, from the "accept" action..
AT_CHECK([sed -n '
/^state \(.*\)/{
s//final state \1/
x
}
/ accept/{
x
p
q
}
' input.output],
0, [expout])
s//final state \1/
x
}
/ accept/{
x
p
q
}
' input.output],
0, [expout])
AT_CLEANUP

View File

@@ -1,4 +1,4 @@
# Test suite for GNU Bison. -*- Autotest -*-
# Test suite for GNU Bison. -*- Autotest -*-
# Copyright (C) 2000-2004, 2006-2007, 2009-2011 Free Software
# Foundation, Inc.

View File

@@ -89,9 +89,9 @@ for my $size (1 .. $max)
{
use Text::Wrap;
print wrap ("| ", " ",
(map { "\"$_\"" } (1 .. $size)),
" END \n"),
" { \$\$ = $size; }\n";
(map { "\"$_\"" } (1 .. $size)),
" END \n"),
" { \$\$ = $size; }\n";
};
print ";\n";
@@ -190,7 +190,7 @@ EOF
use Text::Wrap;
print
wrap ("exp: ", " ",
(map { "\"$_\"" } (1 .. $max)), ";"),
(map { "\"$_\"" } (1 .. $max)), ";"),
"\n";
print <<EOF;
@@ -292,8 +292,8 @@ EOF
print
wrap ("%type <val> ",
" ",
map { "n$_" } (1 .. $max)),
" ",
map { "n$_" } (1 .. $max)),
"\n";
print "%token\n";
@@ -334,7 +334,7 @@ yylex (void)
if (counter > $max)
{
if (counter++ != $max + 1)
abort ();
abort ();
return 0;
}
if (return_token)
@@ -435,8 +435,8 @@ main (int argc, const char **argv)
abort ();
yylval_init = strtol (argv[1], &endp, 10);
if (! (argv[1] != endp
&& 0 <= yylval_init && yylval_init <= INT_MAX
&& errno != ERANGE))
&& 0 <= yylval_init && yylval_init <= INT_MAX
&& errno != ERANGE))
abort ();
yydebug = 1;
{