mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
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:
16
ChangeLog
16
ChangeLog
@@ -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>
|
2011-07-10 Joel E. Denny <joeldenny@joeldenny.org>
|
||||||
|
|
||||||
build: avoid YACC typo inherited from Autoconf.
|
build: avoid YACC typo inherited from Autoconf.
|
||||||
|
|||||||
22
NEWS
22
NEWS
@@ -894,26 +894,26 @@ Bison News
|
|||||||
if the symbols have destructors. For instance:
|
if the symbols have destructors. For instance:
|
||||||
|
|
||||||
exp: exp "?" exp ":" exp { $1 ? $1 : $3; }
|
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
|
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
|
the second ($1 is copied to $$ by the default rule). This example
|
||||||
most likely contains three errors, and could be rewritten as:
|
most likely contains three errors, and could be rewritten as:
|
||||||
|
|
||||||
exp: exp "?" exp ":" exp
|
exp: exp "?" exp ":" exp
|
||||||
{ $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); }
|
{ $$ = $1 ? $3 : $5; free ($1 ? $5 : $3); free ($1); }
|
||||||
| exp "+" exp
|
| exp "+" exp
|
||||||
{ $$ = $1 ? $1 : $3; if ($1) free ($3); }
|
{ $$ = $1 ? $1 : $3; if ($1) free ($3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
However, if the original actions were really intended, memory leaks
|
However, if the original actions were really intended, memory leaks
|
||||||
and all, the warnings can be suppressed by letting Bison believe the
|
and all, the warnings can be suppressed by letting Bison believe the
|
||||||
values are used, e.g.:
|
values are used, e.g.:
|
||||||
|
|
||||||
exp: exp "?" exp ":" exp { $1 ? $1 : $3; (void) ($$, $5); }
|
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
|
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.
|
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
|
In agreement with POSIX and with other Yaccs, leaving a default
|
||||||
action is valid when $$ is untyped, and $1 typed:
|
action is valid when $$ is untyped, and $1 typed:
|
||||||
|
|
||||||
untyped: ... typed;
|
untyped: ... typed;
|
||||||
|
|
||||||
but the converse remains an error:
|
but the converse remains an error:
|
||||||
|
|
||||||
typed: ... untyped;
|
typed: ... untyped;
|
||||||
|
|
||||||
** Values of mid-rule actions
|
** Values of mid-rule actions
|
||||||
The following code:
|
The following code:
|
||||||
|
|
||||||
foo: { ... } { $$ = $1; } ...
|
foo: { ... } { $$ = $1; } ...
|
||||||
|
|
||||||
was incorrectly rejected: $1 is defined in the second mid-rule
|
was incorrectly rejected: $1 is defined in the second mid-rule
|
||||||
action, and is equal to the $$ of the first mid-rule action.
|
action, and is equal to the $$ of the first mid-rule action.
|
||||||
|
|||||||
@@ -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
|
(comparable to assert/abort), and all the --trace output which is
|
||||||
meant for the maintainers only.
|
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
|
* Working from the repository
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ LALR(1) Look-Ahead Sets", ACM Transactions on Programming Languages
|
|||||||
and Systems (TOPLAS) 4, 4 (October 1982), 615-649. Their
|
and Systems (TOPLAS) 4, 4 (October 1982), 615-649. Their
|
||||||
technique is the standard one now.)
|
technique is the standard one now.)
|
||||||
|
|
||||||
paul rubin
|
paul rubin
|
||||||
free software foundation
|
free software foundation
|
||||||
|
|
||||||
|
|
||||||
[DeRemer-Pennello reference corrected by Paul Eggert <eggert@cs.ucla.edu>,
|
[DeRemer-Pennello reference corrected by Paul Eggert <eggert@cs.ucla.edu>,
|
||||||
|
|||||||
44
TODO
44
TODO
@@ -166,11 +166,11 @@ what it should look like. For instance what follows crashes.
|
|||||||
The code in yyerrlab reads:
|
The code in yyerrlab reads:
|
||||||
|
|
||||||
if (yychar <= YYEOF)
|
if (yychar <= YYEOF)
|
||||||
{
|
{
|
||||||
/* Return failure if at end of input. */
|
/* Return failure if at end of input. */
|
||||||
if (yychar == YYEOF)
|
if (yychar == YYEOF)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
There are only two yychar that can be <= YYEOF: YYEMPTY and YYEOF.
|
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
|
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
|
We should find a means to provide an access to values deep in the
|
||||||
stack. For instance, instead of
|
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:
|
we should be able to have:
|
||||||
|
|
||||||
@@ -313,13 +313,13 @@ XML output for GNU Bison
|
|||||||
* Unit rules
|
* Unit rules
|
||||||
Maybe we could expand unit rules, i.e., transform
|
Maybe we could expand unit rules, i.e., transform
|
||||||
|
|
||||||
exp: arith | bool;
|
exp: arith | bool;
|
||||||
arith: exp '+' exp;
|
arith: exp '+' exp;
|
||||||
bool: exp '&' exp;
|
bool: exp '&' exp;
|
||||||
|
|
||||||
into
|
into
|
||||||
|
|
||||||
exp: exp '+' exp | exp '&' exp;
|
exp: exp '+' exp | exp '&' exp;
|
||||||
|
|
||||||
when there are no actions. This can significantly speed up some
|
when there are no actions. This can significantly speed up some
|
||||||
grammars. I can't find the papers. In particular the book `LR
|
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
|
* Coding system independence
|
||||||
Paul notes:
|
Paul notes:
|
||||||
|
|
||||||
Currently Bison assumes 8-bit bytes (i.e. that UCHAR_MAX is
|
Currently Bison assumes 8-bit bytes (i.e. that UCHAR_MAX is
|
||||||
255). It also assumes that the 8-bit character encoding is
|
255). It also assumes that the 8-bit character encoding is
|
||||||
the same for the invocation of 'bison' as it is for the
|
the same for the invocation of 'bison' as it is for the
|
||||||
invocation of 'cc', but this is not necessarily true when
|
invocation of 'cc', but this is not necessarily true when
|
||||||
people run bison on an ASCII host and then use cc on an EBCDIC
|
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
|
host. I don't think these topics are worth our time
|
||||||
addressing (unless we find a gung-ho volunteer for EBCDIC or
|
addressing (unless we find a gung-ho volunteer for EBCDIC or
|
||||||
PDP-10 ports :-) but they should probably be documented
|
PDP-10 ports :-) but they should probably be documented
|
||||||
somewhere.
|
somewhere.
|
||||||
|
|
||||||
More importantly, Bison does not currently allow NUL bytes in
|
More importantly, Bison does not currently allow NUL bytes in
|
||||||
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
|
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
|
||||||
the source code. This should get fixed.
|
the source code. This should get fixed.
|
||||||
|
|
||||||
* --graph
|
* --graph
|
||||||
Show reductions.
|
Show reductions.
|
||||||
|
|||||||
@@ -18,50 +18,50 @@ while (<STDIN>)
|
|||||||
\s # Spaces.
|
\s # Spaces.
|
||||||
/x)
|
/x)
|
||||||
{
|
{
|
||||||
my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
|
my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
|
||||||
$short = '' if ! defined $short;
|
$short = '' if ! defined $short;
|
||||||
$short = '-d' if $long eq '--defines' && ! $short;
|
$short = '-d' if $long eq '--defines' && ! $short;
|
||||||
my $dir = '%' . substr($long, 2);
|
my $dir = '%' . substr($long, 2);
|
||||||
if (index ($scanner, "\"$dir\"") < 0)
|
if (index ($scanner, "\"$dir\"") < 0)
|
||||||
{
|
{
|
||||||
if ($long eq '--force-define') { $dir = '%define'; }
|
if ($long eq '--force-define') { $dir = '%define'; }
|
||||||
else { $dir = ''; }
|
else { $dir = ''; }
|
||||||
}
|
}
|
||||||
if ($arg)
|
if ($arg)
|
||||||
{
|
{
|
||||||
# if $opt, $arg contains the closing ].
|
# if $opt, $arg contains the closing ].
|
||||||
substr ($arg, -1) = ''
|
substr ($arg, -1) = ''
|
||||||
if $opt eq '[';
|
if $opt eq '[';
|
||||||
$arg =~ s/^=//;
|
$arg =~ s/^=//;
|
||||||
$arg = lc ($arg);
|
$arg = lc ($arg);
|
||||||
my $dir_arg = $arg;
|
my $dir_arg = $arg;
|
||||||
# If the argument is compite (e.g., for --define[=NAME[=VALUE]]),
|
# If the argument is compite (e.g., for --define[=NAME[=VALUE]]),
|
||||||
# put each word in @var, to build @var{name}[=@var{value}], not
|
# put each word in @var, to build @var{name}[=@var{value}], not
|
||||||
# @var{name[=value]}].
|
# @var{name[=value]}].
|
||||||
$arg =~ s/(\w+)/\@var{$1}/g;
|
$arg =~ s/(\w+)/\@var{$1}/g;
|
||||||
my $long_arg = "=$arg";
|
my $long_arg = "=$arg";
|
||||||
if ($opt eq '[') {
|
if ($opt eq '[') {
|
||||||
$long_arg = "[$long_arg]";
|
$long_arg = "[$long_arg]";
|
||||||
$arg = "[$arg]";
|
$arg = "[$arg]";
|
||||||
}
|
}
|
||||||
# For arguments of directives: this only works if all arguments
|
# For arguments of directives: this only works if all arguments
|
||||||
# are strings and have the same syntax as on the command line.
|
# are strings and have the same syntax as on the command line.
|
||||||
if ($dir_arg eq 'name[=value]')
|
if ($dir_arg eq 'name[=value]')
|
||||||
{
|
{
|
||||||
$dir_arg = '@var{name} ["@var{value}"]';
|
$dir_arg = '@var{name} ["@var{value}"]';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$dir_arg =~ s/(\w+)/\@var{"$1"}/g;
|
$dir_arg =~ s/(\w+)/\@var{"$1"}/g;
|
||||||
$dir_arg = '[' . $dir_arg . ']'
|
$dir_arg = '[' . $dir_arg . ']'
|
||||||
if $opt eq '[';
|
if $opt eq '[';
|
||||||
}
|
}
|
||||||
$long = "$long$long_arg";
|
$long = "$long$long_arg";
|
||||||
$short = "$short $arg" if $short && $short ne '-d';
|
$short = "$short $arg" if $short && $short ne '-d';
|
||||||
$dir = "$dir $dir_arg" if $dir;
|
$dir = "$dir $dir_arg" if $dir;
|
||||||
}
|
}
|
||||||
$option{$long} = $short;
|
$option{$long} = $short;
|
||||||
$directive{$long} = $dir;
|
$directive{$long} = $dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
EXTRA_DIST += \
|
EXTRA_DIST += \
|
||||||
build-aux/cross-options.pl \
|
build-aux/cross-options.pl \
|
||||||
build-aux/move-if-change \
|
build-aux/move-if-change \
|
||||||
build-aux/prev-version.txt \
|
build-aux/prev-version.txt \
|
||||||
build-aux/update-b4-copyright
|
build-aux/update-b4-copyright
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ AC_ARG_ENABLE(gcc-warnings,
|
|||||||
yes|no) ;;
|
yes|no) ;;
|
||||||
*) AC_MSG_ERROR([bad value ${enableval} for gcc-warnings option]) ;;
|
*) AC_MSG_ERROR([bad value ${enableval} for gcc-warnings option]) ;;
|
||||||
esac],
|
esac],
|
||||||
[enableval=no])
|
[enableval=no])
|
||||||
if test "${enableval}" = yes; then
|
if test "${enableval}" = yes; then
|
||||||
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
|
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
|
||||||
AC_SUBST([WERROR_CFLAGS])
|
AC_SUBST([WERROR_CFLAGS])
|
||||||
@@ -175,7 +175,7 @@ do
|
|||||||
eval "test x\$$ac_var = x || $ac_var=lib/\$$ac_var"
|
eval "test x\$$ac_var = x || $ac_var=lib/\$$ac_var"
|
||||||
done
|
done
|
||||||
AC_CONFIG_FILES([Makefile
|
AC_CONFIG_FILES([Makefile
|
||||||
po/Makefile.in
|
po/Makefile.in
|
||||||
examples/calc++/Makefile
|
examples/calc++/Makefile
|
||||||
doc/yacc.1])
|
doc/yacc.1])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
@@ -304,8 +304,8 @@ m4_define([b4_parser_tables_define],
|
|||||||
m4_define([b4_flag_if],
|
m4_define([b4_flag_if],
|
||||||
[m4_case(b4_$1_flag,
|
[m4_case(b4_$1_flag,
|
||||||
[0], [$3],
|
[0], [$3],
|
||||||
[1], [$2],
|
[1], [$2],
|
||||||
[m4_fatal([invalid $1 value: ]$1)])])
|
[m4_fatal([invalid $1 value: ]$1)])])
|
||||||
|
|
||||||
|
|
||||||
# b4_define_flag_if(FLAG)
|
# b4_define_flag_if(FLAG)
|
||||||
@@ -330,10 +330,10 @@ m4_define([b4_$3_if],
|
|||||||
# b4_FLAG_if(IF-TRUE, IF-FALSE)
|
# b4_FLAG_if(IF-TRUE, IF-FALSE)
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
|
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
|
||||||
b4_define_flag_if([defines]) # Whether headers are requested.
|
b4_define_flag_if([defines]) # Whether headers are requested.
|
||||||
b4_define_flag_if([glr]) # Whether a GLR parser is 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([nondeterministic]) # Whether conflicts should be handled.
|
||||||
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
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_dollar_dollar([b4_symbol([$1], [number])],
|
||||||
[b4_symbol([$1], [tag])],
|
[b4_symbol([$1], [tag])],
|
||||||
[b4_symbol([$1], [type])]);
|
[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]])
|
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
|
||||||
m4_define([b4_percent_define_ifdef],
|
m4_define([b4_percent_define_ifdef],
|
||||||
[m4_ifdef([b4_percent_define(]$1[)],
|
[m4_ifdef([b4_percent_define(]$1[)],
|
||||||
[b4_percent_define_use([$1])$2],
|
[b4_percent_define_use([$1])$2],
|
||||||
[$3])])
|
[$3])])
|
||||||
|
|
||||||
|
|
||||||
## --------- ##
|
## --------- ##
|
||||||
@@ -765,7 +765,7 @@ m4_popdef([b4_macro_name])])
|
|||||||
m4_define([b4_percent_code_ifdef],
|
m4_define([b4_percent_code_ifdef],
|
||||||
[m4_ifdef([b4_percent_code(]$1[)],
|
[m4_ifdef([b4_percent_code(]$1[)],
|
||||||
[m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])$2],
|
[m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])$2],
|
||||||
[$3])])
|
[$3])])
|
||||||
|
|
||||||
|
|
||||||
## ------------------ ##
|
## ------------------ ##
|
||||||
|
|||||||
12
data/c++.m4
12
data/c++.m4
@@ -405,24 +405,24 @@ m4_define([b4_parse_param_decl_1],
|
|||||||
# Extra initialisations of the constructor.
|
# Extra initialisations of the constructor.
|
||||||
m4_define([b4_parse_param_cons],
|
m4_define([b4_parse_param_cons],
|
||||||
[m4_ifset([b4_parse_param],
|
[m4_ifset([b4_parse_param],
|
||||||
[
|
[
|
||||||
b4_cc_constructor_calls(b4_parse_param)])])
|
b4_cc_constructor_calls(b4_parse_param)])])
|
||||||
m4_define([b4_cc_constructor_calls],
|
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],
|
m4_define([b4_cc_constructor_call],
|
||||||
[$2 ($2_yyarg)])
|
[$2 ($2_yyarg)])
|
||||||
|
|
||||||
# b4_parse_param_vars
|
# b4_parse_param_vars
|
||||||
# -------------------
|
# -------------------
|
||||||
# Extra instance variables.
|
# Extra instance variables.
|
||||||
m4_define([b4_parse_param_vars],
|
m4_define([b4_parse_param_vars],
|
||||||
[m4_ifset([b4_parse_param],
|
[m4_ifset([b4_parse_param],
|
||||||
[
|
[
|
||||||
/* User arguments. */
|
/* User arguments. */
|
||||||
b4_cc_var_decls(b4_parse_param)])])
|
b4_cc_var_decls(b4_parse_param)])])
|
||||||
m4_define([b4_cc_var_decls],
|
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],
|
m4_define([b4_cc_var_decl],
|
||||||
[ $1;])
|
[ $1;])
|
||||||
|
|||||||
26
data/c.m4
26
data/c.m4
@@ -146,7 +146,7 @@ m4_define([b4_int_type],
|
|||||||
|
|
||||||
m4_eval([0 <= $1]), [1], [unsigned int],
|
m4_eval([0 <= $1]), [1], [unsigned int],
|
||||||
|
|
||||||
[int])])
|
[int])])
|
||||||
|
|
||||||
|
|
||||||
# b4_int_type_for(NAME)
|
# b4_int_type_for(NAME)
|
||||||
@@ -235,7 +235,7 @@ m4_define([b4_token_enums],
|
|||||||
enum yytokentype {
|
enum yytokentype {
|
||||||
m4_map_sep([ b4_token_enum], [,
|
m4_map_sep([ b4_token_enum], [,
|
||||||
],
|
],
|
||||||
[$@])
|
[$@])
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
])])
|
])])
|
||||||
@@ -314,7 +314,7 @@ $1 (b4_c_ansi_formals(m4_shift2($@)))[]dnl
|
|||||||
m4_define([b4_c_ansi_formals],
|
m4_define([b4_c_ansi_formals],
|
||||||
[m4_if([$#], [0], [void],
|
[m4_if([$#], [0], [void],
|
||||||
[$#$1], [1], [void],
|
[$#$1], [1], [void],
|
||||||
[m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
|
[m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])
|
||||||
|
|
||||||
m4_define([b4_c_ansi_formal],
|
m4_define([b4_c_ansi_formal],
|
||||||
[$1])
|
[$1])
|
||||||
@@ -335,9 +335,9 @@ m4_define([b4_c_knr_formal_name],
|
|||||||
# Output the K&R argument declarations.
|
# Output the K&R argument declarations.
|
||||||
m4_define([b4_c_knr_formal_decls],
|
m4_define([b4_c_knr_formal_decls],
|
||||||
[m4_map_sep([b4_c_knr_formal_decl],
|
[m4_map_sep([b4_c_knr_formal_decl],
|
||||||
[
|
[
|
||||||
],
|
],
|
||||||
[$@])])
|
[$@])])
|
||||||
|
|
||||||
m4_define([b4_c_knr_formal_decl],
|
m4_define([b4_c_knr_formal_decl],
|
||||||
[ $1;])
|
[ $1;])
|
||||||
@@ -457,7 +457,7 @@ b4_parse_param_use[]dnl
|
|||||||
{
|
{
|
||||||
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
||||||
[ default:
|
[ default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}]dnl
|
}]dnl
|
||||||
])
|
])
|
||||||
@@ -477,9 +477,9 @@ m4_define_default([b4_yy_symbol_print_generate],
|
|||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
]$1([yy_symbol_value_print],
|
]$1([yy_symbol_value_print],
|
||||||
[static void],
|
[static void],
|
||||||
[[FILE *yyoutput], [yyoutput]],
|
[[FILE *yyoutput], [yyoutput]],
|
||||||
[[int yytype], [yytype]],
|
[[int yytype], [yytype]],
|
||||||
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
||||||
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
||||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||||
{
|
{
|
||||||
@@ -498,7 +498,7 @@ b4_parse_param_use[]dnl
|
|||||||
{
|
{
|
||||||
]b4_symbol_foreach([b4_symbol_printer])dnl
|
]b4_symbol_foreach([b4_symbol_printer])dnl
|
||||||
[ default:
|
[ default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,9 +509,9 @@ b4_parse_param_use[]dnl
|
|||||||
|
|
||||||
]$1([yy_symbol_print],
|
]$1([yy_symbol_print],
|
||||||
[static void],
|
[static void],
|
||||||
[[FILE *yyoutput], [yyoutput]],
|
[[FILE *yyoutput], [yyoutput]],
|
||||||
[[int yytype], [yytype]],
|
[[int yytype], [yytype]],
|
||||||
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
|
||||||
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
|
||||||
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
m4_ifset([b4_parse_param], [, b4_parse_param]))[
|
||||||
{
|
{
|
||||||
|
|||||||
1348
data/glr.c
1348
data/glr.c
File diff suppressed because it is too large
Load Diff
54
data/glr.cc
54
data/glr.cc
@@ -77,9 +77,9 @@ m4_define([b4_yy_symbol_print_generate],
|
|||||||
[[FILE *], []],
|
[[FILE *], []],
|
||||||
[[int yytype], [yytype]],
|
[[int yytype], [yytype]],
|
||||||
[[const b4_namespace_ref::b4_parser_class_name::semantic_type *yyvaluep],
|
[[const b4_namespace_ref::b4_parser_class_name::semantic_type *yyvaluep],
|
||||||
[yyvaluep]],
|
[yyvaluep]],
|
||||||
[[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp],
|
[[const b4_namespace_ref::b4_parser_class_name::location_type *yylocationp],
|
||||||
[yylocationp]],
|
[yylocationp]],
|
||||||
b4_parse_param)[
|
b4_parse_param)[
|
||||||
{
|
{
|
||||||
]b4_parse_param_use[]dnl
|
]b4_parse_param_use[]dnl
|
||||||
@@ -146,7 +146,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
|||||||
|
|
||||||
inline void
|
inline void
|
||||||
]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,
|
]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. */
|
/* Pacify ``unused variable'' warnings. */
|
||||||
YYUSE (yyvaluep);
|
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
|
]b4_symbol_foreach([b4_symbol_printer])dnl
|
||||||
[ default:
|
[ default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
]b4_parser_class_name[::yy_symbol_print_ (int yytype,
|
]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")
|
*yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm")
|
||||||
<< ' ' << yytname[yytype] << " ("
|
<< ' ' << yytname[yytype] << " ("
|
||||||
<< *yylocationp << ": ";
|
<< *yylocationp << ": ";
|
||||||
yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
|
yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
|
||||||
*yycdebug_ << ')';
|
*yycdebug_ << ')';
|
||||||
}
|
}
|
||||||
@@ -205,10 +205,10 @@ b4_namespace_close[
|
|||||||
# Let glr.c believe that the user arguments include the parser itself.
|
# Let glr.c believe that the user arguments include the parser itself.
|
||||||
m4_ifset([b4_parse_param],
|
m4_ifset([b4_parse_param],
|
||||||
[m4_pushdef([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_defn([b4_parse_param])))],
|
||||||
[m4_pushdef([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_include(b4_pkgdatadir/[glr.c])
|
||||||
m4_popdef([b4_parse_param])
|
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). */
|
the previous symbol: RHS[0] (always defined). */
|
||||||
|
|
||||||
#ifndef YYLLOC_DEFAULT
|
#ifndef YYLLOC_DEFAULT
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
do \
|
do \
|
||||||
if (N) \
|
if (N) \
|
||||||
{ \
|
{ \
|
||||||
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
|
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
|
||||||
(Current).end = YYRHSLOC (Rhs, N).end; \
|
(Current).end = YYRHSLOC (Rhs, N).end; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
||||||
} \
|
} \
|
||||||
while (/*CONSTCOND*/ 0)
|
while (/*CONSTCOND*/ 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -298,15 +298,15 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
|||||||
/// \param yyvaluep Its semantic value.
|
/// \param yyvaluep Its semantic value.
|
||||||
/// \param yylocationp Its location.
|
/// \param yylocationp Its location.
|
||||||
virtual void yy_symbol_value_print_ (int yytype,
|
virtual void yy_symbol_value_print_ (int yytype,
|
||||||
const semantic_type* yyvaluep,
|
const semantic_type* yyvaluep,
|
||||||
const location_type* yylocationp);
|
const location_type* yylocationp);
|
||||||
/// \brief Report a symbol on the debug stream.
|
/// \brief Report a symbol on the debug stream.
|
||||||
/// \param yytype The token type.
|
/// \param yytype The token type.
|
||||||
/// \param yyvaluep Its semantic value.
|
/// \param yyvaluep Its semantic value.
|
||||||
/// \param yylocationp Its location.
|
/// \param yylocationp Its location.
|
||||||
virtual void yy_symbol_print_ (int yytype,
|
virtual void yy_symbol_print_ (int yytype,
|
||||||
const semantic_type* yyvaluep,
|
const semantic_type* yyvaluep,
|
||||||
const location_type* yylocationp);
|
const location_type* yylocationp);
|
||||||
private:
|
private:
|
||||||
/* Debugging. */
|
/* Debugging. */
|
||||||
std::ostream* yycdebug_;
|
std::ostream* yycdebug_;
|
||||||
@@ -318,9 +318,9 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
|||||||
/// \param yyvaluep Its semantic value.
|
/// \param yyvaluep Its semantic value.
|
||||||
/// \param yylocationp Its location.
|
/// \param yylocationp Its location.
|
||||||
inline void yydestruct_ (const char* yymsg,
|
inline void yydestruct_ (const char* yymsg,
|
||||||
int yytype,
|
int yytype,
|
||||||
semantic_type* yyvaluep,
|
semantic_type* yyvaluep,
|
||||||
location_type* yylocationp);
|
location_type* yylocationp);
|
||||||
|
|
||||||
]b4_parse_param_vars[
|
]b4_parse_param_vars[
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -426,14 +426,14 @@ b4_percent_code_get[]dnl
|
|||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
# define YY_REDUCE_PRINT(Rule) \
|
# define YY_REDUCE_PRINT(Rule) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug_) \
|
if (yydebug_) \
|
||||||
yy_reduce_print_ (Rule); \
|
yy_reduce_print_ (Rule); \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
# define YY_STACK_PRINT() \
|
# define YY_STACK_PRINT() \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug_) \
|
if (yydebug_) \
|
||||||
yystack_print_ (); \
|
yystack_print_ (); \
|
||||||
} while (false)
|
} while (false)
|
||||||
@@ -575,7 +575,7 @@ b4_percent_code_get[]dnl
|
|||||||
{
|
{
|
||||||
]b4_symbol_foreach([b4_symbol_printer])dnl
|
]b4_symbol_foreach([b4_symbol_printer])dnl
|
||||||
[ default:
|
[ default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
yyo << ')';
|
yyo << ')';
|
||||||
}
|
}
|
||||||
@@ -739,7 +739,7 @@ m4_popdef([b4_at_dollar])])dnl
|
|||||||
[ yyla = b4_c_function_call([yylex], [symbol_type],
|
[ yyla = b4_c_function_call([yylex], [symbol_type],
|
||||||
m4_ifdef([b4_lex_param], b4_lex_param));],
|
m4_ifdef([b4_lex_param], b4_lex_param));],
|
||||||
[ yyla.type = yytranslate_ (b4_c_function_call([yylex], [int],
|
[ yyla.type = yytranslate_ (b4_c_function_call([yylex], [int],
|
||||||
[[YYSTYPE*], [&yyla.value]][]dnl
|
[[YYSTYPE*], [&yyla.value]][]dnl
|
||||||
b4_locations_if([, [[location*], [&yyla.location]]])dnl
|
b4_locations_if([, [[location*], [&yyla.location]]])dnl
|
||||||
m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
||||||
yyempty = false;
|
yyempty = false;
|
||||||
@@ -756,10 +756,10 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
|||||||
yyn = yytable_[yyn];
|
yyn = yytable_[yyn];
|
||||||
if (yyn <= 0)
|
if (yyn <= 0)
|
||||||
{
|
{
|
||||||
if (yy_table_value_is_error_ (yyn))
|
if (yy_table_value_is_error_ (yyn))
|
||||||
goto yyerrlab;
|
goto yyerrlab;
|
||||||
yyn = -yyn;
|
yyn = -yyn;
|
||||||
goto yyreduce;
|
goto yyreduce;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Discard the token being shifted. */
|
/* Discard the token being shifted. */
|
||||||
@@ -818,7 +818,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
|||||||
switch (yyn)
|
switch (yyn)
|
||||||
{
|
{
|
||||||
]b4_user_actions[
|
]b4_user_actions[
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -859,8 +859,8 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
|||||||
/* If not already recovering from an error, report this error. */
|
/* If not already recovering from an error, report this error. */
|
||||||
if (!yyerrstatus_)
|
if (!yyerrstatus_)
|
||||||
{
|
{
|
||||||
++yynerrs_;
|
++yynerrs_;
|
||||||
error (]b4_args(b4_locations_if([yyla.location]),
|
error (]b4_args(b4_locations_if([yyla.location]),
|
||||||
[[yysyntax_error_ (yystack_[0].state,
|
[[yysyntax_error_ (yystack_[0].state,
|
||||||
yyempty ? yyempty_ : yyla.type)]])[);
|
yyempty ? yyempty_ : yyla.type)]])[);
|
||||||
}
|
}
|
||||||
@@ -869,7 +869,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
|||||||
yyerror_range[1].location = yyla.location;]])[
|
yyerror_range[1].location = yyla.location;]])[
|
||||||
if (yyerrstatus_ == 3)
|
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. */
|
error, discard it. */
|
||||||
|
|
||||||
/* Return failure if at end of input. */
|
/* Return failure if at end of input. */
|
||||||
@@ -879,7 +879,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
|||||||
{
|
{
|
||||||
yy_destroy_ ("Error: discarding", yyla);
|
yy_destroy_ ("Error: discarding", yyla);
|
||||||
yyempty = true;
|
yyempty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Else will try to reuse lookahead token after shifting the error
|
/* 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 -- common code for both syntax error and YYERROR. |
|
||||||
`-------------------------------------------------------------*/
|
`-------------------------------------------------------------*/
|
||||||
yyerrlab1:
|
yyerrlab1:
|
||||||
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
|
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
|
||||||
{
|
{
|
||||||
stack_symbol_type error_token;
|
stack_symbol_type error_token;
|
||||||
for (;;)
|
for (;;)
|
||||||
@@ -965,8 +965,8 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
|
|||||||
yypop_ (yylen);
|
yypop_ (yylen);
|
||||||
while (yystack_.size () != 1)
|
while (yystack_.size () != 1)
|
||||||
{
|
{
|
||||||
yy_destroy_ ("Cleanup: popping", yystack_[0]);
|
yy_destroy_ ("Cleanup: popping", yystack_[0]);
|
||||||
yypop_ ();
|
yypop_ ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return yyresult;
|
return yyresult;
|
||||||
@@ -1098,7 +1098,7 @@ b4_error_verbose_if([state_type yystate, int yytoken],
|
|||||||
for (stack_type::const_iterator
|
for (stack_type::const_iterator
|
||||||
i = yystack_.begin (),
|
i = yystack_.begin (),
|
||||||
i_end = yystack_.end ();
|
i_end = yystack_.end ();
|
||||||
i != i_end; ++i)
|
i != i_end; ++i)
|
||||||
*yycdebug_ << ' ' << i->state;
|
*yycdebug_ << ' ' << i->state;
|
||||||
*yycdebug_ << std::endl;
|
*yycdebug_ << std::endl;
|
||||||
}
|
}
|
||||||
@@ -1111,7 +1111,7 @@ b4_error_verbose_if([state_type yystate, int yytoken],
|
|||||||
int yynrhs = yyr2_[yyrule];
|
int yynrhs = yyr2_[yyrule];
|
||||||
/* Print the symbols being reduced, and their result. */
|
/* Print the symbols being reduced, and their result. */
|
||||||
*yycdebug_ << "Reducing stack by rule " << yyrule - 1
|
*yycdebug_ << "Reducing stack by rule " << yyrule - 1
|
||||||
<< " (line " << yylno << "):" << std::endl;
|
<< " (line " << yylno << "):" << std::endl;
|
||||||
/* The symbols being reduced. */
|
/* The symbols being reduced. */
|
||||||
for (int yyi = 0; yyi < yynrhs; yyi++)
|
for (int yyi = 0; yyi < yynrhs; yyi++)
|
||||||
YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
|
YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
|
||||||
|
|||||||
@@ -13,32 +13,32 @@
|
|||||||
## You should have received a copy of the GNU General Public License
|
## You should have received a copy of the GNU General Public License
|
||||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
dist_pkgdata_DATA = \
|
dist_pkgdata_DATA = \
|
||||||
data/README \
|
data/README \
|
||||||
data/bison.m4 \
|
data/bison.m4 \
|
||||||
data/c++-skel.m4 \
|
data/c++-skel.m4 \
|
||||||
data/c++.m4 \
|
data/c++.m4 \
|
||||||
data/c-skel.m4 \
|
data/c-skel.m4 \
|
||||||
data/c.m4 \
|
data/c.m4 \
|
||||||
data/glr.c \
|
data/glr.c \
|
||||||
data/glr.cc \
|
data/glr.cc \
|
||||||
data/java-skel.m4 \
|
data/java-skel.m4 \
|
||||||
data/java.m4 \
|
data/java.m4 \
|
||||||
data/lalr1.cc \
|
data/lalr1.cc \
|
||||||
data/lalr1.java \
|
data/lalr1.java \
|
||||||
data/location.cc \
|
data/location.cc \
|
||||||
data/stack.hh \
|
data/stack.hh \
|
||||||
data/variant.hh \
|
data/variant.hh \
|
||||||
data/yacc.c
|
data/yacc.c
|
||||||
|
|
||||||
m4sugardir = $(pkgdatadir)/m4sugar
|
m4sugardir = $(pkgdatadir)/m4sugar
|
||||||
dist_m4sugar_DATA = \
|
dist_m4sugar_DATA = \
|
||||||
data/m4sugar/foreach.m4 \
|
data/m4sugar/foreach.m4 \
|
||||||
data/m4sugar/m4sugar.m4
|
data/m4sugar/m4sugar.m4
|
||||||
|
|
||||||
xsltdir = $(pkgdatadir)/xslt
|
xsltdir = $(pkgdatadir)/xslt
|
||||||
dist_xslt_DATA = \
|
dist_xslt_DATA = \
|
||||||
data/xslt/bison.xsl \
|
data/xslt/bison.xsl \
|
||||||
data/xslt/xml2dot.xsl \
|
data/xslt/xml2dot.xsl \
|
||||||
data/xslt/xml2text.xsl \
|
data/xslt/xml2text.xsl \
|
||||||
data/xslt/xml2xhtml.xsl
|
data/xslt/xml2xhtml.xsl
|
||||||
|
|||||||
@@ -279,8 +279,8 @@ b4_copyright([Locations for Bison parsers in C++])[
|
|||||||
position last = loc.end - 1;
|
position last = loc.end - 1;
|
||||||
ostr << loc.begin;
|
ostr << loc.begin;
|
||||||
if (last.filename
|
if (last.filename
|
||||||
&& (!loc.begin.filename
|
&& (!loc.begin.filename
|
||||||
|| *loc.begin.filename != *last.filename))
|
|| *loc.begin.filename != *last.filename))
|
||||||
ostr << '-' << last;
|
ostr << '-' << last;
|
||||||
else if (loc.begin.line != last.line)
|
else if (loc.begin.line != last.line)
|
||||||
ostr << '-' << last.line << '.' << last.column;
|
ostr << '-' << last.line << '.' << last.column;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ b4_copyright([Stack handling for Bison parsers in C++])[
|
|||||||
pop (unsigned int n = 1)
|
pop (unsigned int n = 1)
|
||||||
{
|
{
|
||||||
for (; n; --n)
|
for (; n; --n)
|
||||||
seq_.pop_front ();
|
seq_.pop_front ();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
|||||||
@@ -124,20 +124,20 @@
|
|||||||
<xsl:with-param name="dst" select="@state"/>
|
<xsl:with-param name="dst" select="@state"/>
|
||||||
<xsl:with-param name="style">
|
<xsl:with-param name="style">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="@symbol = 'error'">
|
<xsl:when test="@symbol = 'error'">
|
||||||
<xsl:text>dotted</xsl:text>
|
<xsl:text>dotted</xsl:text>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'shift'">
|
<xsl:when test="@type = 'shift'">
|
||||||
<xsl:text>solid</xsl:text>
|
<xsl:text>solid</xsl:text>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:text>dashed</xsl:text>
|
<xsl:text>dashed</xsl:text>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
<xsl:with-param name="label">
|
<xsl:with-param name="label">
|
||||||
<xsl:if test="not(@symbol = 'error')">
|
<xsl:if test="not(@symbol = 'error')">
|
||||||
<xsl:value-of select="@symbol"/>
|
<xsl:value-of select="@symbol"/>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
|
|||||||
@@ -253,9 +253,9 @@
|
|||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:apply-templates select="transition[@type = $type]">
|
<xsl:apply-templates select="transition[@type = $type]">
|
||||||
<xsl:with-param name="pad">
|
<xsl:with-param name="pad">
|
||||||
<xsl:call-template name="max-width-symbol">
|
<xsl:call-template name="max-width-symbol">
|
||||||
<xsl:with-param name="node" select="transition[@type = $type]"/>
|
<xsl:with-param name="node" select="transition[@type = $type]"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -266,9 +266,9 @@
|
|||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:apply-templates select="error">
|
<xsl:apply-templates select="error">
|
||||||
<xsl:with-param name="pad">
|
<xsl:with-param name="pad">
|
||||||
<xsl:call-template name="max-width-symbol">
|
<xsl:call-template name="max-width-symbol">
|
||||||
<xsl:with-param name="node" select="error"/>
|
<xsl:with-param name="node" select="error"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -279,9 +279,9 @@
|
|||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:apply-templates select="reduction">
|
<xsl:apply-templates select="reduction">
|
||||||
<xsl:with-param name="pad">
|
<xsl:with-param name="pad">
|
||||||
<xsl:call-template name="max-width-symbol">
|
<xsl:call-template name="max-width-symbol">
|
||||||
<xsl:with-param name="node" select="reduction"/>
|
<xsl:with-param name="node" select="reduction"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -290,7 +290,7 @@
|
|||||||
<xsl:template match="item">
|
<xsl:template match="item">
|
||||||
<xsl:param name="pad"/>
|
<xsl:param name="pad"/>
|
||||||
<xsl:param name="prev-rule-number"
|
<xsl:param name="prev-rule-number"
|
||||||
select="preceding-sibling::item[1]/@rule-number"/>
|
select="preceding-sibling::item[1]/@rule-number"/>
|
||||||
<xsl:apply-templates
|
<xsl:apply-templates
|
||||||
select="key('bison:ruleByNumber', current()/@rule-number)"
|
select="key('bison:ruleByNumber', current()/@rule-number)"
|
||||||
>
|
>
|
||||||
@@ -329,14 +329,14 @@
|
|||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
|
<xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
|
||||||
<xsl:call-template name="lpad">
|
<xsl:call-template name="lpad">
|
||||||
<xsl:with-param name="str" select="'|'"/>
|
<xsl:with-param name="str" select="'|'"/>
|
||||||
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
|
<xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
|
||||||
<xsl:call-template name="lpad">
|
<xsl:call-template name="lpad">
|
||||||
<xsl:with-param name="str" select="'|'"/>
|
<xsl:with-param name="str" select="'|'"/>
|
||||||
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
@@ -442,7 +442,7 @@
|
|||||||
<xsl:value-of select="@rule"/>
|
<xsl:value-of select="@rule"/>
|
||||||
<xsl:text> (</xsl:text>
|
<xsl:text> (</xsl:text>
|
||||||
<xsl:value-of
|
<xsl:value-of
|
||||||
select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"/>
|
select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"/>
|
||||||
<xsl:text>)</xsl:text>
|
<xsl:text>)</xsl:text>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
@@ -479,9 +479,9 @@
|
|||||||
<xsl:variable name="longest">
|
<xsl:variable name="longest">
|
||||||
<xsl:for-each select="$node">
|
<xsl:for-each select="$node">
|
||||||
<xsl:sort data-type="number" select="string-length(@symbol)"
|
<xsl:sort data-type="number" select="string-length(@symbol)"
|
||||||
order="descending"/>
|
order="descending"/>
|
||||||
<xsl:if test="position() = 1">
|
<xsl:if test="position() = 1">
|
||||||
<xsl:value-of select="string-length(@symbol)"/>
|
<xsl:value-of select="string-length(@symbol)"/>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
@@ -498,7 +498,7 @@
|
|||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:call-template name="space">
|
<xsl:call-template name="space">
|
||||||
<xsl:with-param name="repeat" select="$diff"/>
|
<xsl:with-param name="repeat" select="$diff"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$str"/>
|
<xsl:value-of select="$str"/>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
@@ -516,7 +516,7 @@
|
|||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:value-of select="$str"/>
|
<xsl:value-of select="$str"/>
|
||||||
<xsl:call-template name="space">
|
<xsl:call-template name="space">
|
||||||
<xsl:with-param name="repeat" select="$diff"/>
|
<xsl:with-param name="repeat" select="$diff"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
|
|||||||
@@ -31,32 +31,32 @@
|
|||||||
<xsl:import href="bison.xsl"/>
|
<xsl:import href="bison.xsl"/>
|
||||||
|
|
||||||
<xsl:output method="xml" encoding="UTF-8"
|
<xsl:output method="xml" encoding="UTF-8"
|
||||||
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
|
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
|
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
|
||||||
indent="yes"/>
|
indent="yes"/>
|
||||||
|
|
||||||
<xsl:template match="/">
|
<xsl:template match="/">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>
|
<title>
|
||||||
<xsl:value-of select="bison-xml-report/filename"/>
|
<xsl:value-of select="bison-xml-report/filename"/>
|
||||||
<xsl:text> - GNU Bison XML Automaton Report</xsl:text>
|
<xsl:text> - GNU Bison XML Automaton Report</xsl:text>
|
||||||
</title>
|
</title>
|
||||||
<style type="text/css"><![CDATA[
|
<style type="text/css"><![CDATA[
|
||||||
body {
|
body {
|
||||||
font-family: "Nimbus Sans L", Arial, sans-serif;
|
font-family: "Nimbus Sans L", Arial, sans-serif;
|
||||||
font-size: 9pt;
|
font-size: 9pt;
|
||||||
}
|
}
|
||||||
a:link {
|
a:link {
|
||||||
color: #1f00ff;
|
color: #1f00ff;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
a:visited {
|
a:visited {
|
||||||
color: #1f00ff;
|
color: #1f00ff;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
a:hover {
|
a:hover {
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
#menu a {
|
#menu a {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
@@ -109,21 +109,21 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="#reductions">Reductions</a>
|
<a href="#reductions">Reductions</a>
|
||||||
<ul class="lower-alpha">
|
<ul class="lower-alpha">
|
||||||
<li><a href="#nonterminals_useless_in_grammar">Nonterminals useless in grammar</a></li>
|
<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="#terminals_unused_in_grammar">Terminals unused in grammar</a></li>
|
||||||
<li><a href="#rules_useless_in_grammar">Rules useless 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']">
|
<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>
|
<li><a href="#rules_useless_in_parser">Rules useless in parser due to conflicts</a></li>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#conflicts">Conflicts</a></li>
|
<li><a href="#conflicts">Conflicts</a></li>
|
||||||
<li>
|
<li>
|
||||||
<a href="#grammar">Grammar</a>
|
<a href="#grammar">Grammar</a>
|
||||||
<ul class="lower-alpha">
|
<ul class="lower-alpha">
|
||||||
<li><a href="#grammar">Itemset</a></li>
|
<li><a href="#grammar">Itemset</a></li>
|
||||||
<li><a href="#terminals">Terminal symbols</a></li>
|
<li><a href="#terminals">Terminal symbols</a></li>
|
||||||
<li><a href="#nonterminals">Nonterminal symbols</a></li>
|
<li><a href="#nonterminals">Nonterminal symbols</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#automaton">Automaton</a></li>
|
<li><a href="#automaton">Automaton</a></li>
|
||||||
@@ -154,9 +154,9 @@
|
|||||||
<xsl:if test="nonterminal[@usefulness='useless-in-grammar']">
|
<xsl:if test="nonterminal[@usefulness='useless-in-grammar']">
|
||||||
<p class="pre">
|
<p class="pre">
|
||||||
<xsl:for-each select="nonterminal[@usefulness='useless-in-grammar']">
|
<xsl:for-each select="nonterminal[@usefulness='useless-in-grammar']">
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:value-of select="@name"/>
|
<xsl:value-of select="@name"/>
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
</p>
|
</p>
|
||||||
@@ -173,9 +173,9 @@
|
|||||||
<p class="pre">
|
<p class="pre">
|
||||||
<xsl:for-each select="terminal[@usefulness='unused-in-grammar']">
|
<xsl:for-each select="terminal[@usefulness='unused-in-grammar']">
|
||||||
<xsl:sort select="@symbol-number" data-type="number"/>
|
<xsl:sort select="@symbol-number" data-type="number"/>
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:value-of select="@name"/>
|
<xsl:value-of select="@name"/>
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
</p>
|
</p>
|
||||||
@@ -381,7 +381,7 @@
|
|||||||
<h3>
|
<h3>
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="name">
|
<xsl:attribute name="name">
|
||||||
<xsl:value-of select="concat('state_', @number)"/>
|
<xsl:value-of select="concat('state_', @number)"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
</a>
|
</a>
|
||||||
<xsl:text>state </xsl:text>
|
<xsl:text>state </xsl:text>
|
||||||
@@ -410,9 +410,9 @@
|
|||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:apply-templates select="transition[@type = $type]">
|
<xsl:apply-templates select="transition[@type = $type]">
|
||||||
<xsl:with-param name="pad">
|
<xsl:with-param name="pad">
|
||||||
<xsl:call-template name="max-width-symbol">
|
<xsl:call-template name="max-width-symbol">
|
||||||
<xsl:with-param name="node" select="transition[@type = $type]"/>
|
<xsl:with-param name="node" select="transition[@type = $type]"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -423,9 +423,9 @@
|
|||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:apply-templates select="error">
|
<xsl:apply-templates select="error">
|
||||||
<xsl:with-param name="pad">
|
<xsl:with-param name="pad">
|
||||||
<xsl:call-template name="max-width-symbol">
|
<xsl:call-template name="max-width-symbol">
|
||||||
<xsl:with-param name="node" select="error"/>
|
<xsl:with-param name="node" select="error"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -436,9 +436,9 @@
|
|||||||
<xsl:text> </xsl:text>
|
<xsl:text> </xsl:text>
|
||||||
<xsl:apply-templates select="reduction">
|
<xsl:apply-templates select="reduction">
|
||||||
<xsl:with-param name="pad">
|
<xsl:with-param name="pad">
|
||||||
<xsl:call-template name="max-width-symbol">
|
<xsl:call-template name="max-width-symbol">
|
||||||
<xsl:with-param name="node" select="reduction"/>
|
<xsl:with-param name="node" select="reduction"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -447,7 +447,7 @@
|
|||||||
<xsl:template match="item">
|
<xsl:template match="item">
|
||||||
<xsl:param name="pad"/>
|
<xsl:param name="pad"/>
|
||||||
<xsl:param name="prev-rule-number"
|
<xsl:param name="prev-rule-number"
|
||||||
select="preceding-sibling::item[1]/@rule-number"/>
|
select="preceding-sibling::item[1]/@rule-number"/>
|
||||||
<xsl:apply-templates
|
<xsl:apply-templates
|
||||||
select="key('bison:ruleByNumber', current()/@rule-number)"
|
select="key('bison:ruleByNumber', current()/@rule-number)"
|
||||||
>
|
>
|
||||||
@@ -477,7 +477,7 @@
|
|||||||
<xsl:if test="$itemset != 'true'">
|
<xsl:if test="$itemset != 'true'">
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="name">
|
<xsl:attribute name="name">
|
||||||
<xsl:value-of select="concat('rule_', @number)"/>
|
<xsl:value-of select="concat('rule_', @number)"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
</a>
|
</a>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
@@ -486,19 +486,19 @@
|
|||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$itemset = 'true'">
|
<xsl:when test="$itemset = 'true'">
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="concat('#rule_', @number)"/>
|
<xsl:value-of select="concat('#rule_', @number)"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:call-template name="lpad">
|
<xsl:call-template name="lpad">
|
||||||
<xsl:with-param name="str" select="string(@number)"/>
|
<xsl:with-param name="str" select="string(@number)"/>
|
||||||
<xsl:with-param name="pad" select="number($pad)"/>
|
<xsl:with-param name="pad" select="number($pad)"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</a>
|
</a>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:call-template name="lpad">
|
<xsl:call-template name="lpad">
|
||||||
<xsl:with-param name="str" select="string(@number)"/>
|
<xsl:with-param name="str" select="string(@number)"/>
|
||||||
<xsl:with-param name="pad" select="number($pad)"/>
|
<xsl:with-param name="pad" select="number($pad)"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
@@ -508,19 +508,19 @@
|
|||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
|
<xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
|
||||||
<xsl:call-template name="lpad">
|
<xsl:call-template name="lpad">
|
||||||
<xsl:with-param name="str" select="'|'"/>
|
<xsl:with-param name="str" select="'|'"/>
|
||||||
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
|
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
|
<xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
|
||||||
<xsl:call-template name="lpad">
|
<xsl:call-template name="lpad">
|
||||||
<xsl:with-param name="str" select="'|'"/>
|
<xsl:with-param name="str" select="'|'"/>
|
||||||
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
|
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<span class="i">
|
<span class="i">
|
||||||
<xsl:value-of select="lhs"/>
|
<xsl:value-of select="lhs"/>
|
||||||
</span>
|
</span>
|
||||||
<xsl:text> →</xsl:text>
|
<xsl:text> →</xsl:text>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
@@ -589,18 +589,18 @@
|
|||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="@type = 'shift'">
|
<xsl:when test="@type = 'shift'">
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="concat('#state_', @state)"/>
|
<xsl:value-of select="concat('#state_', @state)"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:value-of select="concat('shift, and go to state ', @state)"/>
|
<xsl:value-of select="concat('shift, and go to state ', @state)"/>
|
||||||
</a>
|
</a>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'goto'">
|
<xsl:when test="@type = 'goto'">
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="concat('#state_', @state)"/>
|
<xsl:value-of select="concat('#state_', @state)"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:value-of select="concat('go to state ', @state)"/>
|
<xsl:value-of select="concat('go to state ', @state)"/>
|
||||||
</a>
|
</a>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
@@ -637,10 +637,10 @@
|
|||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<a>
|
<a>
|
||||||
<xsl:attribute name="href">
|
<xsl:attribute name="href">
|
||||||
<xsl:value-of select="concat('#rule_', @rule)"/>
|
<xsl:value-of select="concat('#rule_', @rule)"/>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:value-of select="concat('reduce using rule ', @rule)"/>
|
<xsl:value-of select="concat('reduce using rule ', @rule)"/>
|
||||||
</a>
|
</a>
|
||||||
<xsl:text> (</xsl:text>
|
<xsl:text> (</xsl:text>
|
||||||
<xsl:value-of
|
<xsl:value-of
|
||||||
@@ -687,9 +687,9 @@
|
|||||||
<xsl:variable name="longest">
|
<xsl:variable name="longest">
|
||||||
<xsl:for-each select="$node">
|
<xsl:for-each select="$node">
|
||||||
<xsl:sort data-type="number" select="string-length(@symbol)"
|
<xsl:sort data-type="number" select="string-length(@symbol)"
|
||||||
order="descending"/>
|
order="descending"/>
|
||||||
<xsl:if test="position() = 1">
|
<xsl:if test="position() = 1">
|
||||||
<xsl:value-of select="string-length(@symbol)"/>
|
<xsl:value-of select="string-length(@symbol)"/>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
@@ -706,7 +706,7 @@
|
|||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:call-template name="space">
|
<xsl:call-template name="space">
|
||||||
<xsl:with-param name="repeat" select="$diff"/>
|
<xsl:with-param name="repeat" select="$diff"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$str"/>
|
<xsl:value-of select="$str"/>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
@@ -724,7 +724,7 @@
|
|||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:value-of select="$str"/>
|
<xsl:value-of select="$str"/>
|
||||||
<xsl:call-template name="space">
|
<xsl:call-template name="space">
|
||||||
<xsl:with-param name="repeat" select="$diff"/>
|
<xsl:with-param name="repeat" select="$diff"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
|
|||||||
328
data/yacc.c
328
data/yacc.c
@@ -76,8 +76,8 @@ m4_define([b4_pure_flag],
|
|||||||
# Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise.
|
# Expand IF-TRUE, if %pure-parser and %parse-param, IF-FALSE otherwise.
|
||||||
m4_define([b4_yacc_pure_if],
|
m4_define([b4_yacc_pure_if],
|
||||||
[b4_pure_if([m4_ifset([b4_parse_param],
|
[b4_pure_if([m4_ifset([b4_parse_param],
|
||||||
[$1], [$2])],
|
[$1], [$2])],
|
||||||
[$2])])
|
[$2])])
|
||||||
|
|
||||||
|
|
||||||
# b4_yyerror_args
|
# b4_yyerror_args
|
||||||
@@ -117,7 +117,7 @@ m4_define([b4_int_type],
|
|||||||
|
|
||||||
m4_eval([0 <= $1]), [1], [unsigned int],
|
m4_eval([0 <= $1]), [1], [unsigned int],
|
||||||
|
|
||||||
[int])])
|
[int])])
|
||||||
|
|
||||||
|
|
||||||
## ----------------- ##
|
## ----------------- ##
|
||||||
@@ -464,7 +464,7 @@ b4_push_if([], [b4_lac_if([], [[
|
|||||||
# endif
|
# endif
|
||||||
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
|
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
|
||||||
&& ! ((defined YYMALLOC || defined malloc) \
|
&& ! ((defined YYMALLOC || defined malloc) \
|
||||||
&& (defined YYFREE || defined free)))
|
&& (defined YYFREE || defined free)))
|
||||||
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
# ifndef EXIT_SUCCESS
|
# ifndef EXIT_SUCCESS
|
||||||
# define EXIT_SUCCESS 0
|
# define EXIT_SUCCESS 0
|
||||||
@@ -489,8 +489,8 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
|
|||||||
|
|
||||||
#if (! defined yyoverflow \
|
#if (! defined yyoverflow \
|
||||||
&& (! defined __cplusplus \
|
&& (! defined __cplusplus \
|
||||||
|| (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
|
|| (]b4_locations_if([[defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
|
||||||
&& ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|
&& ]])[defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|
||||||
|
|
||||||
/* A type that is properly aligned for any stack member. */
|
/* A type that is properly aligned for any stack member. */
|
||||||
union yyalloc
|
union yyalloc
|
||||||
@@ -520,15 +520,15 @@ union yyalloc
|
|||||||
elements in the stack, and YYPTR gives the new location of the
|
elements in the stack, and YYPTR gives the new location of the
|
||||||
stack. Advance YYPTR to a properly aligned location for the next
|
stack. Advance YYPTR to a properly aligned location for the next
|
||||||
stack. */
|
stack. */
|
||||||
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
|
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
YYSIZE_T yynewbytes; \
|
YYSIZE_T yynewbytes; \
|
||||||
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
|
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
|
||||||
Stack = &yyptr->Stack_alloc; \
|
Stack = &yyptr->Stack_alloc; \
|
||||||
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
||||||
yyptr += yynewbytes / sizeof (*yyptr); \
|
yyptr += yynewbytes / sizeof (*yyptr); \
|
||||||
} \
|
} \
|
||||||
while (YYID (0))
|
while (YYID (0))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -541,13 +541,13 @@ union yyalloc
|
|||||||
# define YYCOPY(To, From, Count) \
|
# define YYCOPY(To, From, Count) \
|
||||||
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
|
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
|
||||||
# else
|
# else
|
||||||
# define YYCOPY(To, From, Count) \
|
# define YYCOPY(To, From, Count) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
YYSIZE_T yyi; \
|
YYSIZE_T yyi; \
|
||||||
for (yyi = 0; yyi < (Count); yyi++) \
|
for (yyi = 0; yyi < (Count); yyi++) \
|
||||||
(To)[yyi] = (From)[yyi]; \
|
(To)[yyi] = (From)[yyi]; \
|
||||||
} \
|
} \
|
||||||
while (YYID (0))
|
while (YYID (0))
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
@@ -572,7 +572,7 @@ union yyalloc
|
|||||||
#define YYUNDEFTOK ]b4_undef_token_number[
|
#define YYUNDEFTOK ]b4_undef_token_number[
|
||||||
#define YYMAXUTOK ]b4_user_token_number_max[
|
#define YYMAXUTOK ]b4_user_token_number_max[
|
||||||
|
|
||||||
#define YYTRANSLATE(YYX) \
|
#define YYTRANSLATE(YYX) \
|
||||||
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||||
|
|
||||||
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
/* 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[
|
]b4_parser_tables_define[
|
||||||
|
|
||||||
#define yyerrok (yyerrstatus = 0)
|
#define yyerrok (yyerrstatus = 0)
|
||||||
#define yyclearin (yychar = YYEMPTY)
|
#define yyclearin (yychar = YYEMPTY)
|
||||||
#define YYEMPTY (-2)
|
#define YYEMPTY (-2)
|
||||||
#define YYEOF 0
|
#define YYEOF 0
|
||||||
|
|
||||||
#define YYACCEPT goto yyacceptlab
|
#define YYACCEPT goto yyacceptlab
|
||||||
#define YYABORT goto yyabortlab
|
#define YYABORT goto yyabortlab
|
||||||
#define YYERROR goto yyerrorlab
|
#define YYERROR goto yyerrorlab
|
||||||
|
|
||||||
|
|
||||||
/* Like YYERROR except do call yyerror. This remains here temporarily
|
/* 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
|
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
|
||||||
discussed. */
|
discussed. */
|
||||||
|
|
||||||
#define YYFAIL goto yyerrlab
|
#define YYFAIL goto yyerrlab
|
||||||
#if defined YYFAIL
|
#if defined YYFAIL
|
||||||
/* This is here to suppress warnings from the GCC cpp's
|
/* This is here to suppress warnings from the GCC cpp's
|
||||||
-Wunused-macros. Normally we don't worry about that warning, but
|
-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 YYRECOVERING() (!!yyerrstatus)
|
||||||
|
|
||||||
#define YYBACKUP(Token, Value) \
|
#define YYBACKUP(Token, Value) \
|
||||||
do \
|
do \
|
||||||
if (yychar == YYEMPTY && yylen == 1) \
|
if (yychar == YYEMPTY && yylen == 1) \
|
||||||
{ \
|
{ \
|
||||||
yychar = (Token); \
|
yychar = (Token); \
|
||||||
yylval = (Value); \
|
yylval = (Value); \
|
||||||
YYPOPSTACK (1); \]b4_lac_if([[
|
YYPOPSTACK (1); \]b4_lac_if([[
|
||||||
YY_LAC_DISCARD ("YYBACKUP"); \]])[
|
YY_LAC_DISCARD ("YYBACKUP"); \]])[
|
||||||
goto yybackup; \
|
goto yybackup; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
|
yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
|
||||||
YYERROR; \
|
YYERROR; \
|
||||||
} \
|
} \
|
||||||
while (YYID (0))
|
while (YYID (0))
|
||||||
|
|
||||||
|
|
||||||
#define YYTERROR 1
|
#define YYTERROR 1
|
||||||
#define YYERRCODE 256
|
#define YYERRCODE 256
|
||||||
|
|
||||||
|
|
||||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
/* 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])
|
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
||||||
#ifndef YYLLOC_DEFAULT
|
#ifndef YYLLOC_DEFAULT
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
do \
|
do \
|
||||||
if (YYID (N)) \
|
if (YYID (N)) \
|
||||||
{ \
|
{ \
|
||||||
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
||||||
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
||||||
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
||||||
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
(Current).first_line = (Current).last_line = \
|
(Current).first_line = (Current).last_line = \
|
||||||
YYRHSLOC (Rhs, 0).last_line; \
|
YYRHSLOC (Rhs, 0).last_line; \
|
||||||
(Current).first_column = (Current).last_column = \
|
(Current).first_column = (Current).last_column = \
|
||||||
YYRHSLOC (Rhs, 0).last_column; \
|
YYRHSLOC (Rhs, 0).last_column; \
|
||||||
} \
|
} \
|
||||||
while (YYID (0))
|
while (YYID (0))
|
||||||
#endif]b4_locations_if([[
|
#endif]b4_locations_if([[
|
||||||
|
|
||||||
@@ -698,10 +698,10 @@ while (YYID (0))
|
|||||||
|
|
||||||
#ifndef YY_LOCATION_PRINT
|
#ifndef YY_LOCATION_PRINT
|
||||||
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
|
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
|
||||||
# define YY_LOCATION_PRINT(File, Loc) \
|
# define YY_LOCATION_PRINT(File, Loc) \
|
||||||
fprintf (File, "%d.%d-%d.%d", \
|
fprintf (File, "%d.%d-%d.%d", \
|
||||||
(Loc).first_line, (Loc).first_column, \
|
(Loc).first_line, (Loc).first_column, \
|
||||||
(Loc).last_line, (Loc).last_column)
|
(Loc).last_line, (Loc).last_column)
|
||||||
# else
|
# else
|
||||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||||
# endif
|
# endif
|
||||||
@@ -731,21 +731,21 @@ while (YYID (0))
|
|||||||
# define YYFPRINTF fprintf
|
# define YYFPRINTF fprintf
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# define YYDPRINTF(Args) \
|
# define YYDPRINTF(Args) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
YYFPRINTF Args; \
|
YYFPRINTF Args; \
|
||||||
} while (YYID (0))
|
} while (YYID (0))
|
||||||
|
|
||||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
{ \
|
{ \
|
||||||
YYFPRINTF (stderr, "%s ", Title); \
|
YYFPRINTF (stderr, "%s ", Title); \
|
||||||
yy_symbol_print (stderr, \
|
yy_symbol_print (stderr, \
|
||||||
Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
|
Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
|
||||||
YYFPRINTF (stderr, "\n"); \
|
YYFPRINTF (stderr, "\n"); \
|
||||||
} \
|
} \
|
||||||
} while (YYID (0))
|
} while (YYID (0))
|
||||||
|
|
||||||
]b4_yy_symbol_print_generate([b4_c_function_def])[
|
]b4_yy_symbol_print_generate([b4_c_function_def])[
|
||||||
@@ -756,8 +756,8 @@ do { \
|
|||||||
`------------------------------------------------------------------*/
|
`------------------------------------------------------------------*/
|
||||||
|
|
||||||
]b4_c_function_def([yy_stack_print], [static void],
|
]b4_c_function_def([yy_stack_print], [static void],
|
||||||
[[yytype_int16 *yybottom], [yybottom]],
|
[[yytype_int16 *yybottom], [yybottom]],
|
||||||
[[yytype_int16 *yytop], [yytop]])[
|
[[yytype_int16 *yytop], [yytop]])[
|
||||||
{
|
{
|
||||||
YYFPRINTF (stderr, "Stack now");
|
YYFPRINTF (stderr, "Stack now");
|
||||||
for (; yybottom <= yytop; yybottom++)
|
for (; yybottom <= yytop; yybottom++)
|
||||||
@@ -768,10 +768,10 @@ do { \
|
|||||||
YYFPRINTF (stderr, "\n");
|
YYFPRINTF (stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
# define YY_STACK_PRINT(Bottom, Top) \
|
# define YY_STACK_PRINT(Bottom, Top) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
yy_stack_print ((Bottom), (Top)); \
|
yy_stack_print ((Bottom), (Top)); \
|
||||||
} while (YYID (0))
|
} while (YYID (0))
|
||||||
|
|
||||||
|
|
||||||
@@ -804,9 +804,9 @@ do { \
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# define YY_REDUCE_PRINT(Rule) \
|
# define YY_REDUCE_PRINT(Rule) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
|
yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
|
||||||
} while (YYID (0))
|
} while (YYID (0))
|
||||||
|
|
||||||
@@ -822,7 +822,7 @@ int yydebug;
|
|||||||
|
|
||||||
|
|
||||||
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
||||||
#ifndef YYINITDEPTH
|
#ifndef YYINITDEPTH
|
||||||
# define YYINITDEPTH ]b4_stack_depth_init[
|
# define YYINITDEPTH ]b4_stack_depth_init[
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1129,27 +1129,27 @@ yytnamerr (char *yyres, const char *yystr)
|
|||||||
char const *yyp = yystr;
|
char const *yyp = yystr;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
switch (*++yyp)
|
switch (*++yyp)
|
||||||
{
|
{
|
||||||
case '\'':
|
case '\'':
|
||||||
case ',':
|
case ',':
|
||||||
goto do_not_strip_quotes;
|
goto do_not_strip_quotes;
|
||||||
|
|
||||||
case '\\':
|
case '\\':
|
||||||
if (*++yyp != '\\')
|
if (*++yyp != '\\')
|
||||||
goto do_not_strip_quotes;
|
goto do_not_strip_quotes;
|
||||||
/* Fall through. */
|
/* Fall through. */
|
||||||
default:
|
default:
|
||||||
if (yyres)
|
if (yyres)
|
||||||
yyres[yyn] = *yyp;
|
yyres[yyn] = *yyp;
|
||||||
yyn++;
|
yyn++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '"':
|
case '"':
|
||||||
if (yyres)
|
if (yyres)
|
||||||
yyres[yyn] = '\0';
|
yyres[yyn] = '\0';
|
||||||
return yyn;
|
return yyn;
|
||||||
}
|
}
|
||||||
do_not_strip_quotes: ;
|
do_not_strip_quotes: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1552,26 +1552,26 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
|
|||||||
|
|
||||||
#ifdef yyoverflow
|
#ifdef yyoverflow
|
||||||
{
|
{
|
||||||
/* Give user a chance to reallocate the stack. Use copies of
|
/* Give user a chance to reallocate the stack. Use copies of
|
||||||
these so that the &'s don't force the real ones into
|
these so that the &'s don't force the real ones into
|
||||||
memory. */
|
memory. */
|
||||||
YYSTYPE *yyvs1 = yyvs;
|
YYSTYPE *yyvs1 = yyvs;
|
||||||
yytype_int16 *yyss1 = yyss;]b4_locations_if([
|
yytype_int16 *yyss1 = yyss;]b4_locations_if([
|
||||||
YYLTYPE *yyls1 = yyls;])[
|
YYLTYPE *yyls1 = yyls;])[
|
||||||
|
|
||||||
/* Each stack pointer address is followed by the size of the
|
/* Each stack pointer address is followed by the size of the
|
||||||
data in use in that stack, in bytes. This used to be a
|
data in use in that stack, in bytes. This used to be a
|
||||||
conditional around just the two extra args, but that might
|
conditional around just the two extra args, but that might
|
||||||
be undefined if yyoverflow is a macro. */
|
be undefined if yyoverflow is a macro. */
|
||||||
yyoverflow (YY_("memory exhausted"),
|
yyoverflow (YY_("memory exhausted"),
|
||||||
&yyss1, yysize * sizeof (*yyssp),
|
&yyss1, yysize * sizeof (*yyssp),
|
||||||
&yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
|
&yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
|
||||||
&yyls1, yysize * sizeof (*yylsp),])[
|
&yyls1, yysize * sizeof (*yylsp),])[
|
||||||
&yystacksize);
|
&yystacksize);
|
||||||
]b4_locations_if([
|
]b4_locations_if([
|
||||||
yyls = yyls1;])[
|
yyls = yyls1;])[
|
||||||
yyss = yyss1;
|
yyss = yyss1;
|
||||||
yyvs = yyvs1;
|
yyvs = yyvs1;
|
||||||
}
|
}
|
||||||
#else /* no yyoverflow */
|
#else /* no yyoverflow */
|
||||||
# ifndef YYSTACK_RELOCATE
|
# ifndef YYSTACK_RELOCATE
|
||||||
@@ -1579,23 +1579,23 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
|
|||||||
# else
|
# else
|
||||||
/* Extend the stack our own way. */
|
/* Extend the stack our own way. */
|
||||||
if (YYMAXDEPTH <= yystacksize)
|
if (YYMAXDEPTH <= yystacksize)
|
||||||
goto yyexhaustedlab;
|
goto yyexhaustedlab;
|
||||||
yystacksize *= 2;
|
yystacksize *= 2;
|
||||||
if (YYMAXDEPTH < yystacksize)
|
if (YYMAXDEPTH < yystacksize)
|
||||||
yystacksize = YYMAXDEPTH;
|
yystacksize = YYMAXDEPTH;
|
||||||
|
|
||||||
{
|
{
|
||||||
yytype_int16 *yyss1 = yyss;
|
yytype_int16 *yyss1 = yyss;
|
||||||
union yyalloc *yyptr =
|
union yyalloc *yyptr =
|
||||||
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
|
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
|
||||||
if (! yyptr)
|
if (! yyptr)
|
||||||
goto yyexhaustedlab;
|
goto yyexhaustedlab;
|
||||||
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
||||||
YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
|
YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
|
||||||
YYSTACK_RELOCATE (yyls_alloc, yyls);])[
|
YYSTACK_RELOCATE (yyls_alloc, yyls);])[
|
||||||
# undef YYSTACK_RELOCATE
|
# undef YYSTACK_RELOCATE
|
||||||
if (yyss1 != yyssa)
|
if (yyss1 != yyssa)
|
||||||
YYSTACK_FREE (yyss1);
|
YYSTACK_FREE (yyss1);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
#endif /* no yyoverflow */
|
#endif /* no yyoverflow */
|
||||||
@@ -1605,10 +1605,10 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc;
|
|||||||
yylsp = yyls + yysize - 1;])[
|
yylsp = yyls + yysize - 1;])[
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
||||||
(unsigned long int) yystacksize));
|
(unsigned long int) yystacksize));
|
||||||
|
|
||||||
if (yyss + yystacksize - 1 <= yyssp)
|
if (yyss + yystacksize - 1 <= yyssp)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
||||||
@@ -1844,20 +1844,20 @@ yyerrlab:
|
|||||||
if (yyerrstatus == 3)
|
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. */
|
error, discard it. */
|
||||||
|
|
||||||
if (yychar <= YYEOF)
|
if (yychar <= YYEOF)
|
||||||
{
|
{
|
||||||
/* Return failure if at end of input. */
|
/* Return failure if at end of input. */
|
||||||
if (yychar == YYEOF)
|
if (yychar == YYEOF)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yydestruct ("Error: discarding",
|
yydestruct ("Error: discarding",
|
||||||
yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
|
yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
|
||||||
yychar = YYEMPTY;
|
yychar = YYEMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Else will try to reuse lookahead token after shifting the error
|
/* 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 -- common code for both syntax error and YYERROR. |
|
||||||
`-------------------------------------------------------------*/
|
`-------------------------------------------------------------*/
|
||||||
yyerrlab1:
|
yyerrlab1:
|
||||||
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
yyn = yypact[yystate];
|
yyn = yypact[yystate];
|
||||||
if (!yypact_value_is_default (yyn))
|
if (!yypact_value_is_default (yyn))
|
||||||
{
|
{
|
||||||
yyn += YYTERROR;
|
yyn += YYTERROR;
|
||||||
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
|
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
|
||||||
{
|
{
|
||||||
yyn = yytable[yyn];
|
yyn = yytable[yyn];
|
||||||
if (0 < yyn)
|
if (0 < yyn)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pop the current state because it cannot handle the error token. */
|
/* Pop the current state because it cannot handle the error token. */
|
||||||
if (yyssp == yyss)
|
if (yyssp == yyss)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
|
|
||||||
]b4_locations_if([[ yyerror_range[1] = *yylsp;]])[
|
]b4_locations_if([[ yyerror_range[1] = *yylsp;]])[
|
||||||
yydestruct ("Error: popping",
|
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);
|
YYPOPSTACK (1);
|
||||||
yystate = *yyssp;
|
yystate = *yyssp;
|
||||||
YY_STACK_PRINT (yyss, yyssp);
|
YY_STACK_PRINT (yyss, yyssp);
|
||||||
@@ -1977,7 +1977,7 @@ yyreturn:
|
|||||||
while (yyssp != yyss)
|
while (yyssp != yyss)
|
||||||
{
|
{
|
||||||
yydestruct ("Cleanup: popping",
|
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);
|
YYPOPSTACK (1);
|
||||||
}
|
}
|
||||||
#ifndef yyoverflow
|
#ifndef yyoverflow
|
||||||
|
|||||||
@@ -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
|
# This file describes the settings to be used by the documentation system
|
||||||
# doxygen (www.doxygen.org) for a project
|
# doxygen (www.doxygen.org) for a project
|
||||||
@@ -362,7 +362,7 @@ WARN_LOGFILE =
|
|||||||
# with spaces.
|
# with spaces.
|
||||||
|
|
||||||
INPUT = @top_srcdir@/src \
|
INPUT = @top_srcdir@/src \
|
||||||
@top_builddir@/src
|
@top_builddir@/src
|
||||||
|
|
||||||
# If the value of the INPUT tag contains directories, you can use the
|
# 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
|
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
|
||||||
@@ -373,8 +373,8 @@ INPUT = @top_srcdir@/src \
|
|||||||
|
|
||||||
FILE_PATTERNS = *.c \
|
FILE_PATTERNS = *.c \
|
||||||
*.h \
|
*.h \
|
||||||
*.l \
|
*.l \
|
||||||
*.y
|
*.y
|
||||||
|
|
||||||
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
|
# 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.
|
# 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.
|
# subdirectory from a directory tree whose root is specified with the INPUT tag.
|
||||||
|
|
||||||
EXCLUDE = @top_srcdir@/src/scan-gram.c \
|
EXCLUDE = @top_srcdir@/src/scan-gram.c \
|
||||||
@top_srcdir@/src/scan-skel.c \
|
@top_srcdir@/src/scan-skel.c \
|
||||||
@top_builddir@/src/parse-*.[ch]
|
@top_builddir@/src/parse-*.[ch]
|
||||||
|
|
||||||
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
|
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
|
||||||
# directories that are symbolic links (a Unix filesystem feature) are
|
# directories that are symbolic links (a Unix filesystem feature) are
|
||||||
|
|||||||
20
doc/local.mk
20
doc/local.mk
@@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
AM_MAKEINFOFLAGS = --no-split
|
AM_MAKEINFOFLAGS = --no-split
|
||||||
info_TEXINFOS = doc/bison.texinfo
|
info_TEXINFOS = doc/bison.texinfo
|
||||||
doc_bison_TEXINFOS = \
|
doc_bison_TEXINFOS = \
|
||||||
$(CROSS_OPTIONS_TEXI) \
|
$(CROSS_OPTIONS_TEXI) \
|
||||||
doc/fdl.texi \
|
doc/fdl.texi \
|
||||||
doc/gpl-3.0.texi
|
doc/gpl-3.0.texi
|
||||||
|
|
||||||
CLEANFILES = doc/bison.fns
|
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.
|
# diff in the next run. Note that $@ might not exist yet.
|
||||||
{ test ! -f $@ || cat $@; } >$@~
|
{ test ! -f $@ || cat $@; } >$@~
|
||||||
test ! -f $@.tmp || rm -f $@.tmp
|
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
|
perl $(CROSS_OPTIONS_PL) $(top_srcdir)/src/scan-gram.l >$@.tmp
|
||||||
diff -u $@~ $@.tmp || true
|
diff -u $@~ $@.tmp || true
|
||||||
mv $@.tmp $@
|
mv $@.tmp $@
|
||||||
@@ -101,14 +101,14 @@ remove_time_stamp = \
|
|||||||
# Depend on configure to get version number changes.
|
# Depend on configure to get version number changes.
|
||||||
$(top_srcdir)/doc/bison.1: doc/bison.help doc/bison.x $(top_srcdir)/configure
|
$(top_srcdir)/doc/bison.1: doc/bison.help doc/bison.x $(top_srcdir)/configure
|
||||||
@echo "Updating man page $@"
|
@echo "Updating man page $@"
|
||||||
$(HELP2MAN) \
|
$(HELP2MAN) \
|
||||||
--include=$(top_srcdir)/doc/bison.x \
|
--include=$(top_srcdir)/doc/bison.x \
|
||||||
--output=$@.t src/bison$(EXEEXT)
|
--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 \
|
$(remove_time_stamp) $@.t | cmp $@a.t - >/dev/null 2>&1; then \
|
||||||
touch $@; \
|
touch $@; \
|
||||||
else \
|
else \
|
||||||
mv $@.t $@; \
|
mv $@.t $@; \
|
||||||
fi
|
fi
|
||||||
rm -f $@*.t
|
rm -f $@*.t
|
||||||
|
|
||||||
|
|||||||
@@ -284,8 +284,8 @@ for my $size (1 .. $max)
|
|||||||
{
|
{
|
||||||
use Text::Wrap;
|
use Text::Wrap;
|
||||||
print $out wrap ("| ", " ",
|
print $out wrap ("| ", " ",
|
||||||
(map { "\"$_\"" } (1 .. $size)),
|
(map { "\"$_\"" } (1 .. $size)),
|
||||||
" END \n"),
|
" END \n"),
|
||||||
" { \$\$ = $size; }\n";
|
" { \$\$ = $size; }\n";
|
||||||
};
|
};
|
||||||
print $out ";\n";
|
print $out ";\n";
|
||||||
@@ -411,7 +411,7 @@ static int yylex (void);
|
|||||||
%token <ival> NUM "number"
|
%token <ival> NUM "number"
|
||||||
%type <ival> exp
|
%type <ival> exp
|
||||||
|
|
||||||
%nonassoc '=' /* comparison */
|
%nonassoc '=' /* comparison */
|
||||||
%left '-' '+'
|
%left '-' '+'
|
||||||
%left '*' '/'
|
%left '*' '/'
|
||||||
%left NEG /* negation--unary minus */
|
%left NEG /* negation--unary minus */
|
||||||
@@ -640,13 +640,13 @@ EOF
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
result:
|
result:
|
||||||
text { /* Throw away the result. */ }
|
text { /* Throw away the result. */ }
|
||||||
;
|
;
|
||||||
|
|
||||||
text:
|
text:
|
||||||
/* nothing */ { /* This will generate an empty string */ }
|
/* nothing */ { /* This will generate an empty string */ }
|
||||||
| text TEXT { std::swap ($$, $2); }
|
| text TEXT { std::swap ($$, $2); }
|
||||||
| text NUMBER { $$ = string_cast($2); }
|
| text NUMBER { $$ = string_cast($2); }
|
||||||
;
|
;
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@@ -663,13 +663,13 @@ EOF
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
result:
|
result:
|
||||||
text { delete $1; }
|
text { delete $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
text:
|
text:
|
||||||
/* nothing */ { $$ = new std::string; }
|
/* nothing */ { $$ = new std::string; }
|
||||||
| text TEXT { delete $1; $$ = $2; }
|
| text TEXT { delete $1; $$ = $2; }
|
||||||
| text NUMBER { delete $1; $$ = new std::string (string_cast ($2)); }
|
| text NUMBER { delete $1; $$ = new std::string (string_cast ($2)); }
|
||||||
;
|
;
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ my $prefix = "lib/";
|
|||||||
sub contents ($)
|
sub contents ($)
|
||||||
{
|
{
|
||||||
my ($file) = @_;
|
my ($file) = @_;
|
||||||
local $/; # Turn on slurp-mode.
|
local $/; # Turn on slurp-mode.
|
||||||
my $f = new IO::File "< $file" or die "$file";
|
my $f = new IO::File "< $file" or die "$file";
|
||||||
my $contents = $f->getline or die "$file";
|
my $contents = $f->getline or die "$file";
|
||||||
$f->close;
|
$f->close;
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ MAINTAINERCLEANFILES = $(srcdir)/*.stamp $(BUILT_SOURCES)
|
|||||||
# Compile the parser and save cycles.
|
# Compile the parser and save cycles.
|
||||||
# This code comes from "Handling Tools that Produce Many Outputs",
|
# This code comes from "Handling Tools that Produce Many Outputs",
|
||||||
# from the Automake documentation.
|
# from the Automake documentation.
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
$(srcdir)/calc++-parser.stamp \
|
$(srcdir)/calc++-parser.stamp \
|
||||||
$(srcdir)/calc++-parser.yy \
|
$(srcdir)/calc++-parser.yy \
|
||||||
$(srcdir)/calc.stamp
|
$(srcdir)/calc.stamp
|
||||||
# Don't depend on $(BISON) otherwise we would rebuild these files
|
# Don't depend on $(BISON) otherwise we would rebuild these files
|
||||||
# in srcdir, including during distcheck, which is forbidden.
|
# in srcdir, including during distcheck, which is forbidden.
|
||||||
|
|||||||
@@ -65,23 +65,23 @@ BEGIN {
|
|||||||
# => + 2.
|
# => + 2.
|
||||||
# Note that recent Bison support it, but not Flex.
|
# Note that recent Bison support it, but not Flex.
|
||||||
if (file ~ /\.[chy]*$/)
|
if (file ~ /\.[chy]*$/)
|
||||||
input = "#line " (FNR + 1) " \"" FILENAME "\"\n";
|
input = "#line " (FNR + 1) " \"" FILENAME "\"\n";
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($0 ~ /^@end example$/)
|
if ($0 ~ /^@end example$/)
|
||||||
{
|
{
|
||||||
if (input == "")
|
if (input == "")
|
||||||
fatal("no contents: " file);
|
fatal("no contents: " file);
|
||||||
|
|
||||||
input = normalize(input);
|
input = normalize(input);
|
||||||
# No spurious end of line: use printf.
|
# No spurious end of line: use printf.
|
||||||
if (files_output[file])
|
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).
|
# by awk on Mac OS X Tiger (darwin 8.4.6).
|
||||||
printf ("%s", input) >> (output_dir "/" file);
|
printf ("%s", input) >> (output_dir "/" file);
|
||||||
else
|
else
|
||||||
printf ("%s", input) > (output_dir "/" file);
|
printf ("%s", input) > (output_dir "/" file);
|
||||||
close (output_dir "/" file);
|
close (output_dir "/" file);
|
||||||
files_output[file] = 1;
|
files_output[file] = 1;
|
||||||
|
|
||||||
@@ -105,11 +105,11 @@ function normalize(contents, i, lines, n, line, res) {
|
|||||||
|
|
||||||
# Whole line commands.
|
# Whole line commands.
|
||||||
if (line ~ /^@(c |comment|dots|end (ignore|group)|ignore|group)/)
|
if (line ~ /^@(c |comment|dots|end (ignore|group)|ignore|group)/)
|
||||||
# Gperf accepts empty lines as valid input!!!
|
# Gperf accepts empty lines as valid input!!!
|
||||||
if (file ~ /\.gperf$/)
|
if (file ~ /\.gperf$/)
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
line = "";
|
line = "";
|
||||||
|
|
||||||
gsub (/"@value\{VERSION\}"/, "\"" VERSION "\"", line)
|
gsub (/"@value\{VERSION\}"/, "\"" VERSION "\"", line)
|
||||||
gsub (/^@result\{\}/, "", line);
|
gsub (/^@result\{\}/, "", line);
|
||||||
|
|||||||
230
lib/abitset.c
230
lib/abitset.c
@@ -47,7 +47,7 @@ abitset_resize (bitset src, bitset_bindex size)
|
|||||||
found and with *NEXT indicating where search stopped. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
abitset_small_list (bitset src, bitset_bindex *list,
|
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 bitno;
|
||||||
bitset_bindex count;
|
bitset_bindex count;
|
||||||
@@ -73,27 +73,27 @@ abitset_small_list (bitset src, bitset_bindex *list,
|
|||||||
if (num >= BITSET_WORD_BITS)
|
if (num >= BITSET_WORD_BITS)
|
||||||
{
|
{
|
||||||
for (count = 0; word; bitno++)
|
for (count = 0; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (count = 0; word; bitno++)
|
for (count = 0; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
bitno++;
|
bitno++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*next = bitno;
|
*next = bitno;
|
||||||
@@ -115,7 +115,7 @@ abitset_set (bitset dst ATTRIBUTE_UNUSED, bitset_bindex bitno ATTRIBUTE_UNUSED)
|
|||||||
/* Reset bit BITNO in bitset DST. */
|
/* Reset bit BITNO in bitset DST. */
|
||||||
static void
|
static void
|
||||||
abitset_reset (bitset dst ATTRIBUTE_UNUSED,
|
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
|
/* This should never occur for abitsets since we should always hit
|
||||||
the cache. It is likely someone is trying to access outside the
|
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. */
|
/* Test bit BITNO in bitset SRC. */
|
||||||
static bool
|
static bool
|
||||||
abitset_test (bitset src ATTRIBUTE_UNUSED,
|
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
|
/* This should never occur for abitsets since we should always
|
||||||
hit the cache. */
|
hit the cache. */
|
||||||
@@ -140,7 +140,7 @@ abitset_test (bitset src ATTRIBUTE_UNUSED,
|
|||||||
stopped. */
|
stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
abitset_list_reverse (bitset src, bitset_bindex *list,
|
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 bitno;
|
||||||
bitset_bindex rbitno;
|
bitset_bindex rbitno;
|
||||||
@@ -173,18 +173,18 @@ abitset_list_reverse (bitset src, bitset_bindex *list,
|
|||||||
|
|
||||||
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||||
for (; word; bitcnt--)
|
for (; word; bitcnt--)
|
||||||
{
|
{
|
||||||
if (word & BITSET_MSB)
|
if (word & BITSET_MSB)
|
||||||
{
|
{
|
||||||
list[count++] = bitoff + bitcnt;
|
list[count++] = bitoff + bitcnt;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = n_bits - (bitoff + bitcnt);
|
*next = n_bits - (bitoff + bitcnt);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word <<= 1;
|
word <<= 1;
|
||||||
}
|
}
|
||||||
bitoff -= BITSET_WORD_BITS;
|
bitoff -= BITSET_WORD_BITS;
|
||||||
bitcnt = BITSET_WORD_BITS - 1;
|
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. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
abitset_list (bitset src, bitset_bindex *list,
|
abitset_list (bitset src, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
bitset_bindex bitno;
|
||||||
bitset_bindex count;
|
bitset_bindex count;
|
||||||
@@ -217,80 +217,80 @@ abitset_list (bitset src, bitset_bindex *list,
|
|||||||
{
|
{
|
||||||
/* Many bitsets are zero, so make this common case fast. */
|
/* Many bitsets are zero, so make this common case fast. */
|
||||||
for (windex = 0; windex < size && !srcp[windex]; windex++)
|
for (windex = 0; windex < size && !srcp[windex]; windex++)
|
||||||
continue;
|
continue;
|
||||||
if (windex >= size)
|
if (windex >= size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* If num is 1, we could speed things up with a binary search
|
/* 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;
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (bitno >= BITSET_SIZE_ (src))
|
if (bitno >= BITSET_SIZE_ (src))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
windex = bitno / BITSET_WORD_BITS;
|
windex = bitno / BITSET_WORD_BITS;
|
||||||
bitno = bitno % BITSET_WORD_BITS;
|
bitno = bitno % BITSET_WORD_BITS;
|
||||||
|
|
||||||
if (bitno)
|
if (bitno)
|
||||||
{
|
{
|
||||||
/* Handle the case where we start within a word.
|
/* Handle the case where we start within a word.
|
||||||
Most often, this is executed with large bitsets
|
Most often, this is executed with large bitsets
|
||||||
with many set bits where we filled the array
|
with many set bits where we filled the array
|
||||||
on the previous call to this function. */
|
on the previous call to this function. */
|
||||||
|
|
||||||
bitoff = windex * BITSET_WORD_BITS;
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
word = srcp[windex] >> bitno;
|
word = srcp[windex] >> bitno;
|
||||||
for (bitno = bitoff + bitno; word; bitno++)
|
for (bitno = bitoff + bitno; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
}
|
}
|
||||||
bitoff = windex * BITSET_WORD_BITS;
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
|
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
|
||||||
{
|
{
|
||||||
if (!(word = srcp[windex]))
|
if (!(word = srcp[windex]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((count + BITSET_WORD_BITS) < num)
|
if ((count + BITSET_WORD_BITS) < num)
|
||||||
{
|
{
|
||||||
for (bitno = bitoff; word; bitno++)
|
for (bitno = bitoff; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (bitno = bitoff; word; bitno++)
|
for (bitno = bitoff; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*next = bitoff;
|
*next = bitoff;
|
||||||
@@ -387,7 +387,7 @@ abitset_equal_p (bitset dst, bitset src)
|
|||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
if (*srcp++ != *dstp++)
|
if (*srcp++ != *dstp++)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +402,7 @@ abitset_subset_p (bitset dst, bitset src)
|
|||||||
|
|
||||||
for (i = 0; i < size; i++, dstp++, srcp++)
|
for (i = 0; i < size; i++, dstp++, srcp++)
|
||||||
if (*dstp != (*srcp | *dstp))
|
if (*dstp != (*srcp | *dstp))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +417,7 @@ abitset_disjoint_p (bitset dst, bitset src)
|
|||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
if (*srcp++ & *dstp++)
|
if (*srcp++ & *dstp++)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -452,10 +452,10 @@ abitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++ & *src2p++;
|
bitset_word tmp = *src1p++ & *src2p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -490,10 +490,10 @@ abitset_andn_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++ & ~(*src2p++);
|
bitset_word tmp = *src1p++ & ~(*src2p++);
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -528,10 +528,10 @@ abitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++ | *src2p++;
|
bitset_word tmp = *src1p++ | *src2p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -566,10 +566,10 @@ abitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++ ^ *src2p++;
|
bitset_word tmp = *src1p++ ^ *src2p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -606,10 +606,10 @@ abitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -646,10 +646,10 @@ abitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -686,10 +686,10 @@ abitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,9 @@
|
|||||||
Memory for bit array and bitset structure allocated
|
Memory for bit array and bitset structure allocated
|
||||||
contiguously.
|
contiguously.
|
||||||
BITSET_LIST: Linked list of arrays of bits (variable size, least storage
|
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
|
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.
|
Faster than BITSET_LIST for random access.
|
||||||
BITSET_VARRAY: Variable array of bits (variable size, fast for
|
BITSET_VARRAY: Variable array of bits (variable size, fast for
|
||||||
dense bitsets).
|
dense bitsets).
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
statistics and/or better run-time checking.
|
statistics and/or better run-time checking.
|
||||||
*/
|
*/
|
||||||
enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_VARRAY,
|
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"}
|
#define BITSET_TYPE_NAMES {"abitset", "lbitset", "ebitset", "vbitset"}
|
||||||
|
|
||||||
extern const char * const bitset_type_names[];
|
extern const char * const bitset_type_names[];
|
||||||
@@ -78,19 +78,19 @@ typedef size_t bitset_windex;
|
|||||||
#define BITSET_LIST_SIZE 1024
|
#define BITSET_LIST_SIZE 1024
|
||||||
|
|
||||||
enum bitset_ops {BITSET_OP_ZERO, BITSET_OP_ONES,
|
enum bitset_ops {BITSET_OP_ZERO, BITSET_OP_ONES,
|
||||||
BITSET_OP_COPY, BITSET_OP_NOT,
|
BITSET_OP_COPY, BITSET_OP_NOT,
|
||||||
BITSET_OP_EMPTY_P, BITSET_OP_EQUAL_P,
|
BITSET_OP_EMPTY_P, BITSET_OP_EQUAL_P,
|
||||||
BITSET_OP_SUBSET_P, BITSET_OP_DISJOINT_P,
|
BITSET_OP_SUBSET_P, BITSET_OP_DISJOINT_P,
|
||||||
BITSET_OP_AND, BITSET_OP_OR, BITSET_OP_XOR, BITSET_OP_ANDN,
|
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_OR_AND, BITSET_OP_AND_OR, BITSET_OP_ANDN_OR};
|
||||||
|
|
||||||
struct bbitset_struct
|
struct bbitset_struct
|
||||||
{
|
{
|
||||||
const struct bitset_vtable *vtable;
|
const struct bitset_vtable *vtable;
|
||||||
bitset_windex cindex; /* Cache word index. */
|
bitset_windex cindex; /* Cache word index. */
|
||||||
bitset_windex csize; /* Cache size in words. */
|
bitset_windex csize; /* Cache size in words. */
|
||||||
bitset_word *cdata; /* Cache data pointer. */
|
bitset_word *cdata; /* Cache data pointer. */
|
||||||
bitset_bindex n_bits; /* Number of bits. */
|
bitset_bindex n_bits; /* Number of bits. */
|
||||||
/* Perhaps we could sacrifice another word to indicate
|
/* Perhaps we could sacrifice another word to indicate
|
||||||
that the bitset is known to be zero, that a bit has been set
|
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.
|
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);
|
bool (*or_and_cmp) (bitset, bitset, bitset, bitset);
|
||||||
|
|
||||||
bitset_bindex (*list) (bitset, bitset_bindex *, bitset_bindex,
|
bitset_bindex (*list) (bitset, bitset_bindex *, bitset_bindex,
|
||||||
bitset_bindex *);
|
bitset_bindex *);
|
||||||
bitset_bindex (*list_reverse) (bitset, bitset_bindex *, bitset_bindex,
|
bitset_bindex (*list_reverse) (bitset, bitset_bindex *, bitset_bindex,
|
||||||
bitset_bindex *);
|
bitset_bindex *);
|
||||||
void (*free) (bitset);
|
void (*free) (bitset);
|
||||||
enum bitset_type type;
|
enum bitset_type type;
|
||||||
};
|
};
|
||||||
|
|||||||
10
lib/bitset.c
10
lib/bitset.c
@@ -151,7 +151,7 @@ bitset_alloc (bitset_bindex n_bits, enum bitset_type type)
|
|||||||
/* Create a bitset of N_BITS of type TYPE. */
|
/* Create a bitset of N_BITS of type TYPE. */
|
||||||
bitset
|
bitset
|
||||||
bitset_obstack_alloc (struct obstack *bobstack,
|
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;
|
size_t bytes;
|
||||||
bitset bset;
|
bitset bset;
|
||||||
@@ -296,15 +296,15 @@ bitset_print (FILE *file, bitset bset, bool verbose)
|
|||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf (file, "n_bits = %lu, set = {",
|
fprintf (file, "n_bits = %lu, set = {",
|
||||||
(unsigned long int) bitset_size (bset));
|
(unsigned long int) bitset_size (bset));
|
||||||
|
|
||||||
pos = 30;
|
pos = 30;
|
||||||
BITSET_FOR_EACH (iter, bset, i, 0)
|
BITSET_FOR_EACH (iter, bset, i, 0)
|
||||||
{
|
{
|
||||||
if (pos > 70)
|
if (pos > 70)
|
||||||
{
|
{
|
||||||
fprintf (file, "\n");
|
fprintf (file, "\n");
|
||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (file, "%lu ", (unsigned long int) i);
|
fprintf (file, "%lu ", (unsigned long int) i);
|
||||||
@@ -407,7 +407,7 @@ bitset_copy_ (bitset dst, bitset src)
|
|||||||
four operand operations. */
|
four operand operations. */
|
||||||
static inline bool
|
static inline bool
|
||||||
bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
|
bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
|
||||||
enum bitset_ops op)
|
enum bitset_ops op)
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bool stats_enabled_save;
|
bool stats_enabled_save;
|
||||||
|
|||||||
58
lib/bitset.h
58
lib/bitset.h
@@ -33,11 +33,11 @@
|
|||||||
|
|
||||||
/* Attributes used to select a bitset implementation. */
|
/* Attributes used to select a bitset implementation. */
|
||||||
enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
|
enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
|
||||||
BITSET_VARIABLE = 2, /* Bitset size variable. */
|
BITSET_VARIABLE = 2, /* Bitset size variable. */
|
||||||
BITSET_DENSE = 4, /* Bitset dense. */
|
BITSET_DENSE = 4, /* Bitset dense. */
|
||||||
BITSET_SPARSE = 8, /* Bitset sparse. */
|
BITSET_SPARSE = 8, /* Bitset sparse. */
|
||||||
BITSET_FRUGAL = 16, /* Prefer most compact. */
|
BITSET_FRUGAL = 16, /* Prefer most compact. */
|
||||||
BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */
|
BITSET_GREEDY = 32}; /* Prefer fastest at memory expense. */
|
||||||
|
|
||||||
typedef unsigned int bitset_attrs;
|
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
|
/* This must be the first member of every other structure that is a
|
||||||
member of this union. */
|
member of this union. */
|
||||||
struct bbitset_struct b; /* Base bitset data. */
|
struct bbitset_struct b; /* Base bitset data. */
|
||||||
|
|
||||||
struct abitset_struct
|
struct abitset_struct
|
||||||
{
|
{
|
||||||
struct bbitset_struct b;
|
struct bbitset_struct b;
|
||||||
bitset_word words[1]; /* The array of bits. */
|
bitset_word words[1]; /* The array of bits. */
|
||||||
} a;
|
} a;
|
||||||
|
|
||||||
struct ebitset_struct
|
struct ebitset_struct
|
||||||
{
|
{
|
||||||
struct bbitset_struct b;
|
struct bbitset_struct b;
|
||||||
bitset_windex size; /* Number of elements. */
|
bitset_windex size; /* Number of elements. */
|
||||||
struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
|
struct ebitset_elt_struct **elts; /* Expanding array of ptrs to elts. */
|
||||||
} e;
|
} e;
|
||||||
|
|
||||||
struct lbitset_struct
|
struct lbitset_struct
|
||||||
{
|
{
|
||||||
struct bbitset_struct b;
|
struct bbitset_struct b;
|
||||||
struct lbitset_elt_struct *head; /* First element in linked list. */
|
struct lbitset_elt_struct *head; /* First element in linked list. */
|
||||||
struct lbitset_elt_struct *tail; /* Last element in linked list. */
|
struct lbitset_elt_struct *tail; /* Last element in linked list. */
|
||||||
} l;
|
} l;
|
||||||
|
|
||||||
struct bitset_stats_struct
|
struct bitset_stats_struct
|
||||||
@@ -80,7 +80,7 @@ union bitset_union
|
|||||||
struct vbitset_struct
|
struct vbitset_struct
|
||||||
{
|
{
|
||||||
struct bbitset_struct b;
|
struct bbitset_struct b;
|
||||||
bitset_windex size; /* Allocated size of array. */
|
bitset_windex size; /* Allocated size of array. */
|
||||||
} v;
|
} v;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -116,7 +116,7 @@ extern void bitset_free (bitset);
|
|||||||
/* Create a bitset of desired type and size using an obstack. The
|
/* Create a bitset of desired type and size using an obstack. The
|
||||||
bitset is zeroed. */
|
bitset is zeroed. */
|
||||||
extern bitset bitset_obstack_alloc (struct obstack *bobstack,
|
extern bitset bitset_obstack_alloc (struct obstack *bobstack,
|
||||||
bitset_bindex, enum bitset_type);
|
bitset_bindex, enum bitset_type);
|
||||||
|
|
||||||
/* Free bitset allocated on obstack. */
|
/* Free bitset allocated on obstack. */
|
||||||
extern void bitset_obstack_free (bitset);
|
extern void bitset_obstack_free (bitset);
|
||||||
@@ -312,14 +312,14 @@ extern void bitset_dump (FILE *, bitset);
|
|||||||
printf ("%lu ", (unsigned long int) i);
|
printf ("%lu ", (unsigned long int) i);
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
|
#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
|
||||||
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
||||||
(ITER.num == BITSET_LIST_SIZE) \
|
(ITER.num == BITSET_LIST_SIZE) \
|
||||||
&& (ITER.num = bitset_list (BSET, ITER.list, \
|
&& (ITER.num = bitset_list (BSET, ITER.list, \
|
||||||
BITSET_LIST_SIZE, &ITER.next));) \
|
BITSET_LIST_SIZE, &ITER.next));) \
|
||||||
for (ITER.i = 0; \
|
for (ITER.i = 0; \
|
||||||
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
|
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
|
||||||
ITER.i++)
|
ITER.i++)
|
||||||
|
|
||||||
|
|
||||||
/* Loop over all elements of BSET, in reverse order starting with
|
/* 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);
|
printf ("%lu ", (unsigned long int) i);
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
|
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
|
||||||
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
|
||||||
(ITER.num == BITSET_LIST_SIZE) \
|
(ITER.num == BITSET_LIST_SIZE) \
|
||||||
&& (ITER.num = bitset_list_reverse (BSET, ITER.list, \
|
&& (ITER.num = bitset_list_reverse (BSET, ITER.list, \
|
||||||
BITSET_LIST_SIZE, &ITER.next));) \
|
BITSET_LIST_SIZE, &ITER.next));) \
|
||||||
for (ITER.i = 0; \
|
for (ITER.i = 0; \
|
||||||
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
|
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
|
||||||
ITER.i++)
|
ITER.i++)
|
||||||
|
|
||||||
|
|
||||||
/* Define set operations in terms of logical operations. */
|
/* Define set operations in terms of logical operations. */
|
||||||
|
|||||||
@@ -48,29 +48,29 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Accessor macros. */
|
/* Accessor macros. */
|
||||||
#define BITSET_STATS_ALLOCS_INC(TYPE) \
|
#define BITSET_STATS_ALLOCS_INC(TYPE) \
|
||||||
bitset_stats_info->types[(TYPE)].allocs++
|
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++
|
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++
|
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++
|
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++
|
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++
|
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++
|
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++
|
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++
|
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)]++
|
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)]++
|
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)]++
|
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. */
|
/* Print a percentage histogram with message MSG to FILE. */
|
||||||
static void
|
static void
|
||||||
bitset_percent_histogram_print (FILE *file, const char *name, const char *msg,
|
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 i;
|
||||||
unsigned int total;
|
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);
|
fprintf (file, "%s %s", name, msg);
|
||||||
for (i = 0; i < n_bins; i++)
|
for (i = 0; i < n_bins; i++)
|
||||||
fprintf (file, "%.0f-%.0f%%\t%8u (%5.1f%%)\n",
|
fprintf (file, "%.0f-%.0f%%\t%8u (%5.1f%%)\n",
|
||||||
i * 100.0 / n_bins,
|
i * 100.0 / n_bins,
|
||||||
(i + 1) * 100.0 / n_bins, bins[i],
|
(i + 1) * 100.0 / n_bins, bins[i],
|
||||||
(100.0 * bins[i]) / total);
|
(100.0 * bins[i]) / total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Print a log histogram with message MSG to FILE. */
|
/* Print a log histogram with message MSG to FILE. */
|
||||||
static void
|
static void
|
||||||
bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
|
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 i;
|
||||||
unsigned int total;
|
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);
|
fprintf (file, "%s %s", name, msg);
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
fprintf (file, "%*d\t%8u (%5.1f%%)\n",
|
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++)
|
for (; i < n_bins; i++)
|
||||||
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
|
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
|
||||||
max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
|
max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
|
||||||
1UL << (i - 1),
|
1UL << (i - 1),
|
||||||
(1UL << i) - 1,
|
(1UL << i) - 1,
|
||||||
bins[i],
|
bins[i],
|
||||||
(100.0 * bins[i]) / total);
|
(100.0 * bins[i]) / total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Print bitset statistics to FILE. */
|
/* Print bitset statistics to FILE. */
|
||||||
static void
|
static void
|
||||||
bitset_stats_print_1 (FILE *file, const char *name,
|
bitset_stats_print_1 (FILE *file, const char *name,
|
||||||
struct bitset_type_info_struct *stats)
|
struct bitset_type_info_struct *stats)
|
||||||
{
|
{
|
||||||
if (!stats)
|
if (!stats)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fprintf (file, "%s:\n", name);
|
fprintf (file, "%s:\n", name);
|
||||||
fprintf (file, _("%u bitset_allocs, %u freed (%.2f%%).\n"),
|
fprintf (file, _("%u bitset_allocs, %u freed (%.2f%%).\n"),
|
||||||
stats->allocs, stats->frees,
|
stats->allocs, stats->frees,
|
||||||
stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);
|
stats->allocs ? 100.0 * stats->frees / stats->allocs : 0);
|
||||||
fprintf (file, _("%u bitset_sets, %u cached (%.2f%%)\n"),
|
fprintf (file, _("%u bitset_sets, %u cached (%.2f%%)\n"),
|
||||||
stats->sets, stats->cache_sets,
|
stats->sets, stats->cache_sets,
|
||||||
stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);
|
stats->sets ? 100.0 * stats->cache_sets / stats->sets : 0);
|
||||||
fprintf (file, _("%u bitset_resets, %u cached (%.2f%%)\n"),
|
fprintf (file, _("%u bitset_resets, %u cached (%.2f%%)\n"),
|
||||||
stats->resets, stats->cache_resets,
|
stats->resets, stats->cache_resets,
|
||||||
stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);
|
stats->resets ? 100.0 * stats->cache_resets / stats->resets : 0);
|
||||||
fprintf (file, _("%u bitset_tests, %u cached (%.2f%%)\n"),
|
fprintf (file, _("%u bitset_tests, %u cached (%.2f%%)\n"),
|
||||||
stats->tests, stats->cache_tests,
|
stats->tests, stats->cache_tests,
|
||||||
stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);
|
stats->tests ? 100.0 * stats->cache_tests / stats->tests : 0);
|
||||||
|
|
||||||
fprintf (file, _("%u bitset_lists\n"), stats->lists);
|
fprintf (file, _("%u bitset_lists\n"), stats->lists);
|
||||||
|
|
||||||
bitset_log_histogram_print (file, name, _("count log histogram\n"),
|
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_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_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++)
|
for (i = 0; i < BITSET_TYPE_NUM; i++)
|
||||||
bitset_stats_print_1 (file, bitset_type_names[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 (file)
|
||||||
{
|
{
|
||||||
if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||||
1, file) != 1)
|
1, file) != 1)
|
||||||
{
|
{
|
||||||
if (ferror (file))
|
if (ferror (file))
|
||||||
perror (_("Could not read stats file."));
|
perror (_("Could not read stats file."));
|
||||||
else
|
else
|
||||||
fprintf (stderr, _("Bad stats file size.\n"));
|
fprintf (stderr, _("Bad stats file size.\n"));
|
||||||
}
|
}
|
||||||
if (fclose (file) != 0)
|
if (fclose (file) != 0)
|
||||||
perror (_("Could not read stats file."));
|
perror (_("Could not read stats file."));
|
||||||
}
|
}
|
||||||
bitset_stats_info_data.runs++;
|
bitset_stats_info_data.runs++;
|
||||||
}
|
}
|
||||||
@@ -283,10 +283,10 @@ bitset_stats_write (const char *file_name)
|
|||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
|
||||||
1, file) != 1)
|
1, file) != 1)
|
||||||
perror (_("Could not write stats file."));
|
perror (_("Could not write stats file."));
|
||||||
if (fclose (file) != 0)
|
if (fclose (file) != 0)
|
||||||
perror (_("Could not write stats file."));
|
perror (_("Could not write stats file."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
perror (_("Could not open stats file for writing."));
|
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)
|
if (offset < bset->b.csize)
|
||||||
{
|
{
|
||||||
bset->b.cdata[offset] &=
|
bset->b.cdata[offset] &=
|
||||||
~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
~((bitset_word) 1 << (bitno % BITSET_WORD_BITS));
|
||||||
BITSET_STATS_CACHE_RESETS_INC (bset);
|
BITSET_STATS_CACHE_RESETS_INC (bset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -570,7 +570,7 @@ bitset_stats_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
|
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
bitset_stats_list (bitset bset, bitset_bindex *list,
|
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 count;
|
||||||
bitset_bindex tmp;
|
bitset_bindex tmp;
|
||||||
@@ -609,7 +609,7 @@ bitset_stats_list (bitset bset, bitset_bindex *list,
|
|||||||
|
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
bitset_stats_list_reverse (bitset bset, bitset_bindex *list,
|
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);
|
return BITSET_LIST_REVERSE_ (bset->s.bset, list, num, next);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ bitsetv_matrix_dump (FILE * out, const char *title, bitsetv bset)
|
|||||||
{
|
{
|
||||||
fprintf (out, "%2lu|", (unsigned long int) i);
|
fprintf (out, "%2lu|", (unsigned long int) i);
|
||||||
for (j = 0; j < hsize; ++j)
|
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);
|
fputs ("|\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
type TYPE. */
|
type TYPE. */
|
||||||
bitset *
|
bitset *
|
||||||
bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
|
bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
|
||||||
enum bitset_type type)
|
enum bitset_type type)
|
||||||
{
|
{
|
||||||
size_t vector_bytes;
|
size_t vector_bytes;
|
||||||
size_t bytes;
|
size_t bytes;
|
||||||
@@ -116,7 +116,7 @@ bitsetv_transitive_closure (bitsetv bsetv)
|
|||||||
for (i = 0; bsetv[i]; i++)
|
for (i = 0; bsetv[i]; i++)
|
||||||
for (j = 0; bsetv[j]; j++)
|
for (j = 0; bsetv[j]; j++)
|
||||||
if (bitset_test (bsetv[j], i))
|
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. */
|
FILE. */
|
||||||
void
|
void
|
||||||
bitsetv_dump (FILE *file, char const *title, char const *subtitle,
|
bitsetv_dump (FILE *file, char const *title, char const *subtitle,
|
||||||
bitsetv bsetv)
|
bitsetv bsetv)
|
||||||
{
|
{
|
||||||
bitset_windex i;
|
bitset_windex i;
|
||||||
|
|
||||||
|
|||||||
608
lib/ebitset.c
608
lib/ebitset.c
@@ -58,7 +58,7 @@ typedef struct ebitset_elt_struct
|
|||||||
{
|
{
|
||||||
union
|
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;
|
struct ebitset_elt_struct *next;
|
||||||
}
|
}
|
||||||
u;
|
u;
|
||||||
@@ -84,7 +84,7 @@ static ebitset_elt ebitset_zero_elts[1]; /* Elements of all zero bits. */
|
|||||||
/* Obstack to allocate bitset elements from. */
|
/* Obstack to allocate bitset elements from. */
|
||||||
static struct obstack ebitset_obstack;
|
static struct obstack ebitset_obstack;
|
||||||
static bool ebitset_obstack_init = false;
|
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_N_ELTS(N) (((N) + EBITSET_ELT_BITS - 1) / EBITSET_ELT_BITS)
|
||||||
#define EBITSET_ELTS(BSET) ((BSET)->e.elts)
|
#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. */
|
/* Disable bitset cache and mark BSET as being zero. */
|
||||||
#define EBITSET_ZERO_SET(BSET) ((BSET)->b.cindex = BITSET_WINDEX_MAX, \
|
#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)
|
#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;
|
bitset_windex size;
|
||||||
|
|
||||||
/* The bitset needs to grow. If we already have enough memory
|
/* 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))
|
if (newsize > EBITSET_ASIZE (src))
|
||||||
{
|
{
|
||||||
/* We need to allocate more memory. When oldsize is
|
/* We need to allocate more memory. When oldsize is
|
||||||
non-zero this means that we are changing the size, so
|
non-zero this means that we are changing the size, so
|
||||||
grow the bitset 25% larger than requested to reduce
|
grow the bitset 25% larger than requested to reduce
|
||||||
number of reallocations. */
|
number of reallocations. */
|
||||||
|
|
||||||
if (oldsize == 0)
|
if (oldsize == 0)
|
||||||
size = newsize;
|
size = newsize;
|
||||||
else
|
else
|
||||||
size = newsize + newsize / 4;
|
size = newsize + newsize / 4;
|
||||||
|
|
||||||
EBITSET_ELTS (src)
|
EBITSET_ELTS (src)
|
||||||
= realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
|
= realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
|
||||||
EBITSET_ASIZE (src) = size;
|
EBITSET_ASIZE (src) = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (EBITSET_ELTS (src) + oldsize, 0,
|
memset (EBITSET_ELTS (src) + oldsize, 0,
|
||||||
(newsize - oldsize) * sizeof (ebitset_elt *));
|
(newsize - oldsize) * sizeof (ebitset_elt *));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* The bitset needs to shrink. There's no point deallocating
|
/* 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)
|
if ((oldsize - newsize) >= oldsize / 2)
|
||||||
{
|
{
|
||||||
EBITSET_ELTS (src)
|
EBITSET_ELTS (src)
|
||||||
= realloc (EBITSET_ELTS (src), newsize * sizeof (ebitset_elt *));
|
= realloc (EBITSET_ELTS (src), newsize * sizeof (ebitset_elt *));
|
||||||
EBITSET_ASIZE (src) = newsize;
|
EBITSET_ASIZE (src) = newsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Need to prune any excess bits. FIXME. */
|
/* Need to prune any excess bits. FIXME. */
|
||||||
}
|
}
|
||||||
@@ -190,16 +190,16 @@ ebitset_elt_alloc (void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!ebitset_obstack_init)
|
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
|
#ifndef OBSTACK_CHUNK_SIZE
|
||||||
#define OBSTACK_CHUNK_SIZE 0
|
#define OBSTACK_CHUNK_SIZE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Let them override the alloc and free routines too. */
|
/* Let them override the alloc and free routines too. */
|
||||||
|
|
||||||
#ifndef OBSTACK_CHUNK_ALLOC
|
#ifndef OBSTACK_CHUNK_ALLOC
|
||||||
#define OBSTACK_CHUNK_ALLOC xmalloc
|
#define OBSTACK_CHUNK_ALLOC xmalloc
|
||||||
@@ -213,16 +213,16 @@ ebitset_elt_alloc (void)
|
|||||||
#define __alignof__(type) 0
|
#define __alignof__(type) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
obstack_specify_allocation (&ebitset_obstack, OBSTACK_CHUNK_SIZE,
|
obstack_specify_allocation (&ebitset_obstack, OBSTACK_CHUNK_SIZE,
|
||||||
__alignof__ (ebitset_elt),
|
__alignof__ (ebitset_elt),
|
||||||
OBSTACK_CHUNK_ALLOC,
|
OBSTACK_CHUNK_ALLOC,
|
||||||
OBSTACK_CHUNK_FREE);
|
OBSTACK_CHUNK_FREE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perhaps we should add a number of new elements to the free
|
/* Perhaps we should add a number of new elements to the free
|
||||||
list. */
|
list. */
|
||||||
elt = (ebitset_elt *) obstack_alloc (&ebitset_obstack,
|
elt = (ebitset_elt *) obstack_alloc (&ebitset_obstack,
|
||||||
sizeof (ebitset_elt));
|
sizeof (ebitset_elt));
|
||||||
}
|
}
|
||||||
|
|
||||||
return elt;
|
return elt;
|
||||||
@@ -293,7 +293,7 @@ ebitset_elt_zero_p (ebitset_elt *elt)
|
|||||||
|
|
||||||
static ebitset_elt *
|
static ebitset_elt *
|
||||||
ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
||||||
enum ebitset_find_mode mode)
|
enum ebitset_find_mode mode)
|
||||||
{
|
{
|
||||||
ebitset_elt *elt;
|
ebitset_elt *elt;
|
||||||
bitset_windex size;
|
bitset_windex size;
|
||||||
@@ -308,13 +308,13 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
|||||||
if (eindex < size)
|
if (eindex < size)
|
||||||
{
|
{
|
||||||
if ((elt = elts[eindex]))
|
if ((elt = elts[eindex]))
|
||||||
{
|
{
|
||||||
if (EBITSET_WORDS (elt) == bset->b.cdata)
|
if (EBITSET_WORDS (elt) == bset->b.cdata)
|
||||||
return elt;
|
return elt;
|
||||||
|
|
||||||
EBITSET_CACHE_SET (bset, eindex);
|
EBITSET_CACHE_SET (bset, eindex);
|
||||||
return elt;
|
return elt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The element could not be found. */
|
/* The element could not be found. */
|
||||||
@@ -329,7 +329,7 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
|
|||||||
|
|
||||||
case EBITSET_CREATE:
|
case EBITSET_CREATE:
|
||||||
if (eindex >= size)
|
if (eindex >= size)
|
||||||
ebitset_resize (bset, bindex);
|
ebitset_resize (bset, bindex);
|
||||||
|
|
||||||
/* Create a new element. */
|
/* Create a new element. */
|
||||||
elt = ebitset_elt_calloc ();
|
elt = ebitset_elt_calloc ();
|
||||||
@@ -361,22 +361,22 @@ ebitset_weed (bitset bset)
|
|||||||
ebitset_elt *elt = elts[j];
|
ebitset_elt *elt = elts[j];
|
||||||
|
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
if (ebitset_elt_zero_p (elt))
|
if (ebitset_elt_zero_p (elt))
|
||||||
{
|
{
|
||||||
ebitset_elt_remove (bset, j);
|
ebitset_elt_remove (bset, j);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
count = j - count;
|
count = j - count;
|
||||||
if (!count)
|
if (!count)
|
||||||
{
|
{
|
||||||
/* All the bits are zero. We could shrink the elts.
|
/* 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);
|
EBITSET_ZERO_SET (bset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -402,7 +402,7 @@ ebitset_zero (bitset bset)
|
|||||||
ebitset_elt *elt = elts[j];
|
ebitset_elt *elt = elts[j];
|
||||||
|
|
||||||
if (elt)
|
if (elt)
|
||||||
ebitset_elt_remove (bset, j);
|
ebitset_elt_remove (bset, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* All the bits are zero. We could shrink the elts.
|
/* 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];
|
ebitset_elt *delt = delts[j];
|
||||||
|
|
||||||
if (!selt && !delt)
|
if (!selt && !delt)
|
||||||
continue;
|
continue;
|
||||||
if ((selt && !delt) || (!selt && delt))
|
if ((selt && !delt) || (!selt && delt))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||||
if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
|
if (EBITSET_WORDS (selt)[i] != EBITSET_WORDS (delt)[i])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -472,14 +472,14 @@ ebitset_copy_ (bitset dst, bitset src)
|
|||||||
ebitset_elt *selt = selts[j];
|
ebitset_elt *selt = selts[j];
|
||||||
|
|
||||||
if (selt)
|
if (selt)
|
||||||
{
|
{
|
||||||
ebitset_elt *tmp;
|
ebitset_elt *tmp;
|
||||||
|
|
||||||
tmp = ebitset_elt_alloc ();
|
tmp = ebitset_elt_alloc ();
|
||||||
delts[j] = tmp;
|
delts[j] = tmp;
|
||||||
memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt),
|
memcpy (EBITSET_WORDS (tmp), EBITSET_WORDS (selt),
|
||||||
sizeof (EBITSET_WORDS (selt)));
|
sizeof (EBITSET_WORDS (selt)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EBITSET_NONZERO_SET (dst);
|
EBITSET_NONZERO_SET (dst);
|
||||||
}
|
}
|
||||||
@@ -545,9 +545,9 @@ ebitset_test (bitset src, bitset_bindex bitno)
|
|||||||
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||||
|
|
||||||
return (ebitset_elt_find (src, bitno, EBITSET_FIND)
|
return (ebitset_elt_find (src, bitno, EBITSET_FIND)
|
||||||
&& ((src->b.cdata[windex - src->b.cindex]
|
&& ((src->b.cdata[windex - src->b.cindex]
|
||||||
>> (bitno % BITSET_WORD_BITS))
|
>> (bitno % BITSET_WORD_BITS))
|
||||||
& 1));
|
& 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -564,7 +564,7 @@ ebitset_free (bitset bset)
|
|||||||
found and with *NEXT indicating where search stopped. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
ebitset_list_reverse (bitset bset, bitset_bindex *list,
|
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 n_bits;
|
||||||
bitset_bindex bitno;
|
bitset_bindex bitno;
|
||||||
@@ -610,33 +610,33 @@ ebitset_list_reverse (bitset bset, bitset_bindex *list,
|
|||||||
|
|
||||||
elt = elts[eindex];
|
elt = elts[eindex];
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
srcp = EBITSET_WORDS (elt);
|
srcp = EBITSET_WORDS (elt);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bitset_word word;
|
bitset_word word;
|
||||||
|
|
||||||
word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
|
word = srcp[woffset] << (BITSET_WORD_BITS - 1 - bcount);
|
||||||
|
|
||||||
for (; word; bcount--)
|
for (; word; bcount--)
|
||||||
{
|
{
|
||||||
if (word & BITSET_MSB)
|
if (word & BITSET_MSB)
|
||||||
{
|
{
|
||||||
list[count++] = boffset + bcount;
|
list[count++] = boffset + bcount;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = n_bits - (boffset + bcount);
|
*next = n_bits - (boffset + bcount);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word <<= 1;
|
word <<= 1;
|
||||||
}
|
}
|
||||||
boffset -= BITSET_WORD_BITS;
|
boffset -= BITSET_WORD_BITS;
|
||||||
bcount = BITSET_WORD_BITS - 1;
|
bcount = BITSET_WORD_BITS - 1;
|
||||||
}
|
}
|
||||||
while (woffset--);
|
while (woffset--);
|
||||||
}
|
}
|
||||||
|
|
||||||
woffset = EBITSET_ELT_WORDS - 1;
|
woffset = EBITSET_ELT_WORDS - 1;
|
||||||
boffset = eindex * EBITSET_ELT_BITS - BITSET_WORD_BITS;
|
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. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
ebitset_list (bitset bset, bitset_bindex *list,
|
ebitset_list (bitset bset, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
bitset_bindex bitno;
|
||||||
bitset_windex windex;
|
bitset_windex windex;
|
||||||
@@ -680,33 +680,33 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
|||||||
|
|
||||||
elt = elts[eindex];
|
elt = elts[eindex];
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
bitset_windex woffset;
|
bitset_windex woffset;
|
||||||
bitset_word *srcp = EBITSET_WORDS (elt);
|
bitset_word *srcp = EBITSET_WORDS (elt);
|
||||||
|
|
||||||
windex = bitno / BITSET_WORD_BITS;
|
windex = bitno / BITSET_WORD_BITS;
|
||||||
woffset = eindex * EBITSET_ELT_WORDS;
|
woffset = eindex * EBITSET_ELT_WORDS;
|
||||||
|
|
||||||
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
|
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
|
||||||
{
|
{
|
||||||
word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS);
|
word = srcp[windex - woffset] >> (bitno % BITSET_WORD_BITS);
|
||||||
|
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
bitno = (windex + 1) * BITSET_WORD_BITS;
|
bitno = (windex + 1) * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip to next element. */
|
/* Skip to next element. */
|
||||||
eindex++;
|
eindex++;
|
||||||
@@ -722,108 +722,108 @@ ebitset_list (bitset bset, bitset_bindex *list,
|
|||||||
|
|
||||||
elt = elts[eindex];
|
elt = elts[eindex];
|
||||||
if (!elt)
|
if (!elt)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
srcp = EBITSET_WORDS (elt);
|
srcp = EBITSET_WORDS (elt);
|
||||||
windex = eindex * EBITSET_ELT_WORDS;
|
windex = eindex * EBITSET_ELT_WORDS;
|
||||||
|
|
||||||
if ((count + EBITSET_ELT_BITS) < num)
|
if ((count + EBITSET_ELT_BITS) < num)
|
||||||
{
|
{
|
||||||
/* The coast is clear, plant boot! */
|
/* The coast is clear, plant boot! */
|
||||||
|
|
||||||
#if EBITSET_ELT_WORDS == 2
|
#if EBITSET_ELT_WORDS == 2
|
||||||
word = srcp[0];
|
word = srcp[0];
|
||||||
if (word)
|
if (word)
|
||||||
{
|
{
|
||||||
if (!(word & 0xffff))
|
if (!(word & 0xffff))
|
||||||
{
|
{
|
||||||
word >>= 16;
|
word >>= 16;
|
||||||
bitno += 16;
|
bitno += 16;
|
||||||
}
|
}
|
||||||
if (!(word & 0xff))
|
if (!(word & 0xff))
|
||||||
{
|
{
|
||||||
word >>= 8;
|
word >>= 8;
|
||||||
bitno += 8;
|
bitno += 8;
|
||||||
}
|
}
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
word = srcp[1];
|
word = srcp[1];
|
||||||
if (word)
|
if (word)
|
||||||
{
|
{
|
||||||
if (!(word & 0xffff))
|
if (!(word & 0xffff))
|
||||||
{
|
{
|
||||||
word >>= 16;
|
word >>= 16;
|
||||||
bitno += 16;
|
bitno += 16;
|
||||||
}
|
}
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
#else
|
#else
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
|
||||||
{
|
{
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
word = srcp[i];
|
word = srcp[i];
|
||||||
if (word)
|
if (word)
|
||||||
{
|
{
|
||||||
if (!(word & 0xffff))
|
if (!(word & 0xffff))
|
||||||
{
|
{
|
||||||
word >>= 16;
|
word >>= 16;
|
||||||
bitno += 16;
|
bitno += 16;
|
||||||
}
|
}
|
||||||
if (!(word & 0xff))
|
if (!(word & 0xff))
|
||||||
{
|
{
|
||||||
word >>= 8;
|
word >>= 8;
|
||||||
bitno += 8;
|
bitno += 8;
|
||||||
}
|
}
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Tread more carefully since we need to check
|
/* Tread more carefully since we need to check
|
||||||
if array overflows. */
|
if array overflows. */
|
||||||
|
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++, windex++)
|
||||||
{
|
{
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
for (word = srcp[i]; word; bitno++)
|
for (word = srcp[i]; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*next = bitno;
|
*next = bitno;
|
||||||
@@ -853,19 +853,19 @@ ebitset_unused_clear (bitset dst)
|
|||||||
|
|
||||||
elt = elts[eindex];
|
elt = elts[eindex];
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
bitset_windex windex;
|
bitset_windex windex;
|
||||||
bitset_windex woffset;
|
bitset_windex woffset;
|
||||||
bitset_word *srcp = EBITSET_WORDS (elt);
|
bitset_word *srcp = EBITSET_WORDS (elt);
|
||||||
|
|
||||||
windex = n_bits / BITSET_WORD_BITS;
|
windex = n_bits / BITSET_WORD_BITS;
|
||||||
woffset = eindex * EBITSET_ELT_WORDS;
|
woffset = eindex * EBITSET_ELT_WORDS;
|
||||||
|
|
||||||
srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
|
srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
|
||||||
windex++;
|
windex++;
|
||||||
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
|
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
|
||||||
srcp[windex - woffset] = 0;
|
srcp[windex - woffset] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -879,9 +879,9 @@ ebitset_ones (bitset dst)
|
|||||||
for (j = 0; j < EBITSET_SIZE (dst); j++)
|
for (j = 0; j < EBITSET_SIZE (dst); j++)
|
||||||
{
|
{
|
||||||
/* Create new elements if they cannot be found. Perhaps
|
/* 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 =
|
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)));
|
memset (EBITSET_WORDS (elt), -1, sizeof (EBITSET_WORDS (elt)));
|
||||||
}
|
}
|
||||||
EBITSET_NONZERO_SET (dst);
|
EBITSET_NONZERO_SET (dst);
|
||||||
@@ -904,12 +904,12 @@ ebitset_empty_p (bitset dst)
|
|||||||
ebitset_elt *elt = elts[j];
|
ebitset_elt *elt = elts[j];
|
||||||
|
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
if (!ebitset_elt_zero_p (elt))
|
if (!ebitset_elt_zero_p (elt))
|
||||||
return 0;
|
return 0;
|
||||||
/* Do some weeding as we go. */
|
/* Do some weeding as we go. */
|
||||||
ebitset_elt_remove (dst, j);
|
ebitset_elt_remove (dst, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* All the bits are zero. We could shrink the elts.
|
/* 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++)
|
for (j = 0; j < EBITSET_SIZE (src); j++)
|
||||||
{
|
{
|
||||||
/* Create new elements for dst if they cannot be found
|
/* 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 =
|
selt =
|
||||||
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
|
ebitset_elt_find (dst, j * EBITSET_ELT_BITS, EBITSET_SUBST);
|
||||||
delt =
|
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++)
|
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_NONZERO_SET (dst);
|
||||||
ebitset_unused_clear (dst);
|
ebitset_unused_clear (dst);
|
||||||
@@ -972,17 +972,17 @@ ebitset_subset_p (bitset dst, bitset src)
|
|||||||
delt = j < dsize ? delts[j] : 0;
|
delt = j < dsize ? delts[j] : 0;
|
||||||
|
|
||||||
if (!selt && !delt)
|
if (!selt && !delt)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!selt)
|
if (!selt)
|
||||||
selt = &ebitset_zero_elts[0];
|
selt = &ebitset_zero_elts[0];
|
||||||
if (!delt)
|
if (!delt)
|
||||||
delt = &ebitset_zero_elts[0];
|
delt = &ebitset_zero_elts[0];
|
||||||
|
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||||
if (EBITSET_WORDS (delt)[i]
|
if (EBITSET_WORDS (delt)[i]
|
||||||
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
|
!= (EBITSET_WORDS (selt)[i] | EBITSET_WORDS (delt)[i]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1014,11 +1014,11 @@ ebitset_disjoint_p (bitset dst, bitset src)
|
|||||||
delt = j < dsize ? delts[j] : 0;
|
delt = j < dsize ? delts[j] : 0;
|
||||||
|
|
||||||
if (!selt || !delt)
|
if (!selt || !delt)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++)
|
||||||
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
|
if ((EBITSET_WORDS (selt)[i] & EBITSET_WORDS (delt)[i]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
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;
|
delt = j < dsize ? delts[j] : 0;
|
||||||
|
|
||||||
if (!selt1 && !selt2)
|
if (!selt1 && !selt2)
|
||||||
{
|
{
|
||||||
if (delt)
|
if (delt)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
ebitset_elt_remove (dst, j);
|
ebitset_elt_remove (dst, j);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selt1)
|
if (!selt1)
|
||||||
selt1 = &ebitset_zero_elts[0];
|
selt1 = &ebitset_zero_elts[0];
|
||||||
if (!selt2)
|
if (!selt2)
|
||||||
selt2 = &ebitset_zero_elts[0];
|
selt2 = &ebitset_zero_elts[0];
|
||||||
if (!delt)
|
if (!delt)
|
||||||
delt = ebitset_elt_calloc ();
|
delt = ebitset_elt_calloc ();
|
||||||
else
|
else
|
||||||
delts[j] = 0;
|
delts[j] = 0;
|
||||||
|
|
||||||
srcp1 = EBITSET_WORDS (selt1);
|
srcp1 = EBITSET_WORDS (selt1);
|
||||||
srcp2 = EBITSET_WORDS (selt2);
|
srcp2 = EBITSET_WORDS (selt2);
|
||||||
dstp = EBITSET_WORDS (delt);
|
dstp = EBITSET_WORDS (delt);
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
case BITSET_OP_OR:
|
case BITSET_OP_OR:
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ | *srcp2++;
|
bitset_word tmp = *srcp1++ | *srcp2++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_AND:
|
case BITSET_OP_AND:
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ & *srcp2++;
|
bitset_word tmp = *srcp1++ & *srcp2++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_XOR:
|
case BITSET_OP_XOR:
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ ^ *srcp2++;
|
bitset_word tmp = *srcp1++ ^ *srcp2++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_ANDN:
|
case BITSET_OP_ANDN:
|
||||||
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ & ~(*srcp2++);
|
bitset_word tmp = *srcp1++ & ~(*srcp2++);
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ebitset_elt_zero_p (delt))
|
if (!ebitset_elt_zero_p (delt))
|
||||||
{
|
{
|
||||||
ebitset_elt_add (dst, delt, j);
|
ebitset_elt_add (dst, delt, j);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ebitset_elt_free (delt);
|
ebitset_elt_free (delt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we have elements of DST left over, free them all. */
|
/* 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];
|
delt = delts[j];
|
||||||
|
|
||||||
if (delt)
|
if (delt)
|
||||||
ebitset_elt_remove (dst, j);
|
ebitset_elt_remove (dst, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
EBITSET_NONZERO_SET (dst);
|
EBITSET_NONZERO_SET (dst);
|
||||||
|
|||||||
720
lib/lbitset.c
720
lib/lbitset.c
@@ -60,10 +60,10 @@ typedef bitset_word lbitset_word;
|
|||||||
These are linked together in a doubly-linked list. */
|
These are linked together in a doubly-linked list. */
|
||||||
typedef struct lbitset_elt_struct
|
typedef struct lbitset_elt_struct
|
||||||
{
|
{
|
||||||
struct lbitset_elt_struct *next; /* Next element. */
|
struct lbitset_elt_struct *next; /* Next element. */
|
||||||
struct lbitset_elt_struct *prev; /* Previous element. */
|
struct lbitset_elt_struct *prev; /* Previous element. */
|
||||||
bitset_windex index; /* bitno / BITSET_WORD_BITS. */
|
bitset_windex index; /* bitno / BITSET_WORD_BITS. */
|
||||||
bitset_word words[LBITSET_ELT_WORDS]; /* Bits that are set. */
|
bitset_word words[LBITSET_ELT_WORDS]; /* Bits that are set. */
|
||||||
}
|
}
|
||||||
lbitset_elt;
|
lbitset_elt;
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ static lbitset_elt lbitset_zero_elts[3]; /* Elements of all zero bits. */
|
|||||||
/* Obstack to allocate bitset elements from. */
|
/* Obstack to allocate bitset elements from. */
|
||||||
static struct obstack lbitset_obstack;
|
static struct obstack lbitset_obstack;
|
||||||
static bool lbitset_obstack_init = false;
|
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);
|
extern void debug_lbitset (bitset);
|
||||||
|
|
||||||
@@ -102,16 +102,16 @@ lbitset_elt_alloc (void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!lbitset_obstack_init)
|
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
|
#ifndef OBSTACK_CHUNK_SIZE
|
||||||
#define OBSTACK_CHUNK_SIZE 0
|
#define OBSTACK_CHUNK_SIZE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Let them override the alloc and free routines too. */
|
/* Let them override the alloc and free routines too. */
|
||||||
|
|
||||||
#ifndef OBSTACK_CHUNK_ALLOC
|
#ifndef OBSTACK_CHUNK_ALLOC
|
||||||
#define OBSTACK_CHUNK_ALLOC xmalloc
|
#define OBSTACK_CHUNK_ALLOC xmalloc
|
||||||
@@ -125,16 +125,16 @@ lbitset_elt_alloc (void)
|
|||||||
#define __alignof__(type) 0
|
#define __alignof__(type) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
obstack_specify_allocation (&lbitset_obstack, OBSTACK_CHUNK_SIZE,
|
obstack_specify_allocation (&lbitset_obstack, OBSTACK_CHUNK_SIZE,
|
||||||
__alignof__ (lbitset_elt),
|
__alignof__ (lbitset_elt),
|
||||||
OBSTACK_CHUNK_ALLOC,
|
OBSTACK_CHUNK_ALLOC,
|
||||||
OBSTACK_CHUNK_FREE);
|
OBSTACK_CHUNK_FREE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perhaps we should add a number of new elements to the free
|
/* Perhaps we should add a number of new elements to the free
|
||||||
list. */
|
list. */
|
||||||
elt = (lbitset_elt *) obstack_alloc (&lbitset_obstack,
|
elt = (lbitset_elt *) obstack_alloc (&lbitset_obstack,
|
||||||
sizeof (lbitset_elt));
|
sizeof (lbitset_elt));
|
||||||
}
|
}
|
||||||
|
|
||||||
return elt;
|
return elt;
|
||||||
@@ -185,20 +185,20 @@ lbitset_elt_unlink (bitset bset, lbitset_elt *elt)
|
|||||||
if (LBITSET_CURRENT (bset) == elt)
|
if (LBITSET_CURRENT (bset) == elt)
|
||||||
{
|
{
|
||||||
if (next)
|
if (next)
|
||||||
{
|
{
|
||||||
bset->b.cdata = next->words;
|
bset->b.cdata = next->words;
|
||||||
bset->b.cindex = next->index;
|
bset->b.cindex = next->index;
|
||||||
}
|
}
|
||||||
else if (prev)
|
else if (prev)
|
||||||
{
|
{
|
||||||
bset->b.cdata = prev->words;
|
bset->b.cdata = prev->words;
|
||||||
bset->b.cindex = prev->index;
|
bset->b.cindex = prev->index;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bset->b.csize = 0;
|
bset->b.csize = 0;
|
||||||
bset->b.cdata = 0;
|
bset->b.cdata = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lbitset_elt_free (elt);
|
lbitset_elt_free (elt);
|
||||||
@@ -278,13 +278,13 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
|
|||||||
else if (windex < bset->b.cindex)
|
else if (windex < bset->b.cindex)
|
||||||
{
|
{
|
||||||
for (ptr = current;
|
for (ptr = current;
|
||||||
ptr->prev && ptr->prev->index > windex; ptr = ptr->prev)
|
ptr->prev && ptr->prev->index > windex; ptr = ptr->prev)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ptr->prev)
|
if (ptr->prev)
|
||||||
ptr->prev->next = elt;
|
ptr->prev->next = elt;
|
||||||
else
|
else
|
||||||
LBITSET_HEAD (bset) = elt;
|
LBITSET_HEAD (bset) = elt;
|
||||||
|
|
||||||
elt->prev = ptr->prev;
|
elt->prev = ptr->prev;
|
||||||
elt->next = ptr;
|
elt->next = ptr;
|
||||||
@@ -295,13 +295,13 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (ptr = current;
|
for (ptr = current;
|
||||||
ptr->next && ptr->next->index < windex; ptr = ptr->next)
|
ptr->next && ptr->next->index < windex; ptr = ptr->next)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ptr->next)
|
if (ptr->next)
|
||||||
ptr->next->prev = elt;
|
ptr->next->prev = elt;
|
||||||
else
|
else
|
||||||
LBITSET_TAIL (bset) = elt;
|
LBITSET_TAIL (bset) = elt;
|
||||||
|
|
||||||
elt->next = ptr->next;
|
elt->next = ptr->next;
|
||||||
elt->prev = ptr;
|
elt->prev = ptr;
|
||||||
@@ -317,7 +317,7 @@ lbitset_elt_link (bitset bset, lbitset_elt *elt)
|
|||||||
|
|
||||||
static lbitset_elt *
|
static lbitset_elt *
|
||||||
lbitset_elt_find (bitset bset, bitset_windex windex,
|
lbitset_elt_find (bitset bset, bitset_windex windex,
|
||||||
enum lbitset_find_mode mode)
|
enum lbitset_find_mode mode)
|
||||||
{
|
{
|
||||||
lbitset_elt *elt;
|
lbitset_elt *elt;
|
||||||
lbitset_elt *current;
|
lbitset_elt *current;
|
||||||
@@ -327,7 +327,7 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
|
|||||||
current = LBITSET_CURRENT (bset);
|
current = LBITSET_CURRENT (bset);
|
||||||
/* Check if element is the cached element. */
|
/* Check if element is the cached element. */
|
||||||
if ((windex - bset->b.cindex) < bset->b.csize)
|
if ((windex - bset->b.cindex) < bset->b.csize)
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -337,28 +337,28 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
|
|||||||
if (current)
|
if (current)
|
||||||
{
|
{
|
||||||
if (windex < bset->b.cindex)
|
if (windex < bset->b.cindex)
|
||||||
{
|
{
|
||||||
for (elt = current;
|
for (elt = current;
|
||||||
elt->prev && elt->index > windex; elt = elt->prev)
|
elt->prev && elt->index > windex; elt = elt->prev)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (elt = current;
|
for (elt = current;
|
||||||
elt->next && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
|
elt->next && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
|
||||||
elt = elt->next)
|
elt = elt->next)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ELT is the nearest to the one we want. If it's not the one
|
/* 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)
|
if (elt && (windex - elt->index) < LBITSET_ELT_WORDS)
|
||||||
{
|
{
|
||||||
bset->b.cindex = elt->index;
|
bset->b.cindex = elt->index;
|
||||||
bset->b.csize = LBITSET_ELT_WORDS;
|
bset->b.csize = LBITSET_ELT_WORDS;
|
||||||
bset->b.cdata = elt->words;
|
bset->b.cdata = elt->words;
|
||||||
return elt;
|
return elt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
@@ -394,7 +394,7 @@ lbitset_weed (bitset bset)
|
|||||||
{
|
{
|
||||||
next = elt->next;
|
next = elt->next;
|
||||||
if (lbitset_elt_zero_p (elt))
|
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)
|
selt && delt; selt = selt->next, delt = delt->next)
|
||||||
{
|
{
|
||||||
if (selt->index != delt->index)
|
if (selt->index != delt->index)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||||
if (delt->words[j] != selt->words[j])
|
if (delt->words[j] != selt->words[j])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !selt && !delt;
|
return !selt && !delt;
|
||||||
}
|
}
|
||||||
@@ -467,9 +467,9 @@ lbitset_copy (bitset dst, bitset src)
|
|||||||
tmp->prev = prev;
|
tmp->prev = prev;
|
||||||
tmp->next = 0;
|
tmp->next = 0;
|
||||||
if (prev)
|
if (prev)
|
||||||
prev->next = tmp;
|
prev->next = tmp;
|
||||||
else
|
else
|
||||||
LBITSET_HEAD (dst) = tmp;
|
LBITSET_HEAD (dst) = tmp;
|
||||||
prev = tmp;
|
prev = tmp;
|
||||||
|
|
||||||
memcpy (tmp->words, elt->words, sizeof (elt->words));
|
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;
|
bitset_windex windex = bitno / BITSET_WORD_BITS;
|
||||||
|
|
||||||
return (lbitset_elt_find (src, windex, LBITSET_FIND)
|
return (lbitset_elt_find (src, windex, LBITSET_FIND)
|
||||||
&& ((src->b.cdata[windex - src->b.cindex]
|
&& ((src->b.cdata[windex - src->b.cindex]
|
||||||
>> (bitno % BITSET_WORD_BITS))
|
>> (bitno % BITSET_WORD_BITS))
|
||||||
& 1));
|
& 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -567,7 +567,7 @@ lbitset_free (bitset bset)
|
|||||||
found and with *NEXT indicating where search stopped. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
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 rbitno;
|
||||||
bitset_bindex bitno;
|
bitset_bindex bitno;
|
||||||
@@ -603,7 +603,7 @@ lbitset_list_reverse (bitset bset, bitset_bindex *list,
|
|||||||
if (windex >= elt->index + LBITSET_ELT_WORDS)
|
if (windex >= elt->index + LBITSET_ELT_WORDS)
|
||||||
{
|
{
|
||||||
/* We are trying to start in no-mans land so start
|
/* 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;
|
bcount = BITSET_WORD_BITS - 1;
|
||||||
windex = elt->index + LBITSET_ELT_WORDS - 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;
|
bitset_word *srcp = elt->words;
|
||||||
|
|
||||||
for (; (windex - elt->index) < LBITSET_ELT_WORDS;
|
for (; (windex - elt->index) < LBITSET_ELT_WORDS;
|
||||||
windex--, boffset -= BITSET_WORD_BITS,
|
windex--, boffset -= BITSET_WORD_BITS,
|
||||||
bcount = BITSET_WORD_BITS - 1)
|
bcount = BITSET_WORD_BITS - 1)
|
||||||
{
|
{
|
||||||
word =
|
word =
|
||||||
srcp[windex - elt->index] << (BITSET_WORD_BITS - 1 - bcount);
|
srcp[windex - elt->index] << (BITSET_WORD_BITS - 1 - bcount);
|
||||||
|
|
||||||
for (; word; bcount--)
|
for (; word; bcount--)
|
||||||
{
|
{
|
||||||
if (word & BITSET_MSB)
|
if (word & BITSET_MSB)
|
||||||
{
|
{
|
||||||
list[count++] = boffset + bcount;
|
list[count++] = boffset + bcount;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = n_bits - (boffset + bcount);
|
*next = n_bits - (boffset + bcount);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word <<= 1;
|
word <<= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elt = elt->prev;
|
elt = elt->prev;
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
windex = elt->index + LBITSET_ELT_WORDS - 1;
|
windex = elt->index + LBITSET_ELT_WORDS - 1;
|
||||||
boffset = windex * BITSET_WORD_BITS;
|
boffset = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*next = n_bits - (boffset + 1);
|
*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. */
|
found and with *NEXT indicating where search stopped. */
|
||||||
static bitset_bindex
|
static bitset_bindex
|
||||||
lbitset_list (bitset bset, bitset_bindex *list,
|
lbitset_list (bitset bset, bitset_bindex *list,
|
||||||
bitset_bindex num, bitset_bindex *next)
|
bitset_bindex num, bitset_bindex *next)
|
||||||
{
|
{
|
||||||
bitset_bindex bitno;
|
bitset_bindex bitno;
|
||||||
bitset_windex windex;
|
bitset_windex windex;
|
||||||
@@ -693,51 +693,51 @@ lbitset_list (bitset bset, bitset_bindex *list,
|
|||||||
|
|
||||||
/* Skip to starting element. */
|
/* Skip to starting element. */
|
||||||
for (elt = head;
|
for (elt = head;
|
||||||
elt && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
|
elt && (elt->index + LBITSET_ELT_WORDS - 1) < windex;
|
||||||
elt = elt->next)
|
elt = elt->next)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!elt)
|
if (!elt)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (windex < elt->index)
|
if (windex < elt->index)
|
||||||
{
|
{
|
||||||
windex = elt->index;
|
windex = elt->index;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
else
|
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++)
|
for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
|
||||||
{
|
{
|
||||||
word = srcp[windex - elt->index] >> (bitno % BITSET_WORD_BITS);
|
word = srcp[windex - elt->index] >> (bitno % BITSET_WORD_BITS);
|
||||||
|
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
bitno = (windex + 1) * BITSET_WORD_BITS;
|
bitno = (windex + 1) * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
elt = elt->next;
|
elt = elt->next;
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
windex = elt->index;
|
windex = elt->index;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -750,109 +750,109 @@ lbitset_list (bitset bset, bitset_bindex *list,
|
|||||||
bitset_word *srcp = elt->words;
|
bitset_word *srcp = elt->words;
|
||||||
|
|
||||||
if ((count + LBITSET_ELT_BITS) < num)
|
if ((count + LBITSET_ELT_BITS) < num)
|
||||||
{
|
{
|
||||||
/* The coast is clear, plant boot! */
|
/* The coast is clear, plant boot! */
|
||||||
|
|
||||||
#if LBITSET_ELT_WORDS == 2
|
#if LBITSET_ELT_WORDS == 2
|
||||||
word = srcp[0];
|
word = srcp[0];
|
||||||
if (word)
|
if (word)
|
||||||
{
|
{
|
||||||
if (!(word & 0xffff))
|
if (!(word & 0xffff))
|
||||||
{
|
{
|
||||||
word >>= 16;
|
word >>= 16;
|
||||||
bitno += 16;
|
bitno += 16;
|
||||||
}
|
}
|
||||||
if (!(word & 0xff))
|
if (!(word & 0xff))
|
||||||
{
|
{
|
||||||
word >>= 8;
|
word >>= 8;
|
||||||
bitno += 8;
|
bitno += 8;
|
||||||
}
|
}
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
|
|
||||||
word = srcp[1];
|
word = srcp[1];
|
||||||
if (word)
|
if (word)
|
||||||
{
|
{
|
||||||
if (!(word & 0xffff))
|
if (!(word & 0xffff))
|
||||||
{
|
{
|
||||||
word >>= 16;
|
word >>= 16;
|
||||||
bitno += 16;
|
bitno += 16;
|
||||||
}
|
}
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
#else
|
#else
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||||
{
|
{
|
||||||
word = srcp[i];
|
word = srcp[i];
|
||||||
if (word)
|
if (word)
|
||||||
{
|
{
|
||||||
if (!(word & 0xffff))
|
if (!(word & 0xffff))
|
||||||
{
|
{
|
||||||
word >>= 16;
|
word >>= 16;
|
||||||
bitno += 16;
|
bitno += 16;
|
||||||
}
|
}
|
||||||
if (!(word & 0xff))
|
if (!(word & 0xff))
|
||||||
{
|
{
|
||||||
word >>= 8;
|
word >>= 8;
|
||||||
bitno += 8;
|
bitno += 8;
|
||||||
}
|
}
|
||||||
for (; word; bitno++)
|
for (; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Tread more carefully since we need to check
|
/* Tread more carefully since we need to check
|
||||||
if array overflows. */
|
if array overflows. */
|
||||||
|
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||||
{
|
{
|
||||||
for (word = srcp[i]; word; bitno++)
|
for (word = srcp[i]; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elt = elt->next;
|
elt = elt->next;
|
||||||
if (elt)
|
if (elt)
|
||||||
{
|
{
|
||||||
windex = elt->index;
|
windex = elt->index;
|
||||||
bitno = windex * BITSET_WORD_BITS;
|
bitno = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*next = bitno;
|
*next = bitno;
|
||||||
@@ -870,7 +870,7 @@ lbitset_empty_p (bitset dst)
|
|||||||
{
|
{
|
||||||
next = elt->next;
|
next = elt->next;
|
||||||
if (!lbitset_elt_zero_p (elt))
|
if (!lbitset_elt_zero_p (elt))
|
||||||
return 0;
|
return 0;
|
||||||
/* Weed as we go. */
|
/* Weed as we go. */
|
||||||
lbitset_elt_unlink (dst, elt);
|
lbitset_elt_unlink (dst, elt);
|
||||||
}
|
}
|
||||||
@@ -903,7 +903,7 @@ lbitset_unused_clear (bitset dst)
|
|||||||
windex++;
|
windex++;
|
||||||
|
|
||||||
for (; (windex - elt->index) < LBITSET_ELT_WORDS; 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)
|
for (i = 0; i < windex; i += LBITSET_ELT_WORDS)
|
||||||
{
|
{
|
||||||
/* Create new elements for dst if they cannot be found
|
/* 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);
|
selt = lbitset_elt_find (src, i, LBITSET_SUBST);
|
||||||
delt = lbitset_elt_find (dst, i, LBITSET_CREATE);
|
delt = lbitset_elt_find (dst, i, LBITSET_CREATE);
|
||||||
|
|
||||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
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_unused_clear (dst);
|
||||||
lbitset_weed (dst);
|
lbitset_weed (dst);
|
||||||
@@ -977,26 +977,26 @@ lbitset_subset_p (bitset dst, bitset src)
|
|||||||
selt || delt; selt = selt->next, delt = delt->next)
|
selt || delt; selt = selt->next, delt = delt->next)
|
||||||
{
|
{
|
||||||
if (!selt)
|
if (!selt)
|
||||||
selt = &lbitset_zero_elts[0];
|
selt = &lbitset_zero_elts[0];
|
||||||
else if (!delt)
|
else if (!delt)
|
||||||
delt = &lbitset_zero_elts[0];
|
delt = &lbitset_zero_elts[0];
|
||||||
else if (selt->index != delt->index)
|
else if (selt->index != delt->index)
|
||||||
{
|
{
|
||||||
if (selt->index < delt->index)
|
if (selt->index < delt->index)
|
||||||
{
|
{
|
||||||
lbitset_zero_elts[2].next = delt;
|
lbitset_zero_elts[2].next = delt;
|
||||||
delt = &lbitset_zero_elts[2];
|
delt = &lbitset_zero_elts[2];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lbitset_zero_elts[1].next = selt;
|
lbitset_zero_elts[1].next = selt;
|
||||||
selt = &lbitset_zero_elts[1];
|
selt = &lbitset_zero_elts[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||||
if (delt->words[j] != (selt->words[j] | delt->words[j]))
|
if (delt->words[j] != (selt->words[j] | delt->words[j]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1014,25 +1014,25 @@ lbitset_disjoint_p (bitset dst, bitset src)
|
|||||||
selt && delt; selt = selt->next, delt = delt->next)
|
selt && delt; selt = selt->next, delt = delt->next)
|
||||||
{
|
{
|
||||||
if (selt->index != delt->index)
|
if (selt->index != delt->index)
|
||||||
{
|
{
|
||||||
if (selt->index < delt->index)
|
if (selt->index < delt->index)
|
||||||
{
|
{
|
||||||
lbitset_zero_elts[2].next = delt;
|
lbitset_zero_elts[2].next = delt;
|
||||||
delt = &lbitset_zero_elts[2];
|
delt = &lbitset_zero_elts[2];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lbitset_zero_elts[1].next = selt;
|
lbitset_zero_elts[1].next = selt;
|
||||||
selt = &lbitset_zero_elts[1];
|
selt = &lbitset_zero_elts[1];
|
||||||
}
|
}
|
||||||
/* Since the elements are different, there is no
|
/* Since the elements are different, there is no
|
||||||
intersection of these elements. */
|
intersection of these elements. */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
for (j = 0; j < LBITSET_ELT_WORDS; j++)
|
||||||
if (selt->words[j] & delt->words[j])
|
if (selt->words[j] & delt->words[j])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1065,124 +1065,124 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
|
|||||||
while (selt1 || selt2)
|
while (selt1 || selt2)
|
||||||
{
|
{
|
||||||
/* Figure out whether we need to substitute zero elements for
|
/* Figure out whether we need to substitute zero elements for
|
||||||
missing links. */
|
missing links. */
|
||||||
if (windex1 == windex2)
|
if (windex1 == windex2)
|
||||||
{
|
{
|
||||||
windex = windex1;
|
windex = windex1;
|
||||||
stmp1 = selt1;
|
stmp1 = selt1;
|
||||||
stmp2 = selt2;
|
stmp2 = selt2;
|
||||||
selt1 = selt1->next;
|
selt1 = selt1->next;
|
||||||
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
|
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
|
||||||
selt2 = selt2->next;
|
selt2 = selt2->next;
|
||||||
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
|
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
|
||||||
}
|
}
|
||||||
else if (windex1 < windex2)
|
else if (windex1 < windex2)
|
||||||
{
|
{
|
||||||
windex = windex1;
|
windex = windex1;
|
||||||
stmp1 = selt1;
|
stmp1 = selt1;
|
||||||
stmp2 = &lbitset_zero_elts[0];
|
stmp2 = &lbitset_zero_elts[0];
|
||||||
selt1 = selt1->next;
|
selt1 = selt1->next;
|
||||||
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
|
windex1 = (selt1) ? selt1->index : BITSET_WINDEX_MAX;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
windex = windex2;
|
windex = windex2;
|
||||||
stmp1 = &lbitset_zero_elts[0];
|
stmp1 = &lbitset_zero_elts[0];
|
||||||
stmp2 = selt2;
|
stmp2 = selt2;
|
||||||
selt2 = selt2->next;
|
selt2 = selt2->next;
|
||||||
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
|
windex2 = (selt2) ? selt2->index : BITSET_WINDEX_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the appropriate element from DST. Begin by discarding
|
/* Find the appropriate element from DST. Begin by discarding
|
||||||
elements that we've skipped. */
|
elements that we've skipped. */
|
||||||
while (delt && delt->index < windex)
|
while (delt && delt->index < windex)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
dtmp = delt;
|
dtmp = delt;
|
||||||
delt = delt->next;
|
delt = delt->next;
|
||||||
lbitset_elt_free (dtmp);
|
lbitset_elt_free (dtmp);
|
||||||
}
|
}
|
||||||
if (delt && delt->index == windex)
|
if (delt && delt->index == windex)
|
||||||
{
|
{
|
||||||
dtmp = delt;
|
dtmp = delt;
|
||||||
delt = delt->next;
|
delt = delt->next;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dtmp = lbitset_elt_calloc ();
|
dtmp = lbitset_elt_calloc ();
|
||||||
|
|
||||||
/* Do the operation, and if any bits are set, link it into the
|
/* Do the operation, and if any bits are set, link it into the
|
||||||
linked list. */
|
linked list. */
|
||||||
srcp1 = stmp1->words;
|
srcp1 = stmp1->words;
|
||||||
srcp2 = stmp2->words;
|
srcp2 = stmp2->words;
|
||||||
dstp = dtmp->words;
|
dstp = dtmp->words;
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
case BITSET_OP_OR:
|
case BITSET_OP_OR:
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ | *srcp2++;
|
bitset_word tmp = *srcp1++ | *srcp2++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_AND:
|
case BITSET_OP_AND:
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ & *srcp2++;
|
bitset_word tmp = *srcp1++ & *srcp2++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_XOR:
|
case BITSET_OP_XOR:
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ ^ *srcp2++;
|
bitset_word tmp = *srcp1++ ^ *srcp2++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BITSET_OP_ANDN:
|
case BITSET_OP_ANDN:
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *srcp1++ & ~(*srcp2++);
|
bitset_word tmp = *srcp1++ & ~(*srcp2++);
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lbitset_elt_zero_p (dtmp))
|
if (!lbitset_elt_zero_p (dtmp))
|
||||||
{
|
{
|
||||||
dtmp->index = windex;
|
dtmp->index = windex;
|
||||||
/* Perhaps this could be optimised... */
|
/* Perhaps this could be optimised... */
|
||||||
lbitset_elt_link (dst, dtmp);
|
lbitset_elt_link (dst, dtmp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lbitset_elt_free (dtmp);
|
lbitset_elt_free (dtmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we have elements of DST left over, free them all. */
|
/* 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);
|
fprintf (stderr, "Elt %lu\n", (unsigned long int) elt->index);
|
||||||
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
for (i = 0; i < LBITSET_ELT_WORDS; i++)
|
||||||
{
|
{
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
bitset_word word;
|
bitset_word word;
|
||||||
|
|
||||||
word = elt->words[i];
|
word = elt->words[i];
|
||||||
|
|
||||||
fprintf (stderr, " Word %u:", i);
|
fprintf (stderr, " Word %u:", i);
|
||||||
for (j = 0; j < LBITSET_WORD_BITS; j++)
|
for (j = 0; j < LBITSET_WORD_BITS; j++)
|
||||||
if ((word & ((bitset_word) 1 << j)))
|
if ((word & ((bitset_word) 1 << j)))
|
||||||
fprintf (stderr, " %u", j);
|
fprintf (stderr, " %u", j);
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,8 +189,8 @@ static struct timevar_time_def start_time;
|
|||||||
|
|
||||||
static void get_time (struct timevar_time_def *);
|
static void get_time (struct timevar_time_def *);
|
||||||
static void timevar_accumulate (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
|
/* 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
|
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;
|
const float tiny = 5e-3;
|
||||||
|
|
||||||
/* Don't print the total execution time here; that goes at the
|
/* Don't print the total execution time here; that goes at the
|
||||||
end. */
|
end. */
|
||||||
if ((timevar_id_t) id == TV_TOTAL)
|
if ((timevar_id_t) id == TV_TOTAL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Don't print timing variables that were never used. */
|
/* Don't print timing variables that were never used. */
|
||||||
if (!tv->used)
|
if (!tv->used)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Don't print timing variables if we're going to get a row of
|
/* Don't print timing variables if we're going to get a row of
|
||||||
zeroes. */
|
zeroes. */
|
||||||
if (tv->elapsed.user < tiny
|
if (tv->elapsed.user < tiny
|
||||||
&& tv->elapsed.sys < tiny
|
&& tv->elapsed.sys < tiny
|
||||||
&& tv->elapsed.wall < tiny)
|
&& tv->elapsed.wall < tiny)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* The timing variable name. */
|
/* The timing variable name. */
|
||||||
fprintf (fp, " %-22s:", tv->name);
|
fprintf (fp, " %-22s:", tv->name);
|
||||||
@@ -500,22 +500,22 @@ timevar_print (fp)
|
|||||||
#ifdef HAVE_USER_TIME
|
#ifdef HAVE_USER_TIME
|
||||||
/* Print user-mode time for this process. */
|
/* Print user-mode time for this process. */
|
||||||
fprintf (fp, "%7.2f (%2.0f%%) usr",
|
fprintf (fp, "%7.2f (%2.0f%%) usr",
|
||||||
tv->elapsed.user,
|
tv->elapsed.user,
|
||||||
(total->user == 0 ? 0 : tv->elapsed.user / total->user) * 100);
|
(total->user == 0 ? 0 : tv->elapsed.user / total->user) * 100);
|
||||||
#endif /* HAVE_USER_TIME */
|
#endif /* HAVE_USER_TIME */
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TIME
|
#ifdef HAVE_SYS_TIME
|
||||||
/* Print system-mode time for this process. */
|
/* Print system-mode time for this process. */
|
||||||
fprintf (fp, "%7.2f (%2.0f%%) sys",
|
fprintf (fp, "%7.2f (%2.0f%%) sys",
|
||||||
tv->elapsed.sys,
|
tv->elapsed.sys,
|
||||||
(total->sys == 0 ? 0 : tv->elapsed.sys / total->sys) * 100);
|
(total->sys == 0 ? 0 : tv->elapsed.sys / total->sys) * 100);
|
||||||
#endif /* HAVE_SYS_TIME */
|
#endif /* HAVE_SYS_TIME */
|
||||||
|
|
||||||
#ifdef HAVE_WALL_TIME
|
#ifdef HAVE_WALL_TIME
|
||||||
/* Print wall clock time elapsed. */
|
/* Print wall clock time elapsed. */
|
||||||
fprintf (fp, "%7.2f (%2.0f%%) wall",
|
fprintf (fp, "%7.2f (%2.0f%%) wall",
|
||||||
tv->elapsed.wall,
|
tv->elapsed.wall,
|
||||||
(total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
|
(total->wall == 0 ? 0 : tv->elapsed.wall / total->wall) * 100);
|
||||||
#endif /* HAVE_WALL_TIME */
|
#endif /* HAVE_WALL_TIME */
|
||||||
|
|
||||||
putc ('\n', fp);
|
putc ('\n', fp);
|
||||||
@@ -534,7 +534,7 @@ timevar_print (fp)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME)
|
#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,
|
/* 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 ();
|
long all_time = get_run_time ();
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("time in %s: %ld.%06ld (%ld%%)\n"),
|
_("time in %s: %ld.%06ld (%ld%%)\n"),
|
||||||
str, total / 1000000, total % 1000000,
|
str, total / 1000000, total % 1000000,
|
||||||
all_time == 0 ? 0
|
all_time == 0 ? 0
|
||||||
: (long) (((100.0 * (double) total) / (double) all_time) + .5));
|
: (long) (((100.0 * (double) total) / (double) all_time) + .5));
|
||||||
}
|
}
|
||||||
|
|||||||
306
lib/vbitset.c
306
lib/vbitset.c
@@ -38,9 +38,9 @@ static void vbitset_set (bitset, bitset_bindex);
|
|||||||
static void vbitset_reset (bitset, bitset_bindex);
|
static void vbitset_reset (bitset, bitset_bindex);
|
||||||
static bool vbitset_test (bitset, bitset_bindex);
|
static bool vbitset_test (bitset, bitset_bindex);
|
||||||
static bitset_bindex vbitset_list (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 *,
|
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_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
|
||||||
#define VBITSET_WORDS(X) ((X)->b.cdata)
|
#define VBITSET_WORDS(X) ((X)->b.cdata)
|
||||||
@@ -69,38 +69,38 @@ vbitset_resize (bitset src, bitset_bindex n_bits)
|
|||||||
bitset_windex size;
|
bitset_windex size;
|
||||||
|
|
||||||
/* The bitset needs to grow. If we already have enough memory
|
/* 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))
|
if (newsize > VBITSET_ASIZE (src))
|
||||||
{
|
{
|
||||||
/* We need to allocate more memory. When oldsize is
|
/* We need to allocate more memory. When oldsize is
|
||||||
non-zero this means that we are changing the size, so
|
non-zero this means that we are changing the size, so
|
||||||
grow the bitset 25% larger than requested to reduce
|
grow the bitset 25% larger than requested to reduce
|
||||||
number of reallocations. */
|
number of reallocations. */
|
||||||
|
|
||||||
if (oldsize == 0)
|
if (oldsize == 0)
|
||||||
size = newsize;
|
size = newsize;
|
||||||
else
|
else
|
||||||
size = newsize + newsize / 4;
|
size = newsize + newsize / 4;
|
||||||
|
|
||||||
VBITSET_WORDS (src)
|
VBITSET_WORDS (src)
|
||||||
= realloc (VBITSET_WORDS (src), size * sizeof (bitset_word));
|
= realloc (VBITSET_WORDS (src), size * sizeof (bitset_word));
|
||||||
VBITSET_ASIZE (src) = size;
|
VBITSET_ASIZE (src) = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (VBITSET_WORDS (src) + oldsize, 0,
|
memset (VBITSET_WORDS (src) + oldsize, 0,
|
||||||
(newsize - oldsize) * sizeof (bitset_word));
|
(newsize - oldsize) * sizeof (bitset_word));
|
||||||
VBITSET_SIZE (src) = newsize;
|
VBITSET_SIZE (src) = newsize;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* The bitset needs to shrink. There's no point deallocating
|
/* 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)
|
if ((oldsize - newsize) >= oldsize / 2)
|
||||||
{
|
{
|
||||||
VBITSET_WORDS (src)
|
VBITSET_WORDS (src)
|
||||||
= realloc (VBITSET_WORDS (src), newsize * sizeof (bitset_word));
|
= realloc (VBITSET_WORDS (src), newsize * sizeof (bitset_word));
|
||||||
VBITSET_ASIZE (src) = newsize;
|
VBITSET_ASIZE (src) = newsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Need to prune any excess bits. FIXME. */
|
/* 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);
|
word = srcp[windex] << (BITSET_WORD_BITS - 1 - bitcnt);
|
||||||
for (; word; bitcnt--)
|
for (; word; bitcnt--)
|
||||||
{
|
{
|
||||||
if (word & BITSET_MSB)
|
if (word & BITSET_MSB)
|
||||||
{
|
{
|
||||||
list[count++] = bitoff + bitcnt;
|
list[count++] = bitoff + bitcnt;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = n_bits - (bitoff + bitcnt);
|
*next = n_bits - (bitoff + bitcnt);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word <<= 1;
|
word <<= 1;
|
||||||
}
|
}
|
||||||
bitoff -= BITSET_WORD_BITS;
|
bitoff -= BITSET_WORD_BITS;
|
||||||
bitcnt = BITSET_WORD_BITS - 1;
|
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. */
|
/* Many bitsets are zero, so make this common case fast. */
|
||||||
for (windex = 0; windex < size && !srcp[windex]; windex++)
|
for (windex = 0; windex < size && !srcp[windex]; windex++)
|
||||||
continue;
|
continue;
|
||||||
if (windex >= size)
|
if (windex >= size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* If num is 1, we could speed things up with a binary search
|
/* 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;
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (bitno >= BITSET_SIZE_ (src))
|
if (bitno >= BITSET_SIZE_ (src))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
windex = bitno / BITSET_WORD_BITS;
|
windex = bitno / BITSET_WORD_BITS;
|
||||||
bitno = bitno % BITSET_WORD_BITS;
|
bitno = bitno % BITSET_WORD_BITS;
|
||||||
|
|
||||||
if (bitno)
|
if (bitno)
|
||||||
{
|
{
|
||||||
/* Handle the case where we start within a word.
|
/* Handle the case where we start within a word.
|
||||||
Most often, this is executed with large bitsets
|
Most often, this is executed with large bitsets
|
||||||
with many set bits where we filled the array
|
with many set bits where we filled the array
|
||||||
on the previous call to this function. */
|
on the previous call to this function. */
|
||||||
|
|
||||||
bitoff = windex * BITSET_WORD_BITS;
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
word = srcp[windex] >> bitno;
|
word = srcp[windex] >> bitno;
|
||||||
for (bitno = bitoff + bitno; word; bitno++)
|
for (bitno = bitoff + bitno; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
windex++;
|
windex++;
|
||||||
}
|
}
|
||||||
bitoff = windex * BITSET_WORD_BITS;
|
bitoff = windex * BITSET_WORD_BITS;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
|
for (; windex < size; windex++, bitoff += BITSET_WORD_BITS)
|
||||||
{
|
{
|
||||||
if (!(word = srcp[windex]))
|
if (!(word = srcp[windex]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((count + BITSET_WORD_BITS) < num)
|
if ((count + BITSET_WORD_BITS) < num)
|
||||||
{
|
{
|
||||||
for (bitno = bitoff; word; bitno++)
|
for (bitno = bitoff; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (bitno = bitoff; word; bitno++)
|
for (bitno = bitoff; word; bitno++)
|
||||||
{
|
{
|
||||||
if (word & 1)
|
if (word & 1)
|
||||||
{
|
{
|
||||||
list[count++] = bitno;
|
list[count++] = bitno;
|
||||||
if (count >= num)
|
if (count >= num)
|
||||||
{
|
{
|
||||||
*next = bitno + 1;
|
*next = bitno + 1;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
word >>= 1;
|
word >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*next = bitoff;
|
*next = bitoff;
|
||||||
@@ -398,7 +398,7 @@ vbitset_copy1 (bitset dst, bitset src)
|
|||||||
memcpy (dstp, srcp, sizeof (bitset_word) * ssize);
|
memcpy (dstp, srcp, sizeof (bitset_word) * ssize);
|
||||||
|
|
||||||
memset (dstp + sizeof (bitset_word) * ssize, 0,
|
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);
|
vbitset_unused_clear (dst);
|
||||||
memset (dstp + sizeof (bitset_word) * ssize, 0,
|
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++)
|
for (i = 0; i < min (ssize, dsize); i++)
|
||||||
if (*srcp++ != *dstp++)
|
if (*srcp++ != *dstp++)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ssize > dsize)
|
if (ssize > dsize)
|
||||||
{
|
{
|
||||||
for (; i < ssize; i++)
|
for (; i < ssize; i++)
|
||||||
if (*srcp++)
|
if (*srcp++)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (; i < dsize; i++)
|
for (; i < dsize; i++)
|
||||||
if (*dstp++)
|
if (*dstp++)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -468,13 +468,13 @@ vbitset_subset_p (bitset dst, bitset src)
|
|||||||
|
|
||||||
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
|
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
|
||||||
if (*dstp != (*srcp | *dstp))
|
if (*dstp != (*srcp | *dstp))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (ssize > dsize)
|
if (ssize > dsize)
|
||||||
{
|
{
|
||||||
for (; i < ssize; i++)
|
for (; i < ssize; i++)
|
||||||
if (*srcp++)
|
if (*srcp++)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -492,7 +492,7 @@ vbitset_disjoint_p (bitset dst, bitset src)
|
|||||||
|
|
||||||
for (i = 0; i < min (ssize, dsize); i++)
|
for (i = 0; i < min (ssize, dsize); i++)
|
||||||
if (*srcp++ & *dstp++)
|
if (*srcp++ & *dstp++)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -551,10 +551,10 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++ & *src2p++;
|
bitset_word tmp = *src1p++ & *src2p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssize2 > ssize1)
|
if (ssize2 > ssize1)
|
||||||
@@ -566,10 +566,10 @@ vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
for (; i < ssize1; i++, dstp++)
|
for (; i < ssize1; i++, dstp++)
|
||||||
{
|
{
|
||||||
if (*dstp != 0)
|
if (*dstp != 0)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = 0;
|
*dstp = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
||||||
@@ -604,14 +604,14 @@ vbitset_andn (bitset dst, bitset src1, bitset src2)
|
|||||||
if (ssize2 > ssize1)
|
if (ssize2 > ssize1)
|
||||||
{
|
{
|
||||||
for (; i < ssize2; i++)
|
for (; i < ssize2; i++)
|
||||||
*dstp++ = 0;
|
*dstp++ = 0;
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
|
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (; i < ssize1; i++)
|
for (; i < ssize1; i++)
|
||||||
*dstp++ = *src1p++;
|
*dstp++ = *src1p++;
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
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++);
|
bitset_word tmp = *src1p++ & ~(*src2p++);
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssize2 > ssize1)
|
if (ssize2 > ssize1)
|
||||||
{
|
{
|
||||||
for (; i < ssize2; i++, dstp++)
|
for (; i < ssize2; i++, dstp++)
|
||||||
{
|
{
|
||||||
if (*dstp != 0)
|
if (*dstp != 0)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = 0;
|
*dstp = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
|
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (; i < ssize1; i++, dstp++)
|
for (; i < ssize1; i++, dstp++)
|
||||||
{
|
{
|
||||||
bitset_word tmp = *src1p++;
|
bitset_word tmp = *src1p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
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++;
|
bitset_word tmp = *src1p++ | *src2p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssize2 > ssize1)
|
if (ssize2 > ssize1)
|
||||||
@@ -762,10 +762,10 @@ vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++;
|
bitset_word tmp = *src1p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
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++;
|
bitset_word tmp = *src1p++ ^ *src2p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssize2 > ssize1)
|
if (ssize2 > ssize1)
|
||||||
@@ -853,10 +853,10 @@ vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
|
|||||||
bitset_word tmp = *src1p++;
|
bitset_word tmp = *src1p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (dstp, 0, sizeof (bitset_word) * (dsize - ssize1));
|
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++;
|
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -993,10 +993,10 @@ vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -1060,10 +1060,10 @@ vbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
|
|||||||
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
|
||||||
|
|
||||||
if (*dstp != tmp)
|
if (*dstp != tmp)
|
||||||
{
|
{
|
||||||
changed = 1;
|
changed = 1;
|
||||||
*dstp = tmp;
|
*dstp = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_C_COMPILER], [
|
|||||||
AC_COMPILE_IFELSE(
|
AC_COMPILE_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[[#include <limits.h>
|
[[#include <limits.h>
|
||||||
int test_array[CHAR_BIT];]])],
|
int test_array[CHAR_BIT];]])],
|
||||||
[],
|
[],
|
||||||
[AC_MSG_FAILURE([cannot compile a simple C program])])
|
[AC_MSG_FAILURE([cannot compile a simple C program])])
|
||||||
])
|
])
|
||||||
|
|||||||
32
m4/cxx.m4
32
m4/cxx.m4
@@ -26,25 +26,25 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_CXX_COMPILER],
|
|||||||
bison_cv_cxx_works=no
|
bison_cv_cxx_works=no
|
||||||
AC_COMPILE_IFELSE(
|
AC_COMPILE_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[#include <cstdlib>
|
[#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;],
|
using namespace std;],
|
||||||
[std::cerr << "";
|
[std::cerr << "";
|
||||||
cout << "";
|
cout << "";
|
||||||
typedef std::pair<unsigned int, int> uipair;
|
typedef std::pair<unsigned int, int> uipair;
|
||||||
std::map<unsigned int, int> m;
|
std::map<unsigned int, int> m;
|
||||||
std::map<unsigned int, int>::iterator i;
|
std::map<unsigned int, int>::iterator i;
|
||||||
m.insert (uipair (4, -4));
|
m.insert (uipair (4, -4));
|
||||||
for (i = m.begin (); i != m.end (); ++i)
|
for (i = m.begin (); i != m.end (); ++i)
|
||||||
if (i->first != 4)
|
if (i->first != 4)
|
||||||
return 1;])],
|
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([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],
|
[AS_IF([test "$cross_compiling" = yes],
|
||||||
[bison_cv_cxx_works=cross],
|
[bison_cv_cxx_works=cross],
|
||||||
[AS_IF([AC_TRY_COMMAND(./conftest$ac_exeext)],
|
[AS_IF([AC_TRY_COMMAND(./conftest$ac_exeext)],
|
||||||
[bison_cv_cxx_works=yes])])])
|
[bison_cv_cxx_works=yes])])])
|
||||||
rm -f conftest$ac_exeext])
|
rm -f conftest$ac_exeext])
|
||||||
AC_LANG_POP([C++])])
|
AC_LANG_POP([C++])])
|
||||||
|
|
||||||
|
|||||||
68
src/LR0.c
68
src/LR0.c
@@ -62,7 +62,7 @@ state_list_append (symbol_number sym, size_t core_size, item_number *core)
|
|||||||
|
|
||||||
if (trace_flag & trace_automaton)
|
if (trace_flag & trace_automaton)
|
||||||
fprintf (stderr, "state_list_append (state = %d, symbol = %d (%s))\n",
|
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->next = NULL;
|
||||||
node->state = s;
|
node->state = s;
|
||||||
@@ -100,13 +100,13 @@ allocate_itemsets (void)
|
|||||||
symbols. */
|
symbols. */
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
size_t *symbol_count = xcalloc (nsyms + nuseless_nonterminals,
|
size_t *symbol_count = xcalloc (nsyms + nuseless_nonterminals,
|
||||||
sizeof *symbol_count);
|
sizeof *symbol_count);
|
||||||
|
|
||||||
for (r = 0; r < nrules; ++r)
|
for (r = 0; r < nrules; ++r)
|
||||||
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
symbol_count[*rhsp]++;
|
symbol_count[*rhsp]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See comments before new_itemsets. All the vectors of items
|
/* See comments before new_itemsets. All the vectors of items
|
||||||
@@ -187,15 +187,15 @@ new_itemsets (state *s)
|
|||||||
for (i = 0; i < nitemset; ++i)
|
for (i = 0; i < nitemset; ++i)
|
||||||
if (item_number_is_symbol_number (ritem[itemset[i]]))
|
if (item_number_is_symbol_number (ritem[itemset[i]]))
|
||||||
{
|
{
|
||||||
symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
|
symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
|
||||||
if (!kernel_size[sym])
|
if (!kernel_size[sym])
|
||||||
{
|
{
|
||||||
shift_symbol[nshifts] = sym;
|
shift_symbol[nshifts] = sym;
|
||||||
nshifts++;
|
nshifts++;
|
||||||
}
|
}
|
||||||
|
|
||||||
kernel_base[sym][kernel_size[sym]] = itemset[i] + 1;
|
kernel_base[sym][kernel_size[sym]] = itemset[i] + 1;
|
||||||
kernel_size[sym]++;
|
kernel_size[sym]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ get_state (symbol_number sym, size_t core_size, item_number *core)
|
|||||||
|
|
||||||
if (trace_flag & trace_automaton)
|
if (trace_flag & trace_automaton)
|
||||||
fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
|
fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
|
||||||
sym, symbols[sym]->tag);
|
sym, symbols[sym]->tag);
|
||||||
|
|
||||||
s = state_hash_lookup (core_size, core);
|
s = state_hash_lookup (core_size, core);
|
||||||
if (!s)
|
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 |
|
| 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. |
|
| SHIFTSET is set up as a vector of those states. |
|
||||||
`---------------------------------------------------------------*/
|
`---------------------------------------------------------------*/
|
||||||
@@ -248,7 +248,7 @@ append_states (state *s)
|
|||||||
symbol_number sym = shift_symbol[i];
|
symbol_number sym = shift_symbol[i];
|
||||||
int j;
|
int j;
|
||||||
for (j = i; 0 < j && sym < shift_symbol[j - 1]; 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;
|
shift_symbol[j] = sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,16 +277,16 @@ save_reductions (state *s)
|
|||||||
{
|
{
|
||||||
item_number item = ritem[itemset[i]];
|
item_number item = ritem[itemset[i]];
|
||||||
if (item_number_is_rule_number (item))
|
if (item_number_is_rule_number (item))
|
||||||
{
|
{
|
||||||
rule_number r = item_number_as_rule_number (item);
|
rule_number r = item_number_as_rule_number (item);
|
||||||
redset[count++] = &rules[r];
|
redset[count++] = &rules[r];
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
{
|
{
|
||||||
/* This is "reduce 0", i.e., accept. */
|
/* This is "reduce 0", i.e., accept. */
|
||||||
aver (!final_state);
|
aver (!final_state);
|
||||||
final_state = s;
|
final_state = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make a reductions structure and copy the data into it. */
|
/* Make a reductions structure and copy the data into it. */
|
||||||
@@ -308,14 +308,14 @@ set_states (void)
|
|||||||
state_list *this = first_state;
|
state_list *this = first_state;
|
||||||
|
|
||||||
/* Pessimization, but simplification of the code: make sure all
|
/* Pessimization, but simplification of the code: make sure all
|
||||||
the states have valid transitions and reductions members,
|
the states have valid transitions and reductions members,
|
||||||
even if reduced to 0. It is too soon for errs, which are
|
even if reduced to 0. It is too soon for errs, which are
|
||||||
computed later, but set_conflicts. */
|
computed later, but set_conflicts. */
|
||||||
state *s = this->state;
|
state *s = this->state;
|
||||||
if (!s->transitions)
|
if (!s->transitions)
|
||||||
state_transitions_set (s, 0, 0);
|
state_transitions_set (s, 0, 0);
|
||||||
if (!s->reductions)
|
if (!s->reductions)
|
||||||
state_reductions_set (s, 0, 0);
|
state_reductions_set (s, 0, 0);
|
||||||
|
|
||||||
states[s->number] = s;
|
states[s->number] = s;
|
||||||
|
|
||||||
@@ -349,9 +349,9 @@ generate_states (void)
|
|||||||
{
|
{
|
||||||
state *s = list->state;
|
state *s = list->state;
|
||||||
if (trace_flag & trace_automaton)
|
if (trace_flag & trace_automaton)
|
||||||
fprintf (stderr, "Processing state %d (reached by %s)\n",
|
fprintf (stderr, "Processing state %d (reached by %s)\n",
|
||||||
s->number,
|
s->number,
|
||||||
symbols[s->accessing_symbol]->tag);
|
symbols[s->accessing_symbol]->tag);
|
||||||
/* Set up itemset for the transitions out of this state. itemset gets a
|
/* Set up itemset for the transitions out of this state. itemset gets a
|
||||||
vector of all the items that could be accepted next. */
|
vector of all the items that could be accepted next. */
|
||||||
closure (s->items, s->nitems);
|
closure (s->items, s->nitems);
|
||||||
@@ -363,7 +363,7 @@ generate_states (void)
|
|||||||
append_states (s);
|
append_states (s);
|
||||||
|
|
||||||
/* Create the shifts structures for the shifts to those states,
|
/* 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);
|
state_transitions_set (s, nshifts, shiftset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ print_closure (char const *title, item_number *array, size_t size)
|
|||||||
item_number *rp;
|
item_number *rp;
|
||||||
fprintf (stderr, " %2d: .", array[i]);
|
fprintf (stderr, " %2d: .", array[i]);
|
||||||
for (rp = &ritem[array[i]]; *rp >= 0; ++rp)
|
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);
|
fprintf (stderr, " (rule %d)\n", -*rp - 1);
|
||||||
}
|
}
|
||||||
fputs ("\n\n", stderr);
|
fputs ("\n\n", stderr);
|
||||||
@@ -80,10 +80,10 @@ print_firsts (void)
|
|||||||
bitset_iterator iter;
|
bitset_iterator iter;
|
||||||
fprintf (stderr, "\t%s firsts\n", symbols[i]->tag);
|
fprintf (stderr, "\t%s firsts\n", symbols[i]->tag);
|
||||||
BITSET_FOR_EACH (iter, FIRSTS (i), j, 0)
|
BITSET_FOR_EACH (iter, FIRSTS (i), j, 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\t\t%s\n",
|
fprintf (stderr, "\t\t%s\n",
|
||||||
symbols[j + ntokens]->tag);
|
symbols[j + ntokens]->tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (stderr, "\n\n");
|
fprintf (stderr, "\n\n");
|
||||||
}
|
}
|
||||||
@@ -101,10 +101,10 @@ print_fderives (void)
|
|||||||
bitset_iterator iter;
|
bitset_iterator iter;
|
||||||
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
|
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
|
||||||
BITSET_FOR_EACH (iter, FDERIVES (i), r, 0)
|
BITSET_FOR_EACH (iter, FDERIVES (i), r, 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\t\t%3d ", r);
|
fprintf (stderr, "\t\t%3d ", r);
|
||||||
rule_rhs_print (&rules[r], stderr);
|
rule_rhs_print (&rules[r], stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (stderr, "\n\n");
|
fprintf (stderr, "\n\n");
|
||||||
}
|
}
|
||||||
@@ -130,9 +130,9 @@ set_firsts (void)
|
|||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
for (j = 0; derives[i - ntokens][j]; ++j)
|
for (j = 0; derives[i - ntokens][j]; ++j)
|
||||||
{
|
{
|
||||||
item_number sym = derives[i - ntokens][j]->rhs[0];
|
item_number sym = derives[i - ntokens][j]->rhs[0];
|
||||||
if (ISVAR (sym))
|
if (ISVAR (sym))
|
||||||
bitset_set (FIRSTS (i), sym - ntokens);
|
bitset_set (FIRSTS (i), sym - ntokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trace_flag & trace_sets)
|
if (trace_flag & trace_sets)
|
||||||
@@ -168,8 +168,8 @@ set_fderives (void)
|
|||||||
for (i = ntokens; i < nsyms; ++i)
|
for (i = ntokens; i < nsyms; ++i)
|
||||||
for (j = ntokens; j < nsyms; ++j)
|
for (j = ntokens; j < nsyms; ++j)
|
||||||
if (bitset_test (FIRSTS (i), j - ntokens))
|
if (bitset_test (FIRSTS (i), j - ntokens))
|
||||||
for (k = 0; derives[j - ntokens][k]; ++k)
|
for (k = 0; derives[j - ntokens][k]; ++k)
|
||||||
bitset_set (FDERIVES (i), derives[j - ntokens][k]->number);
|
bitset_set (FDERIVES (i), derives[j - ntokens][k]->number);
|
||||||
|
|
||||||
if (trace_flag & trace_sets)
|
if (trace_flag & trace_sets)
|
||||||
print_fderives ();
|
print_fderives ();
|
||||||
@@ -219,11 +219,11 @@ closure (item_number *core, size_t n)
|
|||||||
{
|
{
|
||||||
item_number itemno = rules[ruleno].rhs - ritem;
|
item_number itemno = rules[ruleno].rhs - ritem;
|
||||||
while (c < n && core[c] < itemno)
|
while (c < n && core[c] < itemno)
|
||||||
{
|
{
|
||||||
itemset[nitemset] = core[c];
|
itemset[nitemset] = core[c];
|
||||||
nitemset++;
|
nitemset++;
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
itemset[nitemset] = itemno;
|
itemset[nitemset] = itemno;
|
||||||
nitemset++;
|
nitemset++;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ static unsigned *indent_ptr = 0;
|
|||||||
static
|
static
|
||||||
void
|
void
|
||||||
error_message (location *loc,
|
error_message (location *loc,
|
||||||
const char *prefix,
|
const char *prefix,
|
||||||
const char *message, va_list args)
|
const char *message, va_list args)
|
||||||
{
|
{
|
||||||
unsigned pos = 0;
|
unsigned pos = 0;
|
||||||
|
|
||||||
@@ -81,12 +81,12 @@ error_message (location *loc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Wrap error_message() with varargs handling. */
|
/** Wrap error_message() with varargs handling. */
|
||||||
#define ERROR_MESSAGE(Loc, Prefix, Message) \
|
#define ERROR_MESSAGE(Loc, Prefix, Message) \
|
||||||
{ \
|
{ \
|
||||||
va_list args; \
|
va_list args; \
|
||||||
va_start (args, Message); \
|
va_start (args, Message); \
|
||||||
error_message (Loc, Prefix, Message, args); \
|
error_message (Loc, Prefix, Message, args); \
|
||||||
va_end (args); \
|
va_end (args); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
# include "location.h"
|
# include "location.h"
|
||||||
|
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ void fatal_at (location loc, char const *format, ...)
|
|||||||
/** Whether an error was reported. */
|
/** Whether an error was reported. */
|
||||||
extern bool complaint_issued;
|
extern bool complaint_issued;
|
||||||
|
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|||||||
242
src/conflicts.c
242
src/conflicts.c
@@ -64,75 +64,75 @@ enum conflict_resolution
|
|||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
log_resolution (rule *r, symbol_number token,
|
log_resolution (rule *r, symbol_number token,
|
||||||
enum conflict_resolution resolution)
|
enum conflict_resolution resolution)
|
||||||
{
|
{
|
||||||
if (report_flag & report_solved_conflicts)
|
if (report_flag & report_solved_conflicts)
|
||||||
{
|
{
|
||||||
/* The description of the resolution. */
|
/* The description of the resolution. */
|
||||||
switch (resolution)
|
switch (resolution)
|
||||||
{
|
{
|
||||||
case shift_resolution:
|
case shift_resolution:
|
||||||
case right_resolution:
|
case right_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||||
_(" Conflict between rule %d and token %s"
|
_(" Conflict between rule %d and token %s"
|
||||||
" resolved as shift"),
|
" resolved as shift"),
|
||||||
r->number,
|
r->number,
|
||||||
symbols[token]->tag);
|
symbols[token]->tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case reduce_resolution:
|
case reduce_resolution:
|
||||||
case left_resolution:
|
case left_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||||
_(" Conflict between rule %d and token %s"
|
_(" Conflict between rule %d and token %s"
|
||||||
" resolved as reduce"),
|
" resolved as reduce"),
|
||||||
r->number,
|
r->number,
|
||||||
symbols[token]->tag);
|
symbols[token]->tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nonassoc_resolution:
|
case nonassoc_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||||
_(" Conflict between rule %d and token %s"
|
_(" Conflict between rule %d and token %s"
|
||||||
" resolved as an error"),
|
" resolved as an error"),
|
||||||
r->number,
|
r->number,
|
||||||
symbols[token]->tag);
|
symbols[token]->tag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The reason. */
|
/* The reason. */
|
||||||
switch (resolution)
|
switch (resolution)
|
||||||
{
|
{
|
||||||
case shift_resolution:
|
case shift_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||||
" (%s < %s)",
|
" (%s < %s)",
|
||||||
r->prec->tag,
|
r->prec->tag,
|
||||||
symbols[token]->tag);
|
symbols[token]->tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case reduce_resolution:
|
case reduce_resolution:
|
||||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||||
" (%s < %s)",
|
" (%s < %s)",
|
||||||
symbols[token]->tag,
|
symbols[token]->tag,
|
||||||
r->prec->tag);
|
r->prec->tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case left_resolution:
|
case left_resolution:
|
||||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
obstack_fgrow1 (&solved_conflicts_obstack,
|
||||||
" (%%left %s)",
|
" (%%left %s)",
|
||||||
symbols[token]->tag);
|
symbols[token]->tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case right_resolution:
|
case right_resolution:
|
||||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
obstack_fgrow1 (&solved_conflicts_obstack,
|
||||||
" (%%right %s)",
|
" (%%right %s)",
|
||||||
symbols[token]->tag);
|
symbols[token]->tag);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nonassoc_resolution:
|
case nonassoc_resolution:
|
||||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
obstack_fgrow1 (&solved_conflicts_obstack,
|
||||||
" (%%nonassoc %s)",
|
" (%%nonassoc %s)",
|
||||||
symbols[token]->tag);
|
symbols[token]->tag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
obstack_sgrow (&solved_conflicts_obstack, ".\n");
|
obstack_sgrow (&solved_conflicts_obstack, ".\n");
|
||||||
}
|
}
|
||||||
@@ -226,7 +226,7 @@ flush_shift (state *s, int token)
|
|||||||
bitset_reset (lookahead_set, token);
|
bitset_reset (lookahead_set, token);
|
||||||
for (i = 0; i < trans->num; i++)
|
for (i = 0; i < trans->num; i++)
|
||||||
if (!TRANSITION_IS_DISABLED (trans, i)
|
if (!TRANSITION_IS_DISABLED (trans, i)
|
||||||
&& TRANSITION_SYMBOL (trans, i) == token)
|
&& TRANSITION_SYMBOL (trans, i) == token)
|
||||||
TRANSITION_DISABLE (trans, i);
|
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++)
|
for (i = 0; i < ntokens; i++)
|
||||||
if (bitset_test (lookahead_tokens, i)
|
if (bitset_test (lookahead_tokens, i)
|
||||||
&& bitset_test (lookahead_set, i)
|
&& bitset_test (lookahead_set, i)
|
||||||
&& symbols[i]->prec)
|
&& symbols[i]->prec)
|
||||||
{
|
{
|
||||||
/* Shift-reduce conflict occurs for token number i
|
/* Shift-reduce conflict occurs for token number i
|
||||||
and it has a precedence.
|
and it has a precedence.
|
||||||
The precedence of shifting is that of token i. */
|
The precedence of shifting is that of token i. */
|
||||||
if (symbols[i]->prec < redprec)
|
if (symbols[i]->prec < redprec)
|
||||||
{
|
{
|
||||||
log_resolution (redrule, i, reduce_resolution);
|
log_resolution (redrule, i, reduce_resolution);
|
||||||
flush_shift (s, i);
|
flush_shift (s, i);
|
||||||
}
|
}
|
||||||
else if (symbols[i]->prec > redprec)
|
else if (symbols[i]->prec > redprec)
|
||||||
{
|
{
|
||||||
log_resolution (redrule, i, shift_resolution);
|
log_resolution (redrule, i, shift_resolution);
|
||||||
flush_reduce (lookahead_tokens, i);
|
flush_reduce (lookahead_tokens, i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* Matching precedence levels.
|
/* Matching precedence levels.
|
||||||
For non-defined associativity, keep both: unexpected
|
For non-defined associativity, keep both: unexpected
|
||||||
associativity conflict.
|
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 right associativity, keep only the shift.
|
||||||
For nonassociativity, keep neither. */
|
For nonassociativity, keep neither. */
|
||||||
|
|
||||||
switch (symbols[i]->assoc)
|
switch (symbols[i]->assoc)
|
||||||
{
|
{
|
||||||
case undef_assoc:
|
case undef_assoc:
|
||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
case precedence_assoc:
|
case precedence_assoc:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case right_assoc:
|
case right_assoc:
|
||||||
log_resolution (redrule, i, right_resolution);
|
log_resolution (redrule, i, right_resolution);
|
||||||
flush_reduce (lookahead_tokens, i);
|
flush_reduce (lookahead_tokens, i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case left_assoc:
|
case left_assoc:
|
||||||
log_resolution (redrule, i, left_resolution);
|
log_resolution (redrule, i, left_resolution);
|
||||||
flush_shift (s, i);
|
flush_shift (s, i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case non_assoc:
|
case non_assoc:
|
||||||
log_resolution (redrule, i, nonassoc_resolution);
|
log_resolution (redrule, i, nonassoc_resolution);
|
||||||
flush_shift (s, i);
|
flush_shift (s, i);
|
||||||
flush_reduce (lookahead_tokens, i);
|
flush_reduce (lookahead_tokens, i);
|
||||||
/* Record an explicit error for this token. */
|
/* Record an explicit error for this token. */
|
||||||
errors[(*nerrs)++] = symbols[i];
|
errors[(*nerrs)++] = symbols[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ set_conflicts (state *s, symbol **errors)
|
|||||||
precedence. */
|
precedence. */
|
||||||
for (i = 0; i < reds->num; ++i)
|
for (i = 0; i < reds->num; ++i)
|
||||||
if (reds->rules[i]->prec && reds->rules[i]->prec->prec
|
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);
|
resolve_sr_conflict (s, i, errors, &nerrs);
|
||||||
|
|
||||||
if (nerrs)
|
if (nerrs)
|
||||||
@@ -375,7 +375,7 @@ set_conflicts (state *s, symbol **errors)
|
|||||||
for (i = 0; i < reds->num; ++i)
|
for (i = 0; i < reds->num; ++i)
|
||||||
{
|
{
|
||||||
if (!bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set))
|
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]);
|
bitset_or (lookahead_set, lookahead_set, reds->lookahead_tokens[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -404,9 +404,9 @@ conflicts_solve (void)
|
|||||||
set_conflicts (states[i], errors);
|
set_conflicts (states[i], errors);
|
||||||
|
|
||||||
/* For uniformity of the code, make sure all the states have a valid
|
/* For uniformity of the code, make sure all the states have a valid
|
||||||
`errs' member. */
|
`errs' member. */
|
||||||
if (!states[i]->errs)
|
if (!states[i]->errs)
|
||||||
states[i]->errs = errs_new (0, 0);
|
states[i]->errs = errs_new (0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
free (errors);
|
free (errors);
|
||||||
@@ -475,11 +475,11 @@ count_rr_conflicts (state *s, bool one_per_token)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < reds->num; ++j)
|
for (j = 0; j < reds->num; ++j)
|
||||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (count >= 2)
|
if (count >= 2)
|
||||||
rrc_count += one_per_token ? 1 : count-1;
|
rrc_count += one_per_token ? 1 : count-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rrc_count;
|
return rrc_count;
|
||||||
@@ -495,7 +495,7 @@ conflict_report (FILE *out, int src_num, int rrc_num)
|
|||||||
{
|
{
|
||||||
if (src_num && rrc_num)
|
if (src_num && rrc_num)
|
||||||
fprintf (out, _("conflicts: %d shift/reduce, %d reduce/reduce\n"),
|
fprintf (out, _("conflicts: %d shift/reduce, %d reduce/reduce\n"),
|
||||||
src_num, rrc_num);
|
src_num, rrc_num);
|
||||||
else if (src_num)
|
else if (src_num)
|
||||||
fprintf (out, _("conflicts: %d shift/reduce\n"), src_num);
|
fprintf (out, _("conflicts: %d shift/reduce\n"), src_num);
|
||||||
else if (rrc_num)
|
else if (rrc_num)
|
||||||
@@ -516,12 +516,12 @@ conflicts_output (FILE *out)
|
|||||||
{
|
{
|
||||||
state *s = states[i];
|
state *s = states[i];
|
||||||
if (conflicts[i])
|
if (conflicts[i])
|
||||||
{
|
{
|
||||||
fprintf (out, _("State %d "), i);
|
fprintf (out, _("State %d "), i);
|
||||||
conflict_report (out, count_sr_conflicts (s),
|
conflict_report (out, count_sr_conflicts (s),
|
||||||
count_rr_conflicts (s, true));
|
count_rr_conflicts (s, true));
|
||||||
printed_sth = true;
|
printed_sth = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (printed_sth)
|
if (printed_sth)
|
||||||
fputs ("\n\n", out);
|
fputs ("\n\n", out);
|
||||||
@@ -531,7 +531,7 @@ conflicts_output (FILE *out)
|
|||||||
| Total the number of S/R and R/R conflicts. Unlike the |
|
| Total the number of S/R and R/R conflicts. Unlike the |
|
||||||
| code in conflicts_output, however, count EACH pair of |
|
| code in conflicts_output, however, count EACH pair of |
|
||||||
| reductions for the same state and lookahead as one |
|
| reductions for the same state and lookahead as one |
|
||||||
| conflict. |
|
| conflict. |
|
||||||
`--------------------------------------------------------*/
|
`--------------------------------------------------------*/
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -545,8 +545,8 @@ conflicts_total_count (void)
|
|||||||
for (i = 0; i < nstates; i++)
|
for (i = 0; i < nstates; i++)
|
||||||
if (conflicts[i])
|
if (conflicts[i])
|
||||||
{
|
{
|
||||||
count += count_sr_conflicts (states[i]);
|
count += count_sr_conflicts (states[i]);
|
||||||
count += count_rr_conflicts (states[i], false);
|
count += count_rr_conflicts (states[i], false);
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -576,10 +576,10 @@ conflicts_print (void)
|
|||||||
|
|
||||||
for (i = 0; i < nstates; i++)
|
for (i = 0; i < nstates; i++)
|
||||||
if (conflicts[i])
|
if (conflicts[i])
|
||||||
{
|
{
|
||||||
src_total += count_sr_conflicts (states[i]);
|
src_total += count_sr_conflicts (states[i]);
|
||||||
rrc_total += count_rr_conflicts (states[i], true);
|
rrc_total += count_rr_conflicts (states[i], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! glr_parser && rrc_total > 0 && expected_rr_conflicts != -1)
|
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)
|
if (expected_sr_conflicts == -1 && expected_rr_conflicts == -1)
|
||||||
set_warning_issued ();
|
set_warning_issued ();
|
||||||
if (! yacc_flag)
|
if (! yacc_flag)
|
||||||
fprintf (stderr, "%s: ", current_file);
|
fprintf (stderr, "%s: ", current_file);
|
||||||
conflict_report (stderr, src_total, rrc_total);
|
conflict_report (stderr, src_total, rrc_total);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expected_sr_conflicts != -1 || expected_rr_conflicts != -1)
|
if (expected_sr_conflicts != -1 || expected_rr_conflicts != -1)
|
||||||
{
|
{
|
||||||
if (! src_ok)
|
if (! src_ok)
|
||||||
complain (ngettext ("expected %d shift/reduce conflict",
|
complain (ngettext ("expected %d shift/reduce conflict",
|
||||||
"expected %d shift/reduce conflicts",
|
"expected %d shift/reduce conflicts",
|
||||||
src_expected),
|
src_expected),
|
||||||
src_expected);
|
src_expected);
|
||||||
if (! rrc_ok)
|
if (! rrc_ok)
|
||||||
complain (ngettext ("expected %d reduce/reduce conflict",
|
complain (ngettext ("expected %d reduce/reduce conflict",
|
||||||
"expected %d reduce/reduce conflicts",
|
"expected %d reduce/reduce conflicts",
|
||||||
rrc_expected),
|
rrc_expected),
|
||||||
rrc_expected);
|
rrc_expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ print_derives (void)
|
|||||||
rule **rp;
|
rule **rp;
|
||||||
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
|
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
|
||||||
for (rp = derives[i - ntokens]; *rp; ++rp)
|
for (rp = derives[i - ntokens]; *rp; ++rp)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\t\t%3d ", (*rp)->user_number);
|
fprintf (stderr, "\t\t%3d ", (*rp)->user_number);
|
||||||
rule_rhs_print (*rp, stderr);
|
rule_rhs_print (*rp, stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fputs ("\n\n", stderr);
|
fputs ("\n\n", stderr);
|
||||||
@@ -96,10 +96,10 @@ derives_compute (void)
|
|||||||
rule_list *p = dset[i - ntokens];
|
rule_list *p = dset[i - ntokens];
|
||||||
derives[i - ntokens] = q;
|
derives[i - ntokens] = q;
|
||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
*q++ = p->value;
|
*q++ = p->value;
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
*q++ = NULL;
|
*q++ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
62
src/files.c
62
src/files.c
@@ -200,7 +200,7 @@ compute_exts_from_src (const char *ext)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
file_name_split (const char *file_name,
|
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);
|
*base = last_component (file_name);
|
||||||
|
|
||||||
@@ -215,9 +215,9 @@ file_name_split (const char *file_name,
|
|||||||
size_t baselen = *ext - *base;
|
size_t baselen = *ext - *base;
|
||||||
size_t dottablen = 4;
|
size_t dottablen = 4;
|
||||||
if (dottablen < baselen
|
if (dottablen < baselen
|
||||||
&& (strncmp (*ext - dottablen, ".tab", dottablen) == 0
|
&& (strncmp (*ext - dottablen, ".tab", dottablen) == 0
|
||||||
|| strncmp (*ext - dottablen, "_tab", dottablen) == 0))
|
|| strncmp (*ext - dottablen, "_tab", dottablen) == 0))
|
||||||
*tab = *ext - dottablen;
|
*tab = *ext - dottablen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,44 +239,44 @@ compute_file_name_parts (void)
|
|||||||
|
|
||||||
/* ALL_BUT_EXT goes up the EXT, excluding it. */
|
/* ALL_BUT_EXT goes up the EXT, excluding it. */
|
||||||
all_but_ext =
|
all_but_ext =
|
||||||
xstrndup (spec_outfile,
|
xstrndup (spec_outfile,
|
||||||
(strlen (spec_outfile) - (ext ? strlen (ext) : 0)));
|
(strlen (spec_outfile) - (ext ? strlen (ext) : 0)));
|
||||||
|
|
||||||
/* ALL_BUT_TAB_EXT goes up to TAB, excluding it. */
|
/* ALL_BUT_TAB_EXT goes up to TAB, excluding it. */
|
||||||
all_but_tab_ext =
|
all_but_tab_ext =
|
||||||
xstrndup (spec_outfile,
|
xstrndup (spec_outfile,
|
||||||
(strlen (spec_outfile)
|
(strlen (spec_outfile)
|
||||||
- (tab ? strlen (tab) : (ext ? strlen (ext) : 0))));
|
- (tab ? strlen (tab) : (ext ? strlen (ext) : 0))));
|
||||||
|
|
||||||
if (ext)
|
if (ext)
|
||||||
compute_exts_from_src (ext);
|
compute_exts_from_src (ext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file_name_split (grammar_file, &base, &tab, &ext);
|
file_name_split (grammar_file, &base, &tab, &ext);
|
||||||
|
|
||||||
if (spec_file_prefix)
|
if (spec_file_prefix)
|
||||||
{
|
{
|
||||||
/* If --file-prefix=foo was specified, ALL_BUT_TAB_EXT = `foo'. */
|
/* If --file-prefix=foo was specified, ALL_BUT_TAB_EXT = `foo'. */
|
||||||
dir_prefix =
|
dir_prefix =
|
||||||
xstrndup (spec_file_prefix,
|
xstrndup (spec_file_prefix,
|
||||||
last_component (spec_file_prefix) - 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)
|
else if (yacc_flag)
|
||||||
{
|
{
|
||||||
/* If --yacc, then the output is `y.tab.c'. */
|
/* If --yacc, then the output is `y.tab.c'. */
|
||||||
dir_prefix = xstrdup ("");
|
dir_prefix = xstrdup ("");
|
||||||
all_but_tab_ext = xstrdup ("y");
|
all_but_tab_ext = xstrdup ("y");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Otherwise, ALL_BUT_TAB_EXT is computed from the input
|
/* Otherwise, ALL_BUT_TAB_EXT is computed from the input
|
||||||
grammar: `foo/bar.yy' => `bar'. */
|
grammar: `foo/bar.yy' => `bar'. */
|
||||||
dir_prefix = xstrdup ("");
|
dir_prefix = xstrdup ("");
|
||||||
all_but_tab_ext =
|
all_but_tab_ext =
|
||||||
xstrndup (base, (strlen (base) - (ext ? strlen (ext) : 0)));
|
xstrndup (base, (strlen (base) - (ext ? strlen (ext) : 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (language->add_tab)
|
if (language->add_tab)
|
||||||
all_but_ext = concat2 (all_but_tab_ext, TAB_EXT);
|
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. */
|
/* Compute the extensions from the grammar file name. */
|
||||||
if (ext && !yacc_flag)
|
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 (defines_flag)
|
||||||
{
|
{
|
||||||
if (! spec_defines_file)
|
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 (graph_flag)
|
||||||
{
|
{
|
||||||
if (! spec_graph_file)
|
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);
|
output_file_name_check (&spec_graph_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xml_flag)
|
if (xml_flag)
|
||||||
{
|
{
|
||||||
if (! spec_xml_file)
|
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);
|
output_file_name_check (&spec_xml_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,10 +76,10 @@ static struct obstack obstack_for_string;
|
|||||||
#define STRING_GROW \
|
#define STRING_GROW \
|
||||||
obstack_grow (&obstack_for_string, yytext, yyleng)
|
obstack_grow (&obstack_for_string, yytext, yyleng)
|
||||||
|
|
||||||
#define STRING_FINISH \
|
#define STRING_FINISH \
|
||||||
do { \
|
do { \
|
||||||
obstack_1grow (&obstack_for_string, '\0'); \
|
obstack_1grow (&obstack_for_string, '\0'); \
|
||||||
last_string = obstack_finish (&obstack_for_string); \
|
last_string = obstack_finish (&obstack_for_string); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define STRING_FREE \
|
#define STRING_FREE \
|
||||||
|
|||||||
212
src/getargs.c
212
src/getargs.c
@@ -52,7 +52,7 @@ bool graph_flag;
|
|||||||
bool xml_flag;
|
bool xml_flag;
|
||||||
bool no_lines_flag;
|
bool no_lines_flag;
|
||||||
bool token_table_flag;
|
bool token_table_flag;
|
||||||
bool yacc_flag; /* for -y */
|
bool yacc_flag; /* for -y */
|
||||||
|
|
||||||
bool nondeterministic_parser = false;
|
bool nondeterministic_parser = false;
|
||||||
bool glr_parser = false;
|
bool glr_parser = false;
|
||||||
@@ -94,32 +94,32 @@ char *program_name;
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
flags_argmatch (const char *option,
|
flags_argmatch (const char *option,
|
||||||
const char * const keys[], const int values[],
|
const char * const keys[], const int values[],
|
||||||
int all, int *flags, char *args)
|
int all, int *flags, char *args)
|
||||||
{
|
{
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
args = strtok (args, ",");
|
args = strtok (args, ",");
|
||||||
while (args)
|
while (args)
|
||||||
{
|
{
|
||||||
int no = strncmp (args, "no-", 3) == 0 ? 3 : 0;
|
int no = strncmp (args, "no-", 3) == 0 ? 3 : 0;
|
||||||
int value = XARGMATCH (option, args + no, keys, values);
|
int value = XARGMATCH (option, args + no, keys, values);
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
{
|
{
|
||||||
if (no)
|
if (no)
|
||||||
*flags |= all;
|
*flags |= all;
|
||||||
else
|
else
|
||||||
*flags &= ~all;
|
*flags &= ~all;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (no)
|
if (no)
|
||||||
*flags &= ~value;
|
*flags &= ~value;
|
||||||
else
|
else
|
||||||
*flags |= value;
|
*flags |= value;
|
||||||
}
|
}
|
||||||
args = strtok (NULL, ",");
|
args = strtok (NULL, ",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*flags |= all;
|
*flags |= all;
|
||||||
@@ -135,9 +135,9 @@ flags_argmatch (const char *option,
|
|||||||
* \arg FlagName_all the all value.
|
* \arg FlagName_all the all value.
|
||||||
* \arg FlagName_flag the flag to update.
|
* \arg FlagName_flag the flag to update.
|
||||||
*/
|
*/
|
||||||
#define FLAGS_ARGMATCH(FlagName, Args) \
|
#define FLAGS_ARGMATCH(FlagName, Args) \
|
||||||
flags_argmatch ("--" #FlagName, FlagName ## _args, FlagName ## _types, \
|
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)
|
if (status != 0)
|
||||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||||
program_name);
|
program_name);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* For ../build-aux/cross-options.pl to work, use the format:
|
/* For ../build-aux/cross-options.pl to work, use the format:
|
||||||
^ -S, --long[=ARGS] (whitespace)
|
^ -S, --long[=ARGS] (whitespace)
|
||||||
A --long option is required.
|
A --long option is required.
|
||||||
Otherwise, add exceptions to ../build-aux/cross-options.pl. */
|
Otherwise, add exceptions to ../build-aux/cross-options.pl. */
|
||||||
|
|
||||||
printf (_("Usage: %s [OPTION]... FILE\n"), program_name);
|
printf (_("Usage: %s [OPTION]... FILE\n"), program_name);
|
||||||
fputs (_("\
|
fputs (_("\
|
||||||
@@ -379,14 +379,14 @@ version (void)
|
|||||||
putc ('\n', stdout);
|
putc ('\n', stdout);
|
||||||
|
|
||||||
fprintf (stdout,
|
fprintf (stdout,
|
||||||
_("Copyright (C) %d Free Software Foundation, Inc.\n"),
|
_("Copyright (C) %d Free Software Foundation, Inc.\n"),
|
||||||
PACKAGE_COPYRIGHT_YEAR);
|
PACKAGE_COPYRIGHT_YEAR);
|
||||||
|
|
||||||
fputs (_("\
|
fputs (_("\
|
||||||
This is free software; see the source for copying conditions. There is NO\n\
|
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\
|
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;
|
int i;
|
||||||
for (i = 0; valid_languages[i].language[0]; i++)
|
for (i = 0; valid_languages[i].language[0]; i++)
|
||||||
if (c_strcasecmp (arg, valid_languages[i].language) == 0)
|
if (c_strcasecmp (arg, valid_languages[i].language) == 0)
|
||||||
{
|
{
|
||||||
language_prio = prio;
|
language_prio = prio;
|
||||||
language = &valid_languages[i];
|
language = &valid_languages[i];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
msg = _("invalid language `%s'");
|
msg = _("invalid language `%s'");
|
||||||
}
|
}
|
||||||
else if (language_prio == prio)
|
else if (language_prio == prio)
|
||||||
@@ -474,25 +474,25 @@ enum
|
|||||||
static struct option const long_options[] =
|
static struct option const long_options[] =
|
||||||
{
|
{
|
||||||
/* Operation modes. */
|
/* Operation modes. */
|
||||||
{ "help", no_argument, 0, 'h' },
|
{ "help", no_argument, 0, 'h' },
|
||||||
{ "version", no_argument, 0, 'V' },
|
{ "version", no_argument, 0, 'V' },
|
||||||
{ "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION },
|
{ "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION },
|
||||||
{ "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION },
|
{ "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION },
|
||||||
{ "warnings", optional_argument, 0, 'W' },
|
{ "warnings", optional_argument, 0, 'W' },
|
||||||
|
|
||||||
/* Parser. */
|
/* Parser. */
|
||||||
{ "name-prefix", required_argument, 0, 'p' },
|
{ "name-prefix", required_argument, 0, 'p' },
|
||||||
{ "include", required_argument, 0, 'I' },
|
{ "include", required_argument, 0, 'I' },
|
||||||
|
|
||||||
/* Output. */
|
/* Output. */
|
||||||
{ "file-prefix", required_argument, 0, 'b' },
|
{ "file-prefix", required_argument, 0, 'b' },
|
||||||
{ "output", required_argument, 0, 'o' },
|
{ "output", required_argument, 0, 'o' },
|
||||||
{ "output-file", required_argument, 0, 'o' },
|
{ "output-file", required_argument, 0, 'o' },
|
||||||
{ "graph", optional_argument, 0, 'g' },
|
{ "graph", optional_argument, 0, 'g' },
|
||||||
{ "xml", optional_argument, 0, 'x' },
|
{ "xml", optional_argument, 0, 'x' },
|
||||||
{ "report", required_argument, 0, 'r' },
|
{ "report", required_argument, 0, 'r' },
|
||||||
{ "report-file", required_argument, 0, REPORT_FILE_OPTION },
|
{ "report-file", required_argument, 0, REPORT_FILE_OPTION },
|
||||||
{ "verbose", no_argument, 0, 'v' },
|
{ "verbose", no_argument, 0, 'v' },
|
||||||
|
|
||||||
/* Hidden. */
|
/* Hidden. */
|
||||||
{ "trace", optional_argument, 0, 'T' },
|
{ "trace", optional_argument, 0, 'T' },
|
||||||
@@ -502,13 +502,13 @@ static struct option const long_options[] =
|
|||||||
|
|
||||||
/* Operation modes. */
|
/* Operation modes. */
|
||||||
{ "fixed-output-files", no_argument, 0, 'y' },
|
{ "fixed-output-files", no_argument, 0, 'y' },
|
||||||
{ "yacc", no_argument, 0, 'y' },
|
{ "yacc", no_argument, 0, 'y' },
|
||||||
|
|
||||||
/* Parser. */
|
/* Parser. */
|
||||||
{ "debug", no_argument, 0, 't' },
|
{ "debug", no_argument, 0, 't' },
|
||||||
{ "define", required_argument, 0, 'D' },
|
{ "define", required_argument, 0, 'D' },
|
||||||
{ "force-define", required_argument, 0, 'F' },
|
{ "force-define", required_argument, 0, 'F' },
|
||||||
{ "locations", no_argument, 0, LOCATIONS_OPTION },
|
{ "locations", no_argument, 0, LOCATIONS_OPTION },
|
||||||
{ "no-lines", no_argument, 0, 'l' },
|
{ "no-lines", no_argument, 0, 'l' },
|
||||||
{ "raw", no_argument, 0, 0 },
|
{ "raw", no_argument, 0, 0 },
|
||||||
{ "skeleton", required_argument, 0, 'S' },
|
{ "skeleton", required_argument, 0, 'S' },
|
||||||
@@ -545,15 +545,15 @@ getargs (int argc, char *argv[])
|
|||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ((c = getopt_long (argc, argv, short_options, long_options, NULL))
|
while ((c = getopt_long (argc, argv, short_options, long_options, NULL))
|
||||||
!= -1)
|
!= -1)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
/* ASCII Sorting for short options (i.e., upper case then
|
/* ASCII Sorting for short options (i.e., upper case then
|
||||||
lower case), and then long-only options. */
|
lower case), and then long-only options. */
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
/* Certain long options cause getopt_long to return 0. */
|
/* Certain long options cause getopt_long to return 0. */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'D': /* -DNAME[=VALUE]. */
|
case 'D': /* -DNAME[=VALUE]. */
|
||||||
case 'F': /* -FNAME[=VALUE]. */
|
case 'F': /* -FNAME[=VALUE]. */
|
||||||
@@ -567,37 +567,37 @@ getargs (int argc, char *argv[])
|
|||||||
c == 'D' ? MUSCLE_PERCENT_DEFINE_D
|
c == 'D' ? MUSCLE_PERCENT_DEFINE_D
|
||||||
: MUSCLE_PERCENT_DEFINE_F);
|
: MUSCLE_PERCENT_DEFINE_F);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
include = AS_FILE_NAME (optarg);
|
include = AS_FILE_NAME (optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'L':
|
case 'L':
|
||||||
language_argmatch (optarg, command_line_prio,
|
language_argmatch (optarg, command_line_prio,
|
||||||
command_line_location ());
|
command_line_location ());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
skeleton_arg (AS_FILE_NAME (optarg), command_line_prio,
|
skeleton_arg (AS_FILE_NAME (optarg), command_line_prio,
|
||||||
command_line_location ());
|
command_line_location ());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'T':
|
case 'T':
|
||||||
FLAGS_ARGMATCH (trace, optarg);
|
FLAGS_ARGMATCH (trace, optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
version ();
|
version ();
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
|
||||||
case 'W':
|
case 'W':
|
||||||
FLAGS_ARGMATCH (warnings, optarg);
|
FLAGS_ARGMATCH (warnings, optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
spec_file_prefix = AS_FILE_NAME (optarg);
|
spec_file_prefix = AS_FILE_NAME (optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
/* Here, the -d and --defines options are differentiated. */
|
/* Here, the -d and --defines options are differentiated. */
|
||||||
@@ -607,81 +607,81 @@ getargs (int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'g':
|
case 'g':
|
||||||
graph_flag = true;
|
graph_flag = true;
|
||||||
if (optarg)
|
if (optarg)
|
||||||
spec_graph_file = xstrdup (AS_FILE_NAME (optarg));
|
spec_graph_file = xstrdup (AS_FILE_NAME (optarg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
usage (EXIT_SUCCESS);
|
usage (EXIT_SUCCESS);
|
||||||
|
|
||||||
case 'k':
|
case 'k':
|
||||||
token_table_flag = true;
|
token_table_flag = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
no_lines_flag = true;
|
no_lines_flag = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
spec_outfile = AS_FILE_NAME (optarg);
|
spec_outfile = AS_FILE_NAME (optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
spec_name_prefix = optarg;
|
spec_name_prefix = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
FLAGS_ARGMATCH (report, optarg);
|
FLAGS_ARGMATCH (report, optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
muscle_percent_define_insert ("parse.trace",
|
muscle_percent_define_insert ("parse.trace",
|
||||||
command_line_location (), "",
|
command_line_location (), "",
|
||||||
MUSCLE_PERCENT_DEFINE_D);
|
MUSCLE_PERCENT_DEFINE_D);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
report_flag |= report_states;
|
report_flag |= report_states;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
xml_flag = true;
|
xml_flag = true;
|
||||||
if (optarg)
|
if (optarg)
|
||||||
spec_xml_file = xstrdup (AS_FILE_NAME (optarg));
|
spec_xml_file = xstrdup (AS_FILE_NAME (optarg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'y':
|
case 'y':
|
||||||
yacc_flag = true;
|
yacc_flag = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOCATIONS_OPTION:
|
case LOCATIONS_OPTION:
|
||||||
muscle_percent_define_ensure ("locations",
|
muscle_percent_define_ensure ("locations",
|
||||||
command_line_location (), true);
|
command_line_location (), true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PRINT_LOCALEDIR_OPTION:
|
case PRINT_LOCALEDIR_OPTION:
|
||||||
printf ("%s\n", LOCALEDIR);
|
printf ("%s\n", LOCALEDIR);
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
|
||||||
case PRINT_DATADIR_OPTION:
|
case PRINT_DATADIR_OPTION:
|
||||||
printf ("%s\n", compute_pkgdatadir ());
|
printf ("%s\n", compute_pkgdatadir ());
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
|
|
||||||
case REPORT_FILE_OPTION:
|
case REPORT_FILE_OPTION:
|
||||||
spec_verbose_file = xstrdup (AS_FILE_NAME (optarg));
|
spec_verbose_file = xstrdup (AS_FILE_NAME (optarg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage (EXIT_FAILURE);
|
usage (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc - optind != 1)
|
if (argc - optind != 1)
|
||||||
{
|
{
|
||||||
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
|
else
|
||||||
error (0, 0, _("extra operand `%s'"), argv[optind + 1]);
|
error (0, 0, _("extra operand `%s'"), argv[optind + 1]);
|
||||||
usage (EXIT_FAILURE);
|
usage (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ extern int skeleton_prio;
|
|||||||
/* for -I */
|
/* for -I */
|
||||||
extern char const *include;
|
extern char const *include;
|
||||||
|
|
||||||
extern bool defines_flag; /* for -d */
|
extern bool defines_flag; /* for -d */
|
||||||
extern bool graph_flag; /* for -g */
|
extern bool graph_flag; /* for -g */
|
||||||
extern bool xml_flag; /* for -x */
|
extern bool xml_flag; /* for -x */
|
||||||
extern bool no_lines_flag; /* for -l */
|
extern bool no_lines_flag; /* for -l */
|
||||||
extern bool token_table_flag; /* for -k */
|
extern bool token_table_flag; /* for -k */
|
||||||
extern bool yacc_flag; /* for -y */
|
extern bool yacc_flag; /* for -y */
|
||||||
|
|
||||||
|
|
||||||
/* GLR_PARSER is true if the input file says to use the GLR
|
/* GLR_PARSER is true if the input file says to use the GLR
|
||||||
|
|||||||
72
src/gram.c
72
src/gram.c
@@ -78,7 +78,7 @@ rule_lhs_print (rule *r, symbol *previous_lhs, FILE *out)
|
|||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
for (n = strlen (previous_lhs->tag); n > 0; --n)
|
for (n = strlen (previous_lhs->tag); n > 0; --n)
|
||||||
fputc (' ', out);
|
fputc (' ', out);
|
||||||
fputc ('|', out);
|
fputc ('|', out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ rule_rhs_print (rule *r, FILE *out)
|
|||||||
{
|
{
|
||||||
item_number *rp;
|
item_number *rp;
|
||||||
for (rp = r->rhs; *rp >= 0; rp++)
|
for (rp = r->rhs; *rp >= 0; rp++)
|
||||||
fprintf (out, " %s", symbols[*rp]->tag);
|
fprintf (out, " %s", symbols[*rp]->tag);
|
||||||
fputc ('\n', out);
|
fputc ('\n', out);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -123,8 +123,8 @@ rule_rhs_print_xml (rule *r, FILE *out, int level)
|
|||||||
item_number *rp;
|
item_number *rp;
|
||||||
xml_puts (out, level, "<rhs>");
|
xml_puts (out, level, "<rhs>");
|
||||||
for (rp = r->rhs; *rp >= 0; rp++)
|
for (rp = r->rhs; *rp >= 0; rp++)
|
||||||
xml_printf (out, level + 1, "<symbol>%s</symbol>",
|
xml_printf (out, level + 1, "<symbol>%s</symbol>",
|
||||||
xml_escape (symbols[*rp]->tag));
|
xml_escape (symbols[*rp]->tag));
|
||||||
xml_puts (out, level, "</rhs>");
|
xml_puts (out, level, "</rhs>");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -165,7 +165,7 @@ ritem_longest_rhs (void)
|
|||||||
{
|
{
|
||||||
int length = rule_rhs_length (&rules[r]);
|
int length = rule_rhs_length (&rules[r]);
|
||||||
if (length > max)
|
if (length > max)
|
||||||
max = length;
|
max = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return max;
|
return max;
|
||||||
@@ -173,7 +173,7 @@ ritem_longest_rhs (void)
|
|||||||
|
|
||||||
void
|
void
|
||||||
grammar_rules_partial_print (FILE *out, const char *title,
|
grammar_rules_partial_print (FILE *out, const char *title,
|
||||||
rule_filter filter)
|
rule_filter filter)
|
||||||
{
|
{
|
||||||
rule_number r;
|
rule_number r;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
@@ -183,11 +183,11 @@ grammar_rules_partial_print (FILE *out, const char *title,
|
|||||||
for (r = 0; r < nrules + nuseless_productions; r++)
|
for (r = 0; r < nrules + nuseless_productions; r++)
|
||||||
{
|
{
|
||||||
if (filter && !filter (&rules[r]))
|
if (filter && !filter (&rules[r]))
|
||||||
continue;
|
continue;
|
||||||
if (first)
|
if (first)
|
||||||
fprintf (out, "%s\n\n", title);
|
fprintf (out, "%s\n\n", title);
|
||||||
else if (previous_lhs && previous_lhs != rules[r].lhs)
|
else if (previous_lhs && previous_lhs != rules[r].lhs)
|
||||||
fputc ('\n', out);
|
fputc ('\n', out);
|
||||||
first = false;
|
first = false;
|
||||||
rule_lhs_print (&rules[r], previous_lhs, out);
|
rule_lhs_print (&rules[r], previous_lhs, out);
|
||||||
rule_rhs_print (&rules[r], 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++)
|
for (r = 0; r < nrules + nuseless_productions; r++)
|
||||||
{
|
{
|
||||||
if (first)
|
if (first)
|
||||||
xml_puts (out, level + 1, "<rules>");
|
xml_puts (out, level + 1, "<rules>");
|
||||||
first = false;
|
first = false;
|
||||||
{
|
{
|
||||||
char const *usefulness;
|
char const *usefulness;
|
||||||
@@ -245,8 +245,8 @@ grammar_dump (FILE *out, const char *title)
|
|||||||
{
|
{
|
||||||
fprintf (out, "%s\n\n", title);
|
fprintf (out, "%s\n\n", title);
|
||||||
fprintf (out,
|
fprintf (out,
|
||||||
"ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
|
"ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
|
||||||
ntokens, nvars, nsyms, nrules, nritems);
|
ntokens, nvars, nsyms, nrules, nritems);
|
||||||
|
|
||||||
|
|
||||||
fprintf (out, "Variables\n---------\n\n");
|
fprintf (out, "Variables\n---------\n\n");
|
||||||
@@ -256,9 +256,9 @@ grammar_dump (FILE *out, const char *title)
|
|||||||
|
|
||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
fprintf (out, "%5d %5d %5d %s\n",
|
fprintf (out, "%5d %5d %5d %s\n",
|
||||||
i,
|
i,
|
||||||
symbols[i]->prec, symbols[i]->assoc,
|
symbols[i]->prec, symbols[i]->assoc,
|
||||||
symbols[i]->tag);
|
symbols[i]->tag);
|
||||||
fprintf (out, "\n\n");
|
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");
|
fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n");
|
||||||
for (i = 0; i < nrules + nuseless_productions; i++)
|
for (i = 0; i < nrules + nuseless_productions; i++)
|
||||||
{
|
{
|
||||||
rule *rule_i = &rules[i];
|
rule *rule_i = &rules[i];
|
||||||
item_number *rp = NULL;
|
item_number *rp = NULL;
|
||||||
unsigned int rhs_itemno = rule_i->rhs - ritem;
|
unsigned int rhs_itemno = rule_i->rhs - ritem;
|
||||||
unsigned int rhs_count = 0;
|
unsigned int rhs_count = 0;
|
||||||
/* Find the last RHS index in ritems. */
|
/* Find the last RHS index in ritems. */
|
||||||
for (rp = rule_i->rhs; *rp >= 0; ++rp)
|
for (rp = rule_i->rhs; *rp >= 0; ++rp)
|
||||||
++rhs_count;
|
++rhs_count;
|
||||||
fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
|
fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
|
||||||
i,
|
i,
|
||||||
rule_i->prec ? rule_i->prec->prec : 0,
|
rule_i->prec ? rule_i->prec->prec : 0,
|
||||||
rule_i->prec ? rule_i->prec->assoc : 0,
|
rule_i->prec ? rule_i->prec->assoc : 0,
|
||||||
rule_i->useful,
|
rule_i->useful,
|
||||||
rhs_itemno,
|
rhs_itemno,
|
||||||
rhs_itemno + rhs_count - 1,
|
rhs_itemno + rhs_count - 1,
|
||||||
rule_i->lhs->number);
|
rule_i->lhs->number);
|
||||||
/* Dumped the RHS. */
|
/* Dumped the RHS. */
|
||||||
for (rp = rule_i->rhs; *rp >= 0; rp++)
|
for (rp = rule_i->rhs; *rp >= 0; rp++)
|
||||||
fprintf (out, " %3d", *rp);
|
fprintf (out, " %3d", *rp);
|
||||||
fprintf (out, " [%d]\n", item_number_as_rule_number (*rp));
|
fprintf (out, " [%d]\n", item_number_as_rule_number (*rp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (out, "\n\n");
|
fprintf (out, "\n\n");
|
||||||
@@ -296,8 +296,8 @@ grammar_dump (FILE *out, const char *title)
|
|||||||
rule_number r;
|
rule_number r;
|
||||||
for (r = 0; r < nrules + nuseless_productions; r++)
|
for (r = 0; r < nrules + nuseless_productions; r++)
|
||||||
{
|
{
|
||||||
fprintf (out, "%-5d ", r);
|
fprintf (out, "%-5d ", r);
|
||||||
rule_print (&rules[r], out);
|
rule_print (&rules[r], out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (out, "\n\n");
|
fprintf (out, "\n\n");
|
||||||
|
|||||||
@@ -105,8 +105,8 @@
|
|||||||
# include "location.h"
|
# include "location.h"
|
||||||
# include "symtab.h"
|
# include "symtab.h"
|
||||||
|
|
||||||
# define ISTOKEN(i) ((i) < ntokens)
|
# define ISTOKEN(i) ((i) < ntokens)
|
||||||
# define ISVAR(i) ((i) >= ntokens)
|
# define ISVAR(i) ((i) >= ntokens)
|
||||||
|
|
||||||
extern int nsyms;
|
extern int nsyms;
|
||||||
extern int ntokens;
|
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. */
|
/* Print the grammar's rules that match FILTER on OUT under TITLE. */
|
||||||
void grammar_rules_partial_print (FILE *out, const char *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. */
|
/* Print the grammar's useful rules on OUT. */
|
||||||
void grammar_rules_print (FILE *out);
|
void grammar_rules_print (FILE *out);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ output_node (int id, char const *label, FILE *fout)
|
|||||||
|
|
||||||
void
|
void
|
||||||
output_edge (int source, int destination, char const *label,
|
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);
|
fprintf (fout, " %d -> %d [style=%s", source, destination, style);
|
||||||
if (label)
|
if (label)
|
||||||
|
|||||||
@@ -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 style Dot style of the edge (e.g., "dotted" or "solid").
|
||||||
/// \param fout output stream.
|
/// \param fout output stream.
|
||||||
void output_edge (int source, int destination, char const *label,
|
void output_edge (int source, int destination, char const *label,
|
||||||
char const *style, FILE *fout);
|
char const *style, FILE *fout);
|
||||||
|
|
||||||
/// End a Dot graph.
|
/// End a Dot graph.
|
||||||
/// \param fout output stream.
|
/// \param fout output stream.
|
||||||
|
|||||||
170
src/lalr.c
170
src/lalr.c
@@ -85,14 +85,14 @@ set_goto_map (void)
|
|||||||
transitions *sp = states[s]->transitions;
|
transitions *sp = states[s]->transitions;
|
||||||
int i;
|
int i;
|
||||||
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
|
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
|
||||||
{
|
{
|
||||||
ngotos++;
|
ngotos++;
|
||||||
|
|
||||||
/* Abort if (ngotos + 1) would overflow. */
|
/* Abort if (ngotos + 1) would overflow. */
|
||||||
aver (ngotos != GOTO_NUMBER_MAXIMUM);
|
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;
|
int i;
|
||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
{
|
{
|
||||||
temp_map[i - ntokens] = k;
|
temp_map[i - ntokens] = k;
|
||||||
k += goto_map[i - ntokens];
|
k += goto_map[i - ntokens];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
@@ -119,11 +119,11 @@ set_goto_map (void)
|
|||||||
transitions *sp = states[s]->transitions;
|
transitions *sp = states[s]->transitions;
|
||||||
int i;
|
int i;
|
||||||
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
|
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
|
||||||
{
|
{
|
||||||
goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
|
goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
|
||||||
from_state[k] = s;
|
from_state[k] = s;
|
||||||
to_state[k] = sp->states[i]->number;
|
to_state[k] = sp->states[i]->number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free (temp_map);
|
free (temp_map);
|
||||||
@@ -147,11 +147,11 @@ map_goto (state_number s0, symbol_number sym)
|
|||||||
middle = (low + high) / 2;
|
middle = (low + high) / 2;
|
||||||
s = from_state[middle];
|
s = from_state[middle];
|
||||||
if (s == s0)
|
if (s == s0)
|
||||||
return middle;
|
return middle;
|
||||||
else if (s < s0)
|
else if (s < s0)
|
||||||
low = middle + 1;
|
low = middle + 1;
|
||||||
else
|
else
|
||||||
high = middle - 1;
|
high = middle - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,24 +174,24 @@ initialize_F (void)
|
|||||||
|
|
||||||
int j;
|
int j;
|
||||||
FOR_EACH_SHIFT (sp, 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++)
|
for (; j < sp->num; j++)
|
||||||
{
|
{
|
||||||
symbol_number sym = TRANSITION_SYMBOL (sp, j);
|
symbol_number sym = TRANSITION_SYMBOL (sp, j);
|
||||||
if (nullable[sym - ntokens])
|
if (nullable[sym - ntokens])
|
||||||
edge[nedges++] = map_goto (stateno, sym);
|
edge[nedges++] = map_goto (stateno, sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nedges == 0)
|
if (nedges == 0)
|
||||||
reads[i] = NULL;
|
reads[i] = NULL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reads[i] = xnmalloc (nedges + 1, sizeof reads[i][0]);
|
reads[i] = xnmalloc (nedges + 1, sizeof reads[i][0]);
|
||||||
memcpy (reads[i], edge, nedges * sizeof edge[0]);
|
memcpy (reads[i], edge, nedges * sizeof edge[0]);
|
||||||
reads[i][nedges] = END_NODE;
|
reads[i][nedges] = END_NODE;
|
||||||
nedges = 0;
|
nedges = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
relation_digraph (reads, ngotos, &goto_follows);
|
relation_digraph (reads, ngotos, &goto_follows);
|
||||||
@@ -232,53 +232,53 @@ build_relations (void)
|
|||||||
rule **rulep;
|
rule **rulep;
|
||||||
|
|
||||||
for (rulep = derives[symbol1 - ntokens]; *rulep; rulep++)
|
for (rulep = derives[symbol1 - ntokens]; *rulep; rulep++)
|
||||||
{
|
{
|
||||||
bool done;
|
bool done;
|
||||||
int length = 1;
|
int length = 1;
|
||||||
item_number const *rp;
|
item_number const *rp;
|
||||||
state *s = states[from_state[i]];
|
state *s = states[from_state[i]];
|
||||||
states1[0] = s->number;
|
states1[0] = s->number;
|
||||||
|
|
||||||
for (rp = (*rulep)->rhs; ! item_number_is_rule_number (*rp); rp++)
|
for (rp = (*rulep)->rhs; ! item_number_is_rule_number (*rp); rp++)
|
||||||
{
|
{
|
||||||
s = transitions_to (s->transitions,
|
s = transitions_to (s->transitions,
|
||||||
item_number_as_symbol_number (*rp));
|
item_number_as_symbol_number (*rp));
|
||||||
states1[length++] = s->number;
|
states1[length++] = s->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s->consistent)
|
if (!s->consistent)
|
||||||
add_lookback_edge (s, *rulep, i);
|
add_lookback_edge (s, *rulep, i);
|
||||||
|
|
||||||
length--;
|
length--;
|
||||||
done = false;
|
done = false;
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
done = true;
|
done = true;
|
||||||
/* Each rhs ends in a rule number, and there is a
|
/* Each rhs ends in a rule number, and there is a
|
||||||
sentinel (ritem[-1]=0) before the first rhs, so it is safe to
|
sentinel (ritem[-1]=0) before the first rhs, so it is safe to
|
||||||
decrement RP here. */
|
decrement RP here. */
|
||||||
rp--;
|
rp--;
|
||||||
if (ISVAR (*rp))
|
if (ISVAR (*rp))
|
||||||
{
|
{
|
||||||
/* Downcasting from item_number to symbol_number. */
|
/* Downcasting from item_number to symbol_number. */
|
||||||
edge[nedges++] = map_goto (states1[--length],
|
edge[nedges++] = map_goto (states1[--length],
|
||||||
item_number_as_symbol_number (*rp));
|
item_number_as_symbol_number (*rp));
|
||||||
if (nullable[*rp - ntokens])
|
if (nullable[*rp - ntokens])
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nedges == 0)
|
if (nedges == 0)
|
||||||
includes[i] = NULL;
|
includes[i] = NULL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
includes[i] = xnmalloc (nedges + 1, sizeof includes[i][0]);
|
includes[i] = xnmalloc (nedges + 1, sizeof includes[i][0]);
|
||||||
for (j = 0; j < nedges; j++)
|
for (j = 0; j < nedges; j++)
|
||||||
includes[i][j] = edge[j];
|
includes[i][j] = edge[j];
|
||||||
includes[i][nedges] = END_NODE;
|
includes[i][nedges] = END_NODE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free (edge);
|
free (edge);
|
||||||
@@ -398,10 +398,10 @@ initialize_LA (void)
|
|||||||
state_lookahead_tokens_count (states[i],
|
state_lookahead_tokens_count (states[i],
|
||||||
default_reduction_only_for_accept);
|
default_reduction_only_for_accept);
|
||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
states[i]->reductions->lookahead_tokens = pLA;
|
states[i]->reductions->lookahead_tokens = pLA;
|
||||||
pLA += count;
|
pLA += count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,21 +423,21 @@ lookahead_tokens_print (FILE *out)
|
|||||||
int n_lookahead_tokens = 0;
|
int n_lookahead_tokens = 0;
|
||||||
|
|
||||||
if (reds->lookahead_tokens)
|
if (reds->lookahead_tokens)
|
||||||
for (k = 0; k < reds->num; ++k)
|
for (k = 0; k < reds->num; ++k)
|
||||||
if (reds->lookahead_tokens[k])
|
if (reds->lookahead_tokens[k])
|
||||||
++n_lookahead_tokens;
|
++n_lookahead_tokens;
|
||||||
|
|
||||||
fprintf (out, "State %d: %d lookahead tokens\n",
|
fprintf (out, "State %d: %d lookahead tokens\n",
|
||||||
i, n_lookahead_tokens);
|
i, n_lookahead_tokens);
|
||||||
|
|
||||||
if (reds->lookahead_tokens)
|
if (reds->lookahead_tokens)
|
||||||
for (j = 0; j < reds->num; ++j)
|
for (j = 0; j < reds->num; ++j)
|
||||||
BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0)
|
BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0)
|
||||||
{
|
{
|
||||||
fprintf (out, " on %d (%s) -> rule %d\n",
|
fprintf (out, " on %d (%s) -> rule %d\n",
|
||||||
k, symbols[k]->tag,
|
k, symbols[k]->tag,
|
||||||
reds->rules[j]->number);
|
reds->rules[j]->number);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
fprintf (out, "Lookahead tokens: END\n");
|
fprintf (out, "Lookahead tokens: END\n");
|
||||||
}
|
}
|
||||||
|
|||||||
162
src/local.mk
162
src/local.mk
@@ -32,91 +32,91 @@ bin_SCRIPTS = $(YACC_SCRIPT)
|
|||||||
EXTRA_SCRIPTS = src/yacc
|
EXTRA_SCRIPTS = src/yacc
|
||||||
|
|
||||||
src_bison_CFLAGS = $(AM_CFLAGS) $(WERROR_CFLAGS)
|
src_bison_CFLAGS = $(AM_CFLAGS) $(WERROR_CFLAGS)
|
||||||
src_bison_SOURCES = \
|
src_bison_SOURCES = \
|
||||||
src/AnnotationList.c \
|
src/AnnotationList.c \
|
||||||
src/AnnotationList.h \
|
src/AnnotationList.h \
|
||||||
src/InadequacyList.c \
|
src/InadequacyList.c \
|
||||||
src/InadequacyList.h \
|
src/InadequacyList.h \
|
||||||
src/LR0.c \
|
src/LR0.c \
|
||||||
src/LR0.h \
|
src/LR0.h \
|
||||||
src/Sbitset.c \
|
src/Sbitset.c \
|
||||||
src/Sbitset.h \
|
src/Sbitset.h \
|
||||||
src/assoc.c \
|
src/assoc.c \
|
||||||
src/assoc.h \
|
src/assoc.h \
|
||||||
src/closure.c \
|
src/closure.c \
|
||||||
src/closure.h \
|
src/closure.h \
|
||||||
src/complain.c \
|
src/complain.c \
|
||||||
src/complain.h \
|
src/complain.h \
|
||||||
src/conflicts.c \
|
src/conflicts.c \
|
||||||
src/conflicts.h \
|
src/conflicts.h \
|
||||||
src/derives.c \
|
src/derives.c \
|
||||||
src/derives.h \
|
src/derives.h \
|
||||||
src/files.c \
|
src/files.c \
|
||||||
src/files.h \
|
src/files.h \
|
||||||
src/flex-scanner.h \
|
src/flex-scanner.h \
|
||||||
src/getargs.c \
|
src/getargs.c \
|
||||||
src/getargs.h \
|
src/getargs.h \
|
||||||
src/gram.c \
|
src/gram.c \
|
||||||
src/gram.h \
|
src/gram.h \
|
||||||
src/graphviz.c \
|
src/graphviz.c \
|
||||||
src/graphviz.h \
|
src/graphviz.h \
|
||||||
src/lalr.c \
|
src/lalr.c \
|
||||||
src/lalr.h \
|
src/lalr.h \
|
||||||
src/ielr.c \
|
src/ielr.c \
|
||||||
src/ielr.h \
|
src/ielr.h \
|
||||||
src/location.c \
|
src/location.c \
|
||||||
src/location.h \
|
src/location.h \
|
||||||
src/main.c \
|
src/main.c \
|
||||||
src/muscle-tab.c \
|
src/muscle-tab.c \
|
||||||
src/muscle-tab.h \
|
src/muscle-tab.h \
|
||||||
src/named-ref.c \
|
src/named-ref.c \
|
||||||
src/named-ref.h \
|
src/named-ref.h \
|
||||||
src/nullable.c \
|
src/nullable.c \
|
||||||
src/nullable.h \
|
src/nullable.h \
|
||||||
src/output.c \
|
src/output.c \
|
||||||
src/output.h \
|
src/output.h \
|
||||||
src/parse-gram.h \
|
src/parse-gram.h \
|
||||||
src/parse-gram.y \
|
src/parse-gram.y \
|
||||||
src/print-xml.c \
|
src/print-xml.c \
|
||||||
src/print-xml.h \
|
src/print-xml.h \
|
||||||
src/print.c \
|
src/print.c \
|
||||||
src/print.h \
|
src/print.h \
|
||||||
src/print_graph.c \
|
src/print_graph.c \
|
||||||
src/print_graph.h \
|
src/print_graph.h \
|
||||||
src/reader.c \
|
src/reader.c \
|
||||||
src/reader.h \
|
src/reader.h \
|
||||||
src/reduce.c \
|
src/reduce.c \
|
||||||
src/reduce.h \
|
src/reduce.h \
|
||||||
src/relation.c \
|
src/relation.c \
|
||||||
src/relation.h \
|
src/relation.h \
|
||||||
src/scan-code-c.c \
|
src/scan-code-c.c \
|
||||||
src/scan-code.h \
|
src/scan-code.h \
|
||||||
src/scan-gram-c.c \
|
src/scan-gram-c.c \
|
||||||
src/scan-gram.h \
|
src/scan-gram.h \
|
||||||
src/scan-skel-c.c \
|
src/scan-skel-c.c \
|
||||||
src/scan-skel.h \
|
src/scan-skel.h \
|
||||||
src/state.c \
|
src/state.c \
|
||||||
src/state.h \
|
src/state.h \
|
||||||
src/symlist.c \
|
src/symlist.c \
|
||||||
src/symlist.h \
|
src/symlist.h \
|
||||||
src/symtab.c \
|
src/symtab.c \
|
||||||
src/symtab.h \
|
src/symtab.h \
|
||||||
src/system.h \
|
src/system.h \
|
||||||
src/tables.c \
|
src/tables.c \
|
||||||
src/tables.h \
|
src/tables.h \
|
||||||
src/uniqstr.c \
|
src/uniqstr.c \
|
||||||
src/uniqstr.h
|
src/uniqstr.h
|
||||||
|
|
||||||
EXTRA_src_bison_SOURCES = \
|
EXTRA_src_bison_SOURCES = \
|
||||||
src/scan-code.l \
|
src/scan-code.l \
|
||||||
src/scan-gram.l \
|
src/scan-gram.l \
|
||||||
src/scan-skel.l
|
src/scan-skel.l
|
||||||
|
|
||||||
BUILT_SOURCES += \
|
BUILT_SOURCES += \
|
||||||
src/parse-gram.c \
|
src/parse-gram.c \
|
||||||
src/parse-gram.h \
|
src/parse-gram.h \
|
||||||
src/scan-code.c \
|
src/scan-code.c \
|
||||||
src/scan-gram.c \
|
src/scan-gram.c \
|
||||||
src/scan-skel.c
|
src/scan-skel.c
|
||||||
|
|
||||||
MOSTLYCLEANFILES += src/yacc
|
MOSTLYCLEANFILES += src/yacc
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ add_column_width (int column, char const *buf, size_t bufsize)
|
|||||||
if (buf)
|
if (buf)
|
||||||
{
|
{
|
||||||
if (INT_MAX / 2 <= bufsize)
|
if (INT_MAX / 2 <= bufsize)
|
||||||
return INT_MAX;
|
return INT_MAX;
|
||||||
width = mbsnwidth (buf, bufsize, 0);
|
width = mbsnwidth (buf, bufsize, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -69,19 +69,19 @@ location_compute (location *loc, boundary *cur, char const *token, size_t size)
|
|||||||
switch (*p)
|
switch (*p)
|
||||||
{
|
{
|
||||||
case '\n':
|
case '\n':
|
||||||
line += line < INT_MAX;
|
line += line < INT_MAX;
|
||||||
column = 1;
|
column = 1;
|
||||||
p0 = p + 1;
|
p0 = p + 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\t':
|
case '\t':
|
||||||
column = add_column_width (column, p0, p - p0);
|
column = add_column_width (column, p0, p - p0);
|
||||||
column = add_column_width (column, NULL, 8 - ((column - 1) & 7));
|
column = add_column_width (column, NULL, 8 - ((column - 1) & 7));
|
||||||
p0 = p + 1;
|
p0 = p + 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur->line = line;
|
cur->line = line;
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ static inline bool
|
|||||||
equal_boundaries (boundary a, boundary b)
|
equal_boundaries (boundary a, boundary b)
|
||||||
{
|
{
|
||||||
return (a.column == b.column
|
return (a.column == b.column
|
||||||
&& a.line == b.line
|
&& a.line == b.line
|
||||||
&& UNIQSTR_EQ (a.file, b.file));
|
&& UNIQSTR_EQ (a.file, b.file));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A location, that is, a region of source code. */
|
/* 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
|
/* Set *LOC and adjust scanner cursor to account for token TOKEN of
|
||||||
size SIZE. */
|
size SIZE. */
|
||||||
void location_compute (location *loc,
|
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
|
/* Print location to file. Return number of actually printed
|
||||||
characters. */
|
characters. */
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ muscle_init (void)
|
|||||||
obstack_init (&muscle_obstack);
|
obstack_init (&muscle_obstack);
|
||||||
|
|
||||||
muscle_table = hash_initialize (HT_INITIAL_CAPACITY, NULL, hash_muscle,
|
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. */
|
/* Version and input file. */
|
||||||
MUSCLE_INSERT_STRING ("version", VERSION);
|
MUSCLE_INSERT_STRING ("version", VERSION);
|
||||||
@@ -179,7 +179,7 @@ muscle_syncline_grow (char const *key, location loc)
|
|||||||
char *extension = NULL;
|
char *extension = NULL;
|
||||||
obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line);
|
obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line);
|
||||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
|
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_sgrow (&muscle_obstack, "]])[");
|
||||||
obstack_1grow (&muscle_obstack, 0);
|
obstack_1grow (&muscle_obstack, 0);
|
||||||
extension = obstack_finish (&muscle_obstack);
|
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,
|
void muscle_pair_list_grow (const char *muscle,
|
||||||
const char *a1, const char *a2)
|
const char *a1, const char *a2)
|
||||||
{
|
{
|
||||||
char *pair;
|
char *pair;
|
||||||
obstack_sgrow (&muscle_obstack, "[[[");
|
obstack_sgrow (&muscle_obstack, "[[[");
|
||||||
|
|||||||
@@ -32,40 +32,40 @@ void muscle_free (void);
|
|||||||
/* An obstack dedicated to receive muscle keys and values. */
|
/* An obstack dedicated to receive muscle keys and values. */
|
||||||
extern struct obstack muscle_obstack;
|
extern struct obstack muscle_obstack;
|
||||||
|
|
||||||
#define MUSCLE_INSERT_BOOL(Key, Value) \
|
#define MUSCLE_INSERT_BOOL(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
int v__ = Value; \
|
int v__ = Value; \
|
||||||
MUSCLE_INSERT_INT (Key, v__); \
|
MUSCLE_INSERT_INT (Key, v__); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_INT(Key, Value) \
|
#define MUSCLE_INSERT_INT(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
|
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
|
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
|
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
/* Key -> Value, but don't apply escaping to Value. */
|
/* Key -> Value, but don't apply escaping to Value. */
|
||||||
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
|
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
obstack_sgrow (&muscle_obstack, Value); \
|
obstack_sgrow (&muscle_obstack, Value); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
/* Key -> Value, applying M4 escaping to Value. */
|
/* Key -> Value, applying M4 escaping to Value. */
|
||||||
#define MUSCLE_INSERT_STRING(Key, Value) \
|
#define MUSCLE_INSERT_STRING(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \
|
MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \
|
#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \
|
||||||
@@ -74,21 +74,21 @@ do { \
|
|||||||
for (p__ = Value; *p__; p__++) \
|
for (p__ = Value; *p__; p__++) \
|
||||||
switch (*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; \
|
default: obstack_1grow (Obstack, *p__); break; \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define MUSCLE_INSERT_C_STRING(Key, Value) \
|
#define MUSCLE_INSERT_C_STRING(Key, Value) \
|
||||||
do { \
|
do { \
|
||||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, \
|
MUSCLE_OBSTACK_SGROW (&muscle_obstack, \
|
||||||
quotearg_style (c_quoting_style, \
|
quotearg_style (c_quoting_style, \
|
||||||
Value)); \
|
Value)); \
|
||||||
obstack_1grow (&muscle_obstack, 0); \
|
obstack_1grow (&muscle_obstack, 0); \
|
||||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
/* Append VALUE to the current value of KEY. If KEY did not already
|
/* 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
|
muscle values are output *double* quoted, one needs to strip the first level
|
||||||
of quotes to reach the list itself. */
|
of quotes to reach the list itself. */
|
||||||
void muscle_pair_list_grow (const char *muscle,
|
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
|
/* In the format `[[file_name:line.column]], [[file_name:line.column]]', append
|
||||||
LOC to MUSCLE. Use digraphs for special characters in each file name. */
|
LOC to MUSCLE. Use digraphs for special characters in each file name. */
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ nullable_print (FILE *out)
|
|||||||
fputs ("NULLABLE\n", out);
|
fputs ("NULLABLE\n", out);
|
||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
fprintf (out, "\t%s: %s\n", symbols[i]->tag,
|
fprintf (out, "\t%s: %s\n", symbols[i]->tag,
|
||||||
nullable[i - ntokens] ? "yes" : "no");
|
nullable[i - ntokens] ? "yes" : "no");
|
||||||
fputs ("\n\n", out);
|
fputs ("\n\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,52 +77,52 @@ nullable_compute (void)
|
|||||||
for (ruleno = 0; ruleno < nrules; ++ruleno)
|
for (ruleno = 0; ruleno < nrules; ++ruleno)
|
||||||
if (rules[ruleno].useful)
|
if (rules[ruleno].useful)
|
||||||
{
|
{
|
||||||
rule *rules_ruleno = &rules[ruleno];
|
rule *rules_ruleno = &rules[ruleno];
|
||||||
if (rules_ruleno->rhs[0] >= 0)
|
if (rules_ruleno->rhs[0] >= 0)
|
||||||
{
|
{
|
||||||
/* This rule has a non empty RHS. */
|
/* This rule has a non empty RHS. */
|
||||||
item_number *rp = NULL;
|
item_number *rp = NULL;
|
||||||
bool any_tokens = false;
|
bool any_tokens = false;
|
||||||
for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
|
for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
|
||||||
if (ISTOKEN (*rp))
|
if (ISTOKEN (*rp))
|
||||||
any_tokens = true;
|
any_tokens = true;
|
||||||
|
|
||||||
/* This rule has only nonterminals: schedule it for the second
|
/* This rule has only nonterminals: schedule it for the second
|
||||||
pass. */
|
pass. */
|
||||||
if (!any_tokens)
|
if (!any_tokens)
|
||||||
for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
|
for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
|
||||||
{
|
{
|
||||||
rcount[ruleno]++;
|
rcount[ruleno]++;
|
||||||
p->next = rsets[*rp - ntokens];
|
p->next = rsets[*rp - ntokens];
|
||||||
p->value = rules_ruleno;
|
p->value = rules_ruleno;
|
||||||
rsets[*rp - ntokens] = p;
|
rsets[*rp - ntokens] = p;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* This rule has an empty RHS. */
|
/* This rule has an empty RHS. */
|
||||||
aver (item_number_as_rule_number (rules_ruleno->rhs[0])
|
aver (item_number_as_rule_number (rules_ruleno->rhs[0])
|
||||||
== ruleno);
|
== ruleno);
|
||||||
if (rules_ruleno->useful
|
if (rules_ruleno->useful
|
||||||
&& ! nullable[rules_ruleno->lhs->number - ntokens])
|
&& ! nullable[rules_ruleno->lhs->number - ntokens])
|
||||||
{
|
{
|
||||||
nullable[rules_ruleno->lhs->number - ntokens] = true;
|
nullable[rules_ruleno->lhs->number - ntokens] = true;
|
||||||
*s2++ = rules_ruleno->lhs->number;
|
*s2++ = rules_ruleno->lhs->number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (s1 < s2)
|
while (s1 < s2)
|
||||||
for (p = rsets[*s1++ - ntokens]; p; p = p->next)
|
for (p = rsets[*s1++ - ntokens]; p; p = p->next)
|
||||||
{
|
{
|
||||||
rule *r = p->value;
|
rule *r = p->value;
|
||||||
if (--rcount[r->number] == 0)
|
if (--rcount[r->number] == 0)
|
||||||
if (r->useful && ! nullable[r->lhs->number - ntokens])
|
if (r->useful && ! nullable[r->lhs->number - ntokens])
|
||||||
{
|
{
|
||||||
nullable[r->lhs->number - ntokens] = true;
|
nullable[r->lhs->number - ntokens] = true;
|
||||||
*s2++ = r->lhs->number;
|
*s2++ = r->lhs->number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free (squeue);
|
free (squeue);
|
||||||
|
|||||||
168
src/output.c
168
src/output.c
@@ -54,51 +54,51 @@ static struct obstack format_obstack;
|
|||||||
`-------------------------------------------------------------------*/
|
`-------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#define GENERATE_MUSCLE_INSERT_TABLE(Name, Type) \
|
#define GENERATE_MUSCLE_INSERT_TABLE(Name, Type) \
|
||||||
\
|
\
|
||||||
static void \
|
static void \
|
||||||
Name (char const *name, \
|
Name (char const *name, \
|
||||||
Type *table_data, \
|
Type *table_data, \
|
||||||
Type first, \
|
Type first, \
|
||||||
int begin, \
|
int begin, \
|
||||||
int end) \
|
int end) \
|
||||||
{ \
|
{ \
|
||||||
Type min = first; \
|
Type min = first; \
|
||||||
Type max = first; \
|
Type max = first; \
|
||||||
long int lmin; \
|
long int lmin; \
|
||||||
long int lmax; \
|
long int lmax; \
|
||||||
int i; \
|
int i; \
|
||||||
int j = 1; \
|
int j = 1; \
|
||||||
\
|
\
|
||||||
obstack_fgrow1 (&format_obstack, "%6d", first); \
|
obstack_fgrow1 (&format_obstack, "%6d", first); \
|
||||||
for (i = begin; i < end; ++i) \
|
for (i = begin; i < end; ++i) \
|
||||||
{ \
|
{ \
|
||||||
obstack_1grow (&format_obstack, ','); \
|
obstack_1grow (&format_obstack, ','); \
|
||||||
if (j >= 10) \
|
if (j >= 10) \
|
||||||
{ \
|
{ \
|
||||||
obstack_sgrow (&format_obstack, "\n "); \
|
obstack_sgrow (&format_obstack, "\n "); \
|
||||||
j = 1; \
|
j = 1; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
++j; \
|
++j; \
|
||||||
obstack_fgrow1 (&format_obstack, "%6d", table_data[i]); \
|
obstack_fgrow1 (&format_obstack, "%6d", table_data[i]); \
|
||||||
if (table_data[i] < min) \
|
if (table_data[i] < min) \
|
||||||
min = table_data[i]; \
|
min = table_data[i]; \
|
||||||
if (max < table_data[i]) \
|
if (max < table_data[i]) \
|
||||||
max = table_data[i]; \
|
max = table_data[i]; \
|
||||||
} \
|
} \
|
||||||
obstack_1grow (&format_obstack, 0); \
|
obstack_1grow (&format_obstack, 0); \
|
||||||
muscle_insert (name, obstack_finish (&format_obstack)); \
|
muscle_insert (name, obstack_finish (&format_obstack)); \
|
||||||
\
|
\
|
||||||
lmin = min; \
|
lmin = min; \
|
||||||
lmax = max; \
|
lmax = max; \
|
||||||
/* Build `NAME_min' and `NAME_max' in the obstack. */ \
|
/* Build `NAME_min' and `NAME_max' in the obstack. */ \
|
||||||
obstack_fgrow1 (&format_obstack, "%s_min", name); \
|
obstack_fgrow1 (&format_obstack, "%s_min", name); \
|
||||||
obstack_1grow (&format_obstack, 0); \
|
obstack_1grow (&format_obstack, 0); \
|
||||||
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
|
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
|
||||||
obstack_fgrow1 (&format_obstack, "%s_max", name); \
|
obstack_fgrow1 (&format_obstack, "%s_max", name); \
|
||||||
obstack_1grow (&format_obstack, 0); \
|
obstack_1grow (&format_obstack, 0); \
|
||||||
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
|
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
|
||||||
}
|
}
|
||||||
|
|
||||||
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_unsigned_int_table, unsigned int)
|
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_INT ("user_token_number_max", max_user_token_number);
|
||||||
|
|
||||||
muscle_insert_symbol_number_table ("translate",
|
muscle_insert_symbol_number_table ("translate",
|
||||||
token_translations,
|
token_translations,
|
||||||
token_translations[0],
|
token_translations[0],
|
||||||
1, max_user_token_number + 1);
|
1, max_user_token_number + 1);
|
||||||
|
|
||||||
/* tname -- token names. */
|
/* tname -- token names. */
|
||||||
{
|
{
|
||||||
@@ -163,23 +163,23 @@ prepare_symbols (void)
|
|||||||
set_quoting_flags (qo, QA_SPLIT_TRIGRAPHS);
|
set_quoting_flags (qo, QA_SPLIT_TRIGRAPHS);
|
||||||
for (i = 0; i < nsyms; i++)
|
for (i = 0; i < nsyms; i++)
|
||||||
{
|
{
|
||||||
char *cp = quotearg_alloc (symbols[i]->tag, -1, qo);
|
char *cp = quotearg_alloc (symbols[i]->tag, -1, qo);
|
||||||
/* Width of the next token, including the two quotes, the
|
/* Width of the next token, including the two quotes, the
|
||||||
comma and the space. */
|
comma and the space. */
|
||||||
int width = strlen (cp) + 2;
|
int width = strlen (cp) + 2;
|
||||||
|
|
||||||
if (j + width > 75)
|
if (j + width > 75)
|
||||||
{
|
{
|
||||||
obstack_sgrow (&format_obstack, "\n ");
|
obstack_sgrow (&format_obstack, "\n ");
|
||||||
j = 1;
|
j = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i)
|
if (i)
|
||||||
obstack_1grow (&format_obstack, ' ');
|
obstack_1grow (&format_obstack, ' ');
|
||||||
MUSCLE_OBSTACK_SGROW (&format_obstack, cp);
|
MUSCLE_OBSTACK_SGROW (&format_obstack, cp);
|
||||||
free (cp);
|
free (cp);
|
||||||
obstack_1grow (&format_obstack, ',');
|
obstack_1grow (&format_obstack, ',');
|
||||||
j += width;
|
j += width;
|
||||||
}
|
}
|
||||||
free (qo);
|
free (qo);
|
||||||
obstack_sgrow (&format_obstack, " ]b4_null[");
|
obstack_sgrow (&format_obstack, " ]b4_null[");
|
||||||
@@ -196,7 +196,7 @@ prepare_symbols (void)
|
|||||||
for (i = 0; i < ntokens; ++i)
|
for (i = 0; i < ntokens; ++i)
|
||||||
values[i] = symbols[i]->user_token_number;
|
values[i] = symbols[i]->user_token_number;
|
||||||
muscle_insert_int_table ("toknum", values,
|
muscle_insert_int_table ("toknum", values,
|
||||||
values[0], 1, ntokens);
|
values[0], 1, ntokens);
|
||||||
free (values);
|
free (values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,7 +264,7 @@ prepare_states (void)
|
|||||||
for (i = 0; i < nstates; ++i)
|
for (i = 0; i < nstates; ++i)
|
||||||
values[i] = states[i]->accessing_symbol;
|
values[i] = states[i]->accessing_symbol;
|
||||||
muscle_insert_symbol_number_table ("stos", values,
|
muscle_insert_symbol_number_table ("stos", values,
|
||||||
0, 1, nstates);
|
0, 1, nstates);
|
||||||
free (values);
|
free (values);
|
||||||
|
|
||||||
MUSCLE_INSERT_INT ("last", high);
|
MUSCLE_INSERT_INT ("last", high);
|
||||||
@@ -354,11 +354,11 @@ user_actions_output (FILE *out)
|
|||||||
for (r = 0; r < nrules; ++r)
|
for (r = 0; r < nrules; ++r)
|
||||||
if (rules[r].action)
|
if (rules[r].action)
|
||||||
{
|
{
|
||||||
fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ",
|
fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ",
|
||||||
rules[r].is_predicate ? "predicate_" : "",
|
rules[r].is_predicate ? "predicate_" : "",
|
||||||
r + 1, rules[r].action_location.start.line);
|
r + 1, rules[r].action_location.start.line);
|
||||||
escaped_output (out, rules[r].action_location.start.file);
|
escaped_output (out, rules[r].action_location.start.file);
|
||||||
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
|
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
|
||||||
}
|
}
|
||||||
fputs ("])\n\n", out);
|
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)
|
for (n = 1, p = merge_functions; p != NULL; n += 1, p = p->next)
|
||||||
{
|
{
|
||||||
if (p->type[0] == '\0')
|
if (p->type[0] == '\0')
|
||||||
fprintf (out, " case %d: *yy0 = %s (*yy0, *yy1); break;\n",
|
fprintf (out, " case %d: *yy0 = %s (*yy0, *yy1); break;\n",
|
||||||
n, p->name);
|
n, p->name);
|
||||||
else
|
else
|
||||||
fprintf (out, " case %d: yy0->%s = %s (*yy0, *yy1); break;\n",
|
fprintf (out, " case %d: yy0->%s = %s (*yy0, *yy1); break;\n",
|
||||||
n, p->type, p->name);
|
n, p->type, p->name);
|
||||||
}
|
}
|
||||||
fputs ("]])\n\n", out);
|
fputs ("]])\n\n", out);
|
||||||
}
|
}
|
||||||
@@ -503,30 +503,30 @@ prepare_actions (void)
|
|||||||
lookahead token type. */
|
lookahead token type. */
|
||||||
|
|
||||||
muscle_insert_rule_number_table ("defact", yydefact,
|
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
|
/* Figure out what to do after reducing with each rule, depending on
|
||||||
the saved state from before the beginning of parsing the data
|
the saved state from before the beginning of parsing the data
|
||||||
that matched this rule. */
|
that matched this rule. */
|
||||||
muscle_insert_state_number_table ("defgoto", yydefgoto,
|
muscle_insert_state_number_table ("defgoto", yydefgoto,
|
||||||
yydefgoto[0], 1, nsyms - ntokens);
|
yydefgoto[0], 1, nsyms - ntokens);
|
||||||
|
|
||||||
|
|
||||||
/* Output PACT. */
|
/* Output PACT. */
|
||||||
muscle_insert_base_table ("pact", base,
|
muscle_insert_base_table ("pact", base,
|
||||||
base[0], 1, nstates);
|
base[0], 1, nstates);
|
||||||
MUSCLE_INSERT_INT ("pact_ninf", base_ninf);
|
MUSCLE_INSERT_INT ("pact_ninf", base_ninf);
|
||||||
|
|
||||||
/* Output PGOTO. */
|
/* Output PGOTO. */
|
||||||
muscle_insert_base_table ("pgoto", base,
|
muscle_insert_base_table ("pgoto", base,
|
||||||
base[nstates], nstates + 1, nvectors);
|
base[nstates], nstates + 1, nvectors);
|
||||||
|
|
||||||
muscle_insert_base_table ("table", table,
|
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_INT ("table_ninf", table_ninf);
|
||||||
|
|
||||||
muscle_insert_base_table ("check", check,
|
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
|
/* GLR parsing slightly modifies YYTABLE and YYCHECK (and thus
|
||||||
YYPACT) so that in states with unresolved conflicts, the default
|
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
|
that case. Nevertheless, it seems even better to be able to use
|
||||||
the GLR skeletons even without the non-deterministic tables. */
|
the GLR skeletons even without the non-deterministic tables. */
|
||||||
muscle_insert_unsigned_int_table ("conflict_list_heads", conflict_table,
|
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,
|
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] == '/')
|
while (pkgdatadirlen && pkgdatadir[pkgdatadirlen - 1] == '/')
|
||||||
pkgdatadirlen--;
|
pkgdatadirlen--;
|
||||||
full_skeleton = xmalloc (pkgdatadirlen + 1
|
full_skeleton = xmalloc (pkgdatadirlen + 1
|
||||||
+ (skeleton_size < sizeof m4sugar
|
+ (skeleton_size < sizeof m4sugar
|
||||||
? sizeof m4sugar : skeleton_size));
|
? sizeof m4sugar : skeleton_size));
|
||||||
strncpy (full_skeleton, pkgdatadir, pkgdatadirlen);
|
strncpy (full_skeleton, pkgdatadir, pkgdatadirlen);
|
||||||
full_skeleton[pkgdatadirlen] = '/';
|
full_skeleton[pkgdatadirlen] = '/';
|
||||||
strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar);
|
strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar);
|
||||||
@@ -669,7 +669,7 @@ output_skeleton (void)
|
|||||||
in = fdopen (filter_fd[0], "r");
|
in = fdopen (filter_fd[0], "r");
|
||||||
if (! in)
|
if (! in)
|
||||||
error (EXIT_FAILURE, get_errno (),
|
error (EXIT_FAILURE, get_errno (),
|
||||||
"fdopen");
|
"fdopen");
|
||||||
scan_skel (in);
|
scan_skel (in);
|
||||||
/* scan_skel should have read all of M4's output. Otherwise, when we
|
/* 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
|
close the pipe, we risk letting M4 report a broken-pipe to the
|
||||||
|
|||||||
354
src/parse-gram.c
354
src/parse-gram.c
@@ -113,7 +113,7 @@
|
|||||||
static YYLTYPE lloc_default (YYLTYPE const *, int);
|
static YYLTYPE lloc_default (YYLTYPE const *, int);
|
||||||
|
|
||||||
#define YY_LOCATION_PRINT(File, Loc) \
|
#define YY_LOCATION_PRINT(File, Loc) \
|
||||||
location_print (File, Loc)
|
location_print (File, Loc)
|
||||||
|
|
||||||
static void version_check (location const *loc, char const *version);
|
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. */
|
FIXME: depends on the undocumented availability of YYLLOC. */
|
||||||
#undef yyerror
|
#undef yyerror
|
||||||
#define yyerror(Msg) \
|
#define yyerror(Msg) \
|
||||||
gram_error (&yylloc, Msg)
|
gram_error (&yylloc, Msg)
|
||||||
static void gram_error (location const *, char const *);
|
static void gram_error (location const *, char const *);
|
||||||
|
|
||||||
static char const *char_name (char);
|
static char const *char_name (char);
|
||||||
@@ -493,7 +493,7 @@ YYID (yyi)
|
|||||||
# endif
|
# endif
|
||||||
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
|
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
|
||||||
&& ! ((defined YYMALLOC || defined malloc) \
|
&& ! ((defined YYMALLOC || defined malloc) \
|
||||||
&& (defined YYFREE || defined free)))
|
&& (defined YYFREE || defined free)))
|
||||||
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
||||||
# ifndef EXIT_SUCCESS
|
# ifndef EXIT_SUCCESS
|
||||||
# define EXIT_SUCCESS 0
|
# define EXIT_SUCCESS 0
|
||||||
@@ -520,8 +520,8 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
|
|||||||
|
|
||||||
#if (! defined yyoverflow \
|
#if (! defined yyoverflow \
|
||||||
&& (! defined __cplusplus \
|
&& (! defined __cplusplus \
|
||||||
|| (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
|
|| (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
|
||||||
&& defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|
&& defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|
||||||
|
|
||||||
/* A type that is properly aligned for any stack member. */
|
/* A type that is properly aligned for any stack member. */
|
||||||
union yyalloc
|
union yyalloc
|
||||||
@@ -547,15 +547,15 @@ union yyalloc
|
|||||||
elements in the stack, and YYPTR gives the new location of the
|
elements in the stack, and YYPTR gives the new location of the
|
||||||
stack. Advance YYPTR to a properly aligned location for the next
|
stack. Advance YYPTR to a properly aligned location for the next
|
||||||
stack. */
|
stack. */
|
||||||
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
|
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
YYSIZE_T yynewbytes; \
|
YYSIZE_T yynewbytes; \
|
||||||
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
|
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
|
||||||
Stack = &yyptr->Stack_alloc; \
|
Stack = &yyptr->Stack_alloc; \
|
||||||
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
||||||
yyptr += yynewbytes / sizeof (*yyptr); \
|
yyptr += yynewbytes / sizeof (*yyptr); \
|
||||||
} \
|
} \
|
||||||
while (YYID (0))
|
while (YYID (0))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -568,13 +568,13 @@ union yyalloc
|
|||||||
# define YYCOPY(To, From, Count) \
|
# define YYCOPY(To, From, Count) \
|
||||||
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
|
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
|
||||||
# else
|
# else
|
||||||
# define YYCOPY(To, From, Count) \
|
# define YYCOPY(To, From, Count) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
YYSIZE_T yyi; \
|
YYSIZE_T yyi; \
|
||||||
for (yyi = 0; yyi < (Count); yyi++) \
|
for (yyi = 0; yyi < (Count); yyi++) \
|
||||||
(To)[yyi] = (From)[yyi]; \
|
(To)[yyi] = (From)[yyi]; \
|
||||||
} \
|
} \
|
||||||
while (YYID (0))
|
while (YYID (0))
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
@@ -599,7 +599,7 @@ union yyalloc
|
|||||||
#define YYUNDEFTOK 2
|
#define YYUNDEFTOK 2
|
||||||
#define YYMAXUTOK 311
|
#define YYMAXUTOK 311
|
||||||
|
|
||||||
#define YYTRANSLATE(YYX) \
|
#define YYTRANSLATE(YYX) \
|
||||||
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||||
|
|
||||||
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
||||||
@@ -875,14 +875,14 @@ static const yytype_uint8 yyr2[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define yyerrok (yyerrstatus = 0)
|
#define yyerrok (yyerrstatus = 0)
|
||||||
#define yyclearin (yychar = YYEMPTY)
|
#define yyclearin (yychar = YYEMPTY)
|
||||||
#define YYEMPTY (-2)
|
#define YYEMPTY (-2)
|
||||||
#define YYEOF 0
|
#define YYEOF 0
|
||||||
|
|
||||||
#define YYACCEPT goto yyacceptlab
|
#define YYACCEPT goto yyacceptlab
|
||||||
#define YYABORT goto yyabortlab
|
#define YYABORT goto yyabortlab
|
||||||
#define YYERROR goto yyerrorlab
|
#define YYERROR goto yyerrorlab
|
||||||
|
|
||||||
|
|
||||||
/* Like YYERROR except do call yyerror. This remains here temporarily
|
/* 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
|
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
|
||||||
discussed. */
|
discussed. */
|
||||||
|
|
||||||
#define YYFAIL goto yyerrlab
|
#define YYFAIL goto yyerrlab
|
||||||
#if defined YYFAIL
|
#if defined YYFAIL
|
||||||
/* This is here to suppress warnings from the GCC cpp's
|
/* This is here to suppress warnings from the GCC cpp's
|
||||||
-Wunused-macros. Normally we don't worry about that warning, but
|
-Wunused-macros. Normally we don't worry about that warning, but
|
||||||
@@ -902,26 +902,26 @@ static const yytype_uint8 yyr2[] =
|
|||||||
|
|
||||||
#define YYRECOVERING() (!!yyerrstatus)
|
#define YYRECOVERING() (!!yyerrstatus)
|
||||||
|
|
||||||
#define YYBACKUP(Token, Value) \
|
#define YYBACKUP(Token, Value) \
|
||||||
do \
|
do \
|
||||||
if (yychar == YYEMPTY && yylen == 1) \
|
if (yychar == YYEMPTY && yylen == 1) \
|
||||||
{ \
|
{ \
|
||||||
yychar = (Token); \
|
yychar = (Token); \
|
||||||
yylval = (Value); \
|
yylval = (Value); \
|
||||||
YYPOPSTACK (1); \
|
YYPOPSTACK (1); \
|
||||||
YY_LAC_DISCARD ("YYBACKUP"); \
|
YY_LAC_DISCARD ("YYBACKUP"); \
|
||||||
goto yybackup; \
|
goto yybackup; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
yyerror (YY_("syntax error: cannot back up")); \
|
yyerror (YY_("syntax error: cannot back up")); \
|
||||||
YYERROR; \
|
YYERROR; \
|
||||||
} \
|
} \
|
||||||
while (YYID (0))
|
while (YYID (0))
|
||||||
|
|
||||||
|
|
||||||
#define YYTERROR 1
|
#define YYTERROR 1
|
||||||
#define YYERRCODE 256
|
#define YYERRCODE 256
|
||||||
|
|
||||||
|
|
||||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
/* 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])
|
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
||||||
#ifndef YYLLOC_DEFAULT
|
#ifndef YYLLOC_DEFAULT
|
||||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||||
do \
|
do \
|
||||||
if (YYID (N)) \
|
if (YYID (N)) \
|
||||||
{ \
|
{ \
|
||||||
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
||||||
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
||||||
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
||||||
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
(Current).first_line = (Current).last_line = \
|
(Current).first_line = (Current).last_line = \
|
||||||
YYRHSLOC (Rhs, 0).last_line; \
|
YYRHSLOC (Rhs, 0).last_line; \
|
||||||
(Current).first_column = (Current).last_column = \
|
(Current).first_column = (Current).last_column = \
|
||||||
YYRHSLOC (Rhs, 0).last_column; \
|
YYRHSLOC (Rhs, 0).last_column; \
|
||||||
} \
|
} \
|
||||||
while (YYID (0))
|
while (YYID (0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -956,10 +956,10 @@ while (YYID (0))
|
|||||||
|
|
||||||
#ifndef YY_LOCATION_PRINT
|
#ifndef YY_LOCATION_PRINT
|
||||||
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
|
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
|
||||||
# define YY_LOCATION_PRINT(File, Loc) \
|
# define YY_LOCATION_PRINT(File, Loc) \
|
||||||
fprintf (File, "%d.%d-%d.%d", \
|
fprintf (File, "%d.%d-%d.%d", \
|
||||||
(Loc).first_line, (Loc).first_column, \
|
(Loc).first_line, (Loc).first_column, \
|
||||||
(Loc).last_line, (Loc).last_column)
|
(Loc).last_line, (Loc).last_column)
|
||||||
# else
|
# else
|
||||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||||
# endif
|
# endif
|
||||||
@@ -982,21 +982,21 @@ while (YYID (0))
|
|||||||
# define YYFPRINTF fprintf
|
# define YYFPRINTF fprintf
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# define YYDPRINTF(Args) \
|
# define YYDPRINTF(Args) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
YYFPRINTF Args; \
|
YYFPRINTF Args; \
|
||||||
} while (YYID (0))
|
} while (YYID (0))
|
||||||
|
|
||||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
{ \
|
{ \
|
||||||
YYFPRINTF (stderr, "%s ", Title); \
|
YYFPRINTF (stderr, "%s ", Title); \
|
||||||
yy_symbol_print (stderr, \
|
yy_symbol_print (stderr, \
|
||||||
Type, Value, Location); \
|
Type, Value, Location); \
|
||||||
YYFPRINTF (stderr, "\n"); \
|
YYFPRINTF (stderr, "\n"); \
|
||||||
} \
|
} \
|
||||||
} while (YYID (0))
|
} while (YYID (0))
|
||||||
|
|
||||||
|
|
||||||
@@ -1221,7 +1221,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1279,10 +1279,10 @@ yy_stack_print (yybottom, yytop)
|
|||||||
YYFPRINTF (stderr, "\n");
|
YYFPRINTF (stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
# define YY_STACK_PRINT(Bottom, Top) \
|
# define YY_STACK_PRINT(Bottom, Top) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
yy_stack_print ((Bottom), (Top)); \
|
yy_stack_print ((Bottom), (Top)); \
|
||||||
} while (YYID (0))
|
} while (YYID (0))
|
||||||
|
|
||||||
|
|
||||||
@@ -1320,9 +1320,9 @@ yy_reduce_print (yyssp, yyvsp, yylsp, yyrule)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# define YY_REDUCE_PRINT(Rule) \
|
# define YY_REDUCE_PRINT(Rule) \
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \
|
yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \
|
||||||
} while (YYID (0))
|
} while (YYID (0))
|
||||||
|
|
||||||
@@ -1338,7 +1338,7 @@ int yydebug;
|
|||||||
|
|
||||||
|
|
||||||
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
||||||
#ifndef YYINITDEPTH
|
#ifndef YYINITDEPTH
|
||||||
# define YYINITDEPTH 200
|
# define YYINITDEPTH 200
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1657,27 +1657,27 @@ yytnamerr (char *yyres, const char *yystr)
|
|||||||
char const *yyp = yystr;
|
char const *yyp = yystr;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
switch (*++yyp)
|
switch (*++yyp)
|
||||||
{
|
{
|
||||||
case '\'':
|
case '\'':
|
||||||
case ',':
|
case ',':
|
||||||
goto do_not_strip_quotes;
|
goto do_not_strip_quotes;
|
||||||
|
|
||||||
case '\\':
|
case '\\':
|
||||||
if (*++yyp != '\\')
|
if (*++yyp != '\\')
|
||||||
goto do_not_strip_quotes;
|
goto do_not_strip_quotes;
|
||||||
/* Fall through. */
|
/* Fall through. */
|
||||||
default:
|
default:
|
||||||
if (yyres)
|
if (yyres)
|
||||||
yyres[yyn] = *yyp;
|
yyres[yyn] = *yyp;
|
||||||
yyn++;
|
yyn++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '"':
|
case '"':
|
||||||
if (yyres)
|
if (yyres)
|
||||||
yyres[yyn] = '\0';
|
yyres[yyn] = '\0';
|
||||||
return yyn;
|
return yyn;
|
||||||
}
|
}
|
||||||
do_not_strip_quotes: ;
|
do_not_strip_quotes: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1858,7 +1858,7 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp)
|
|||||||
switch (yytype)
|
switch (yytype)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2043,26 +2043,26 @@ YYLTYPE yylloc;
|
|||||||
|
|
||||||
#ifdef yyoverflow
|
#ifdef yyoverflow
|
||||||
{
|
{
|
||||||
/* Give user a chance to reallocate the stack. Use copies of
|
/* Give user a chance to reallocate the stack. Use copies of
|
||||||
these so that the &'s don't force the real ones into
|
these so that the &'s don't force the real ones into
|
||||||
memory. */
|
memory. */
|
||||||
YYSTYPE *yyvs1 = yyvs;
|
YYSTYPE *yyvs1 = yyvs;
|
||||||
yytype_int16 *yyss1 = yyss;
|
yytype_int16 *yyss1 = yyss;
|
||||||
YYLTYPE *yyls1 = yyls;
|
YYLTYPE *yyls1 = yyls;
|
||||||
|
|
||||||
/* Each stack pointer address is followed by the size of the
|
/* Each stack pointer address is followed by the size of the
|
||||||
data in use in that stack, in bytes. This used to be a
|
data in use in that stack, in bytes. This used to be a
|
||||||
conditional around just the two extra args, but that might
|
conditional around just the two extra args, but that might
|
||||||
be undefined if yyoverflow is a macro. */
|
be undefined if yyoverflow is a macro. */
|
||||||
yyoverflow (YY_("memory exhausted"),
|
yyoverflow (YY_("memory exhausted"),
|
||||||
&yyss1, yysize * sizeof (*yyssp),
|
&yyss1, yysize * sizeof (*yyssp),
|
||||||
&yyvs1, yysize * sizeof (*yyvsp),
|
&yyvs1, yysize * sizeof (*yyvsp),
|
||||||
&yyls1, yysize * sizeof (*yylsp),
|
&yyls1, yysize * sizeof (*yylsp),
|
||||||
&yystacksize);
|
&yystacksize);
|
||||||
|
|
||||||
yyls = yyls1;
|
yyls = yyls1;
|
||||||
yyss = yyss1;
|
yyss = yyss1;
|
||||||
yyvs = yyvs1;
|
yyvs = yyvs1;
|
||||||
}
|
}
|
||||||
#else /* no yyoverflow */
|
#else /* no yyoverflow */
|
||||||
# ifndef YYSTACK_RELOCATE
|
# ifndef YYSTACK_RELOCATE
|
||||||
@@ -2070,23 +2070,23 @@ YYLTYPE yylloc;
|
|||||||
# else
|
# else
|
||||||
/* Extend the stack our own way. */
|
/* Extend the stack our own way. */
|
||||||
if (YYMAXDEPTH <= yystacksize)
|
if (YYMAXDEPTH <= yystacksize)
|
||||||
goto yyexhaustedlab;
|
goto yyexhaustedlab;
|
||||||
yystacksize *= 2;
|
yystacksize *= 2;
|
||||||
if (YYMAXDEPTH < yystacksize)
|
if (YYMAXDEPTH < yystacksize)
|
||||||
yystacksize = YYMAXDEPTH;
|
yystacksize = YYMAXDEPTH;
|
||||||
|
|
||||||
{
|
{
|
||||||
yytype_int16 *yyss1 = yyss;
|
yytype_int16 *yyss1 = yyss;
|
||||||
union yyalloc *yyptr =
|
union yyalloc *yyptr =
|
||||||
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
|
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
|
||||||
if (! yyptr)
|
if (! yyptr)
|
||||||
goto yyexhaustedlab;
|
goto yyexhaustedlab;
|
||||||
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
||||||
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
|
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
|
||||||
YYSTACK_RELOCATE (yyls_alloc, yyls);
|
YYSTACK_RELOCATE (yyls_alloc, yyls);
|
||||||
# undef YYSTACK_RELOCATE
|
# undef YYSTACK_RELOCATE
|
||||||
if (yyss1 != yyssa)
|
if (yyss1 != yyssa)
|
||||||
YYSTACK_FREE (yyss1);
|
YYSTACK_FREE (yyss1);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
#endif /* no yyoverflow */
|
#endif /* no yyoverflow */
|
||||||
@@ -2096,10 +2096,10 @@ YYLTYPE yylloc;
|
|||||||
yylsp = yyls + yysize - 1;
|
yylsp = yyls + yysize - 1;
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
||||||
(unsigned long int) yystacksize));
|
(unsigned long int) yystacksize));
|
||||||
|
|
||||||
if (yyss + yystacksize - 1 <= yyssp)
|
if (yyss + yystacksize - 1 <= yyssp)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
||||||
@@ -2503,7 +2503,7 @@ yyreduce:
|
|||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
for (list = (yyvsp[0].list); list; list = list->next)
|
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));
|
symbol_list_free ((yyvsp[0].list));
|
||||||
}
|
}
|
||||||
/* Line 1740 of yacc.c */
|
/* Line 1740 of yacc.c */
|
||||||
@@ -2516,7 +2516,7 @@ yyreduce:
|
|||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
for (list = (yyvsp[0].list); list; list = list->next)
|
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));
|
symbol_list_free ((yyvsp[0].list));
|
||||||
}
|
}
|
||||||
/* Line 1740 of yacc.c */
|
/* Line 1740 of yacc.c */
|
||||||
@@ -2640,7 +2640,7 @@ yyreduce:
|
|||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
tag_seen = true;
|
tag_seen = true;
|
||||||
for (list = (yyvsp[0].list); list; list = list->next)
|
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));
|
symbol_list_free ((yyvsp[0].list));
|
||||||
}
|
}
|
||||||
/* Line 1740 of yacc.c */
|
/* Line 1740 of yacc.c */
|
||||||
@@ -2654,10 +2654,10 @@ yyreduce:
|
|||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
++current_prec;
|
++current_prec;
|
||||||
for (list = (yyvsp[0].list); list; list = list->next)
|
for (list = (yyvsp[0].list); list; list = list->next)
|
||||||
{
|
{
|
||||||
symbol_type_set (list->content.sym, current_type, (yylsp[-1]));
|
symbol_type_set (list->content.sym, current_type, (yylsp[-1]));
|
||||||
symbol_precedence_set (list->content.sym, current_prec, (yyvsp[-2].assoc), (yylsp[-2]));
|
symbol_precedence_set (list->content.sym, current_prec, (yyvsp[-2].assoc), (yylsp[-2]));
|
||||||
}
|
}
|
||||||
symbol_list_free ((yyvsp[0].list));
|
symbol_list_free ((yyvsp[0].list));
|
||||||
current_type = NULL;
|
current_type = NULL;
|
||||||
}
|
}
|
||||||
@@ -2917,7 +2917,7 @@ yyreduce:
|
|||||||
/* Line 1740 of yacc.c */
|
/* Line 1740 of yacc.c */
|
||||||
#line 605 "src/parse-gram.y"
|
#line 605 "src/parse-gram.y"
|
||||||
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location,
|
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location,
|
||||||
current_lhs_named_ref); }
|
current_lhs_named_ref); }
|
||||||
/* Line 1740 of yacc.c */
|
/* Line 1740 of yacc.c */
|
||||||
#line 2923 "src/parse-gram.c"
|
#line 2923 "src/parse-gram.c"
|
||||||
break;
|
break;
|
||||||
@@ -3178,20 +3178,20 @@ yyerrlab:
|
|||||||
if (yyerrstatus == 3)
|
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. */
|
error, discard it. */
|
||||||
|
|
||||||
if (yychar <= YYEOF)
|
if (yychar <= YYEOF)
|
||||||
{
|
{
|
||||||
/* Return failure if at end of input. */
|
/* Return failure if at end of input. */
|
||||||
if (yychar == YYEOF)
|
if (yychar == YYEOF)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yydestruct ("Error: discarding",
|
yydestruct ("Error: discarding",
|
||||||
yytoken, &yylval, &yylloc);
|
yytoken, &yylval, &yylloc);
|
||||||
yychar = YYEMPTY;
|
yychar = YYEMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Else will try to reuse lookahead token after shifting the error
|
/* 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 -- common code for both syntax error and YYERROR. |
|
||||||
`-------------------------------------------------------------*/
|
`-------------------------------------------------------------*/
|
||||||
yyerrlab1:
|
yyerrlab1:
|
||||||
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
yyn = yypact[yystate];
|
yyn = yypact[yystate];
|
||||||
if (!yypact_value_is_default (yyn))
|
if (!yypact_value_is_default (yyn))
|
||||||
{
|
{
|
||||||
yyn += YYTERROR;
|
yyn += YYTERROR;
|
||||||
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
|
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
|
||||||
{
|
{
|
||||||
yyn = yytable[yyn];
|
yyn = yytable[yyn];
|
||||||
if (0 < yyn)
|
if (0 < yyn)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pop the current state because it cannot handle the error token. */
|
/* Pop the current state because it cannot handle the error token. */
|
||||||
if (yyssp == yyss)
|
if (yyssp == yyss)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
|
|
||||||
yyerror_range[1] = *yylsp;
|
yyerror_range[1] = *yylsp;
|
||||||
yydestruct ("Error: popping",
|
yydestruct ("Error: popping",
|
||||||
yystos[yystate], yyvsp, yylsp);
|
yystos[yystate], yyvsp, yylsp);
|
||||||
YYPOPSTACK (1);
|
YYPOPSTACK (1);
|
||||||
yystate = *yyssp;
|
yystate = *yyssp;
|
||||||
YY_STACK_PRINT (yyss, yyssp);
|
YY_STACK_PRINT (yyss, yyssp);
|
||||||
@@ -3311,7 +3311,7 @@ yyreturn:
|
|||||||
while (yyssp != yyss)
|
while (yyssp != yyss)
|
||||||
{
|
{
|
||||||
yydestruct ("Cleanup: popping",
|
yydestruct ("Cleanup: popping",
|
||||||
yystos[*yyssp], yyvsp, yylsp);
|
yystos[*yyssp], yyvsp, yylsp);
|
||||||
YYPOPSTACK (1);
|
YYPOPSTACK (1);
|
||||||
}
|
}
|
||||||
#ifndef yyoverflow
|
#ifndef yyoverflow
|
||||||
@@ -3355,8 +3355,8 @@ lloc_default (YYLTYPE const *rhs, int n)
|
|||||||
for (i = 1; i <= n; i++)
|
for (i = 1; i <= n; i++)
|
||||||
if (! equal_boundaries (rhs[i].start, rhs[i].end))
|
if (! equal_boundaries (rhs[i].start, rhs[i].end))
|
||||||
{
|
{
|
||||||
loc.start = rhs[i].start;
|
loc.start = rhs[i].start;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return loc;
|
return loc;
|
||||||
@@ -3399,9 +3399,9 @@ add_param (param_type type, char *decl, location loc)
|
|||||||
size_t name_len;
|
size_t name_len;
|
||||||
|
|
||||||
for (name_len = 1;
|
for (name_len = 1;
|
||||||
memchr (alphanum, name_start[name_len], sizeof alphanum);
|
memchr (alphanum, name_start[name_len], sizeof alphanum);
|
||||||
name_len++)
|
name_len++)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
name = xmalloc (name_len + 1);
|
name = xmalloc (name_len + 1);
|
||||||
memcpy (name, name_start, name_len);
|
memcpy (name, name_start, name_len);
|
||||||
@@ -3423,7 +3423,7 @@ version_check (location const *loc, char const *version)
|
|||||||
if (strverscmp (version, PACKAGE_VERSION) > 0)
|
if (strverscmp (version, PACKAGE_VERSION) > 0)
|
||||||
{
|
{
|
||||||
complain_at (*loc, "require bison %s, but have %s",
|
complain_at (*loc, "require bison %s, but have %s",
|
||||||
version, PACKAGE_VERSION);
|
version, PACKAGE_VERSION);
|
||||||
exit (63);
|
exit (63);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
static YYLTYPE lloc_default (YYLTYPE const *, int);
|
static YYLTYPE lloc_default (YYLTYPE const *, int);
|
||||||
|
|
||||||
#define YY_LOCATION_PRINT(File, Loc) \
|
#define YY_LOCATION_PRINT(File, Loc) \
|
||||||
location_print (File, Loc)
|
location_print (File, Loc)
|
||||||
|
|
||||||
static void version_check (location const *loc, char const *version);
|
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. */
|
FIXME: depends on the undocumented availability of YYLLOC. */
|
||||||
#undef yyerror
|
#undef yyerror
|
||||||
#define yyerror(Msg) \
|
#define yyerror(Msg) \
|
||||||
gram_error (&yylloc, Msg)
|
gram_error (&yylloc, Msg)
|
||||||
static void gram_error (location const *, char const *);
|
static void gram_error (location const *, char const *);
|
||||||
|
|
||||||
static char const *char_name (char);
|
static char const *char_name (char);
|
||||||
@@ -191,9 +191,9 @@ static char const *char_name (char);
|
|||||||
%type <chars> STRING "%{...%}" EPILOGUE braceless content.opt
|
%type <chars> STRING "%{...%}" EPILOGUE braceless content.opt
|
||||||
%type <code> "{...}" "%?{...}"
|
%type <code> "{...}" "%?{...}"
|
||||||
%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
|
%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
|
||||||
STRING
|
STRING
|
||||||
%printer { fprintf (stderr, "{\n%s\n}", $$); }
|
%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
|
%type <uniqstr> BRACKETED_ID ID ID_COLON PERCENT_FLAG TAG variable
|
||||||
%printer { fputs ($$, stderr); } <uniqstr>
|
%printer { fputs ($$, stderr); } <uniqstr>
|
||||||
@@ -270,9 +270,9 @@ input:
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------.
|
/*------------------------------------.
|
||||||
| Declarations: before the first %%. |
|
| Declarations: before the first %%. |
|
||||||
`------------------------------------*/
|
`------------------------------------*/
|
||||||
|
|
||||||
prologue_declarations:
|
prologue_declarations:
|
||||||
/* Nothing */
|
/* Nothing */
|
||||||
@@ -312,7 +312,7 @@ prologue_declaration:
|
|||||||
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
||||||
}
|
}
|
||||||
| "%expect" INT { expected_sr_conflicts = $2; }
|
| "%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 = $2; }
|
||||||
| "%file-prefix" "=" STRING { spec_file_prefix = $3; } /* deprecated */
|
| "%file-prefix" "=" STRING { spec_file_prefix = $3; } /* deprecated */
|
||||||
| "%glr-parser"
|
| "%glr-parser"
|
||||||
@@ -329,11 +329,11 @@ prologue_declaration:
|
|||||||
muscle_code_grow ("initial_action", action.code, @2);
|
muscle_code_grow ("initial_action", action.code, @2);
|
||||||
code_scanner_last_string_free ();
|
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 = $2; }
|
||||||
| "%name-prefix" "=" STRING { spec_name_prefix = $3; } /* deprecated */
|
| "%name-prefix" "=" STRING { spec_name_prefix = $3; } /* deprecated */
|
||||||
| "%no-lines" { no_lines_flag = true; }
|
| "%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 = $2; }
|
||||||
| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */
|
| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */
|
||||||
| "%param" { current_param = $1; } params { current_param = param_none; }
|
| "%param" { current_param = $1; } params { current_param = param_none; }
|
||||||
@@ -389,14 +389,14 @@ grammar_declaration:
|
|||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
for (list = $3; list; list = list->next)
|
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);
|
symbol_list_free ($3);
|
||||||
}
|
}
|
||||||
| "%printer" "{...}" generic_symlist
|
| "%printer" "{...}" generic_symlist
|
||||||
{
|
{
|
||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
for (list = $3; list; list = list->next)
|
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);
|
symbol_list_free ($3);
|
||||||
}
|
}
|
||||||
| "%default-prec"
|
| "%default-prec"
|
||||||
@@ -461,7 +461,7 @@ symbol_declaration:
|
|||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
tag_seen = true;
|
tag_seen = true;
|
||||||
for (list = $3; list; list = list->next)
|
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);
|
symbol_list_free ($3);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@@ -472,10 +472,10 @@ precedence_declaration:
|
|||||||
symbol_list *list;
|
symbol_list *list;
|
||||||
++current_prec;
|
++current_prec;
|
||||||
for (list = $3; list; list = list->next)
|
for (list = $3; list; list = list->next)
|
||||||
{
|
{
|
||||||
symbol_type_set (list->content.sym, current_type, @2);
|
symbol_type_set (list->content.sym, current_type, @2);
|
||||||
symbol_precedence_set (list->content.sym, current_prec, $1, @1);
|
symbol_precedence_set (list->content.sym, current_prec, $1, @1);
|
||||||
}
|
}
|
||||||
symbol_list_free ($3);
|
symbol_list_free ($3);
|
||||||
current_type = NULL;
|
current_type = NULL;
|
||||||
}
|
}
|
||||||
@@ -566,9 +566,9 @@ symbol_defs.1:
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------.
|
/*------------------------------------------.
|
||||||
| The grammar section: between the two %%. |
|
| The grammar section: between the two %%. |
|
||||||
`------------------------------------------*/
|
`------------------------------------------*/
|
||||||
|
|
||||||
grammar:
|
grammar:
|
||||||
rules_or_grammar_declaration
|
rules_or_grammar_declaration
|
||||||
@@ -603,7 +603,7 @@ rhses.1:
|
|||||||
rhs:
|
rhs:
|
||||||
/* Nothing. */
|
/* Nothing. */
|
||||||
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location,
|
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location,
|
||||||
current_lhs_named_ref); }
|
current_lhs_named_ref); }
|
||||||
| rhs symbol named_ref.opt
|
| rhs symbol named_ref.opt
|
||||||
{ grammar_current_rule_symbol_append ($2, @2, $3); }
|
{ grammar_current_rule_symbol_append ($2, @2, $3); }
|
||||||
| rhs "{...}" named_ref.opt
|
| rhs "{...}" named_ref.opt
|
||||||
@@ -735,8 +735,8 @@ lloc_default (YYLTYPE const *rhs, int n)
|
|||||||
for (i = 1; i <= n; i++)
|
for (i = 1; i <= n; i++)
|
||||||
if (! equal_boundaries (rhs[i].start, rhs[i].end))
|
if (! equal_boundaries (rhs[i].start, rhs[i].end))
|
||||||
{
|
{
|
||||||
loc.start = rhs[i].start;
|
loc.start = rhs[i].start;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return loc;
|
return loc;
|
||||||
@@ -779,9 +779,9 @@ add_param (param_type type, char *decl, location loc)
|
|||||||
size_t name_len;
|
size_t name_len;
|
||||||
|
|
||||||
for (name_len = 1;
|
for (name_len = 1;
|
||||||
memchr (alphanum, name_start[name_len], sizeof alphanum);
|
memchr (alphanum, name_start[name_len], sizeof alphanum);
|
||||||
name_len++)
|
name_len++)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
name = xmalloc (name_len + 1);
|
name = xmalloc (name_len + 1);
|
||||||
memcpy (name, name_start, name_len);
|
memcpy (name, name_start, name_len);
|
||||||
@@ -803,7 +803,7 @@ version_check (location const *loc, char const *version)
|
|||||||
if (strverscmp (version, PACKAGE_VERSION) > 0)
|
if (strverscmp (version, PACKAGE_VERSION) > 0)
|
||||||
{
|
{
|
||||||
complain_at (*loc, "require bison %s, but have %s",
|
complain_at (*loc, "require bison %s, but have %s",
|
||||||
version, PACKAGE_VERSION);
|
version, PACKAGE_VERSION);
|
||||||
exit (63);
|
exit (63);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
186
src/print-xml.c
186
src/print-xml.c
@@ -82,36 +82,36 @@ print_core (FILE *out, int level, state *s)
|
|||||||
sp1 = sp = ritem + sitems[i];
|
sp1 = sp = ritem + sitems[i];
|
||||||
|
|
||||||
while (*sp >= 0)
|
while (*sp >= 0)
|
||||||
sp++;
|
sp++;
|
||||||
|
|
||||||
r = item_number_as_rule_number (*sp);
|
r = item_number_as_rule_number (*sp);
|
||||||
sp = rules[r].rhs;
|
sp = rules[r].rhs;
|
||||||
|
|
||||||
/* Display the lookahead tokens? */
|
/* Display the lookahead tokens? */
|
||||||
if (item_number_is_rule_number (*sp1))
|
if (item_number_is_rule_number (*sp1))
|
||||||
{
|
{
|
||||||
reductions *reds = s->reductions;
|
reductions *reds = s->reductions;
|
||||||
int red = state_reduction_find (s, &rules[r]);
|
int red = state_reduction_find (s, &rules[r]);
|
||||||
/* Print item with lookaheads if there are. */
|
/* Print item with lookaheads if there are. */
|
||||||
if (reds->lookahead_tokens && red != -1)
|
if (reds->lookahead_tokens && red != -1)
|
||||||
{
|
{
|
||||||
xml_printf (out, level + 1,
|
xml_printf (out, level + 1,
|
||||||
"<item rule-number=\"%d\" point=\"%d\">",
|
"<item rule-number=\"%d\" point=\"%d\">",
|
||||||
rules[r].number, sp1 - sp);
|
rules[r].number, sp1 - sp);
|
||||||
state_rule_lookahead_tokens_print_xml (s, &rules[r],
|
state_rule_lookahead_tokens_print_xml (s, &rules[r],
|
||||||
out, level + 2);
|
out, level + 2);
|
||||||
xml_puts (out, level + 1, "</item>");
|
xml_puts (out, level + 1, "</item>");
|
||||||
printed = true;
|
printed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!printed)
|
if (!printed)
|
||||||
{
|
{
|
||||||
xml_printf (out, level + 1,
|
xml_printf (out, level + 1,
|
||||||
"<item rule-number=\"%d\" point=\"%d\"/>",
|
"<item rule-number=\"%d\" point=\"%d\"/>",
|
||||||
rules[r].number,
|
rules[r].number,
|
||||||
sp1 - sp);
|
sp1 - sp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xml_puts (out, level, "</itemset>");
|
xml_puts (out, level, "</itemset>");
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ print_transitions (state *s, FILE *out, int level)
|
|||||||
for (i = 0; i < trans->num; i++)
|
for (i = 0; i < trans->num; i++)
|
||||||
if (!TRANSITION_IS_DISABLED (trans, i))
|
if (!TRANSITION_IS_DISABLED (trans, i))
|
||||||
{
|
{
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Nothing to report. */
|
/* Nothing to report. */
|
||||||
@@ -146,28 +146,28 @@ print_transitions (state *s, FILE *out, int level)
|
|||||||
|
|
||||||
for (i = 0; i < trans->num; i++)
|
for (i = 0; i < trans->num; i++)
|
||||||
if (!TRANSITION_IS_DISABLED (trans, i)
|
if (!TRANSITION_IS_DISABLED (trans, i)
|
||||||
&& TRANSITION_IS_SHIFT (trans, i))
|
&& TRANSITION_IS_SHIFT (trans, i))
|
||||||
{
|
{
|
||||||
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
||||||
char const *tag = sym->tag;
|
char const *tag = sym->tag;
|
||||||
state *s1 = trans->states[i];
|
state *s1 = trans->states[i];
|
||||||
|
|
||||||
xml_printf (out, level + 1,
|
xml_printf (out, level + 1,
|
||||||
"<transition type=\"shift\" symbol=\"%s\" state=\"%d\"/>",
|
"<transition type=\"shift\" symbol=\"%s\" state=\"%d\"/>",
|
||||||
xml_escape (tag), s1->number);
|
xml_escape (tag), s1->number);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < trans->num; i++)
|
for (i = 0; i < trans->num; i++)
|
||||||
if (!TRANSITION_IS_DISABLED (trans, i)
|
if (!TRANSITION_IS_DISABLED (trans, i)
|
||||||
&& !TRANSITION_IS_SHIFT (trans, i))
|
&& !TRANSITION_IS_SHIFT (trans, i))
|
||||||
{
|
{
|
||||||
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
||||||
char const *tag = sym->tag;
|
char const *tag = sym->tag;
|
||||||
state *s1 = trans->states[i];
|
state *s1 = trans->states[i];
|
||||||
|
|
||||||
xml_printf (out, level + 1,
|
xml_printf (out, level + 1,
|
||||||
"<transition type=\"goto\" symbol=\"%s\" state=\"%d\"/>",
|
"<transition type=\"goto\" symbol=\"%s\" state=\"%d\"/>",
|
||||||
xml_escape (tag), s1->number);
|
xml_escape (tag), s1->number);
|
||||||
}
|
}
|
||||||
|
|
||||||
xml_puts (out, level, "</transitions>");
|
xml_puts (out, level, "</transitions>");
|
||||||
@@ -200,10 +200,10 @@ print_errs (FILE *out, int level, state *s)
|
|||||||
for (i = 0; i < errp->num; ++i)
|
for (i = 0; i < errp->num; ++i)
|
||||||
if (errp->symbols[i])
|
if (errp->symbols[i])
|
||||||
{
|
{
|
||||||
char const *tag = errp->symbols[i]->tag;
|
char const *tag = errp->symbols[i]->tag;
|
||||||
xml_printf (out, level + 1,
|
xml_printf (out, level + 1,
|
||||||
"<error symbol=\"%s\">nonassociative</error>",
|
"<error symbol=\"%s\">nonassociative</error>",
|
||||||
xml_escape (tag));
|
xml_escape (tag));
|
||||||
}
|
}
|
||||||
xml_puts (out, level, "</errors>");
|
xml_puts (out, level, "</errors>");
|
||||||
}
|
}
|
||||||
@@ -217,19 +217,19 @@ print_errs (FILE *out, int level, state *s)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
print_reduction (FILE *out, int level, char const *lookahead_token,
|
print_reduction (FILE *out, int level, char const *lookahead_token,
|
||||||
rule *r, bool enabled)
|
rule *r, bool enabled)
|
||||||
{
|
{
|
||||||
if (r->number)
|
if (r->number)
|
||||||
xml_printf (out, level,
|
xml_printf (out, level,
|
||||||
"<reduction symbol=\"%s\" rule=\"%d\" enabled=\"%s\"/>",
|
"<reduction symbol=\"%s\" rule=\"%d\" enabled=\"%s\"/>",
|
||||||
xml_escape (lookahead_token),
|
xml_escape (lookahead_token),
|
||||||
r->number,
|
r->number,
|
||||||
enabled ? "true" : "false");
|
enabled ? "true" : "false");
|
||||||
else
|
else
|
||||||
xml_printf (out, level,
|
xml_printf (out, level,
|
||||||
"<reduction symbol=\"%s\" rule=\"accept\" enabled=\"%s\"/>",
|
"<reduction symbol=\"%s\" rule=\"accept\" enabled=\"%s\"/>",
|
||||||
xml_escape (lookahead_token),
|
xml_escape (lookahead_token),
|
||||||
enabled ? "true" : "false");
|
enabled ? "true" : "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -268,22 +268,22 @@ print_reductions (FILE *out, int level, state *s)
|
|||||||
if (reds->lookahead_tokens)
|
if (reds->lookahead_tokens)
|
||||||
for (i = 0; i < ntokens; i++)
|
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)
|
for (j = 0; j < reds->num; ++j)
|
||||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||||
{
|
{
|
||||||
if (! count)
|
if (! count)
|
||||||
{
|
{
|
||||||
if (reds->rules[j] != default_reduction)
|
if (reds->rules[j] != default_reduction)
|
||||||
report = true;
|
report = true;
|
||||||
count = true;
|
count = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
report = true;
|
report = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Nothing to report. */
|
/* Nothing to report. */
|
||||||
@@ -298,36 +298,36 @@ print_reductions (FILE *out, int level, state *s)
|
|||||||
if (reds->lookahead_tokens)
|
if (reds->lookahead_tokens)
|
||||||
for (i = 0; i < ntokens; i++)
|
for (i = 0; i < ntokens; i++)
|
||||||
{
|
{
|
||||||
bool defaulted = false;
|
bool defaulted = false;
|
||||||
bool count = bitset_test (no_reduce_set, i);
|
bool count = bitset_test (no_reduce_set, i);
|
||||||
|
|
||||||
for (j = 0; j < reds->num; ++j)
|
for (j = 0; j < reds->num; ++j)
|
||||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||||
{
|
{
|
||||||
if (! count)
|
if (! count)
|
||||||
{
|
{
|
||||||
if (reds->rules[j] != default_reduction)
|
if (reds->rules[j] != default_reduction)
|
||||||
print_reduction (out, level + 1, symbols[i]->tag,
|
print_reduction (out, level + 1, symbols[i]->tag,
|
||||||
reds->rules[j], true);
|
reds->rules[j], true);
|
||||||
else
|
else
|
||||||
defaulted = true;
|
defaulted = true;
|
||||||
count = true;
|
count = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (defaulted)
|
if (defaulted)
|
||||||
print_reduction (out, level + 1, symbols[i]->tag,
|
print_reduction (out, level + 1, symbols[i]->tag,
|
||||||
default_reduction, true);
|
default_reduction, true);
|
||||||
defaulted = false;
|
defaulted = false;
|
||||||
print_reduction (out, level + 1, symbols[i]->tag,
|
print_reduction (out, level + 1, symbols[i]->tag,
|
||||||
reds->rules[j], false);
|
reds->rules[j], false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (default_reduction)
|
if (default_reduction)
|
||||||
print_reduction (out, level + 1,
|
print_reduction (out, level + 1,
|
||||||
"$default", default_reduction, true);
|
"$default", default_reduction, true);
|
||||||
|
|
||||||
xml_puts (out, level, "</reductions>");
|
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++)
|
for (i = 0; i < max_user_token_number + 1; i++)
|
||||||
if (token_translations[i] != undeftoken->number)
|
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;
|
int precedence = symbols[token_translations[i]]->prec;
|
||||||
assoc associativity = symbols[token_translations[i]]->assoc;
|
assoc associativity = symbols[token_translations[i]]->assoc;
|
||||||
xml_indent (out, level + 2);
|
xml_indent (out, level + 2);
|
||||||
@@ -414,9 +414,9 @@ print_grammar (FILE *out, int level)
|
|||||||
{
|
{
|
||||||
char const *tag = symbols[i]->tag;
|
char const *tag = symbols[i]->tag;
|
||||||
xml_printf (out, level + 2,
|
xml_printf (out, level + 2,
|
||||||
"<nonterminal symbol-number=\"%d\" name=\"%s\""
|
"<nonterminal symbol-number=\"%d\" name=\"%s\""
|
||||||
" usefulness=\"%s\"/>",
|
" usefulness=\"%s\"/>",
|
||||||
i, xml_escape (tag),
|
i, xml_escape (tag),
|
||||||
reduce_nonterminal_useless_in_grammar (i)
|
reduce_nonterminal_useless_in_grammar (i)
|
||||||
? "useless-in-grammar" : "useful");
|
? "useless-in-grammar" : "useful");
|
||||||
}
|
}
|
||||||
@@ -512,7 +512,7 @@ print_xml (void)
|
|||||||
|
|
||||||
fputc ('\n', out);
|
fputc ('\n', out);
|
||||||
xml_printf (out, level + 1, "<filename>%s</filename>",
|
xml_printf (out, level + 1, "<filename>%s</filename>",
|
||||||
xml_escape (grammar_file));
|
xml_escape (grammar_file));
|
||||||
|
|
||||||
/* print grammar */
|
/* print grammar */
|
||||||
print_grammar (out, level + 1);
|
print_grammar (out, level + 1);
|
||||||
|
|||||||
248
src/print.c
248
src/print.c
@@ -97,7 +97,7 @@ print_core (FILE *out, state *s)
|
|||||||
sp1 = sp = ritem + sitems[i];
|
sp1 = sp = ritem + sitems[i];
|
||||||
|
|
||||||
while (*sp >= 0)
|
while (*sp >= 0)
|
||||||
sp++;
|
sp++;
|
||||||
|
|
||||||
r = item_number_as_rule_number (*sp);
|
r = item_number_as_rule_number (*sp);
|
||||||
|
|
||||||
@@ -105,15 +105,15 @@ print_core (FILE *out, state *s)
|
|||||||
previous_lhs = rules[r].lhs;
|
previous_lhs = rules[r].lhs;
|
||||||
|
|
||||||
for (sp = rules[r].rhs; sp < sp1; sp++)
|
for (sp = rules[r].rhs; sp < sp1; sp++)
|
||||||
fprintf (out, " %s", symbols[*sp]->tag);
|
fprintf (out, " %s", symbols[*sp]->tag);
|
||||||
fputs (" .", out);
|
fputs (" .", out);
|
||||||
for (/* Nothing */; *sp >= 0; ++sp)
|
for (/* Nothing */; *sp >= 0; ++sp)
|
||||||
fprintf (out, " %s", symbols[*sp]->tag);
|
fprintf (out, " %s", symbols[*sp]->tag);
|
||||||
|
|
||||||
/* Display the lookahead tokens? */
|
/* Display the lookahead tokens? */
|
||||||
if (report_flag & report_lookahead_tokens
|
if (report_flag & report_lookahead_tokens
|
||||||
&& item_number_is_rule_number (*sp1))
|
&& 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);
|
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. */
|
/* Compute the width of the lookahead token column. */
|
||||||
for (i = 0; i < trans->num; i++)
|
for (i = 0; i < trans->num; i++)
|
||||||
if (!TRANSITION_IS_DISABLED (trans, 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)];
|
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
||||||
max_length (&width, sym->tag);
|
max_length (&width, sym->tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Nothing to report. */
|
/* Nothing to report. */
|
||||||
@@ -151,20 +151,20 @@ print_transitions (state *s, FILE *out, bool display_transitions_p)
|
|||||||
/* Report lookahead tokens and shifts. */
|
/* Report lookahead tokens and shifts. */
|
||||||
for (i = 0; i < trans->num; i++)
|
for (i = 0; i < trans->num; i++)
|
||||||
if (!TRANSITION_IS_DISABLED (trans, 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)];
|
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
||||||
const char *tag = sym->tag;
|
const char *tag = sym->tag;
|
||||||
state *s1 = trans->states[i];
|
state *s1 = trans->states[i];
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
fprintf (out, " %s", tag);
|
fprintf (out, " %s", tag);
|
||||||
for (j = width - strlen (tag); j > 0; --j)
|
for (j = width - strlen (tag); j > 0; --j)
|
||||||
fputc (' ', out);
|
fputc (' ', out);
|
||||||
if (display_transitions_p)
|
if (display_transitions_p)
|
||||||
fprintf (out, _("shift, and go to state %d\n"), s1->number);
|
fprintf (out, _("shift, and go to state %d\n"), s1->number);
|
||||||
else
|
else
|
||||||
fprintf (out, _("go to state %d\n"), s1->number);
|
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)
|
for (i = 0; i < errp->num; ++i)
|
||||||
if (errp->symbols[i])
|
if (errp->symbols[i])
|
||||||
{
|
{
|
||||||
const char *tag = errp->symbols[i]->tag;
|
const char *tag = errp->symbols[i]->tag;
|
||||||
int j;
|
int j;
|
||||||
fprintf (out, " %s", tag);
|
fprintf (out, " %s", tag);
|
||||||
for (j = width - strlen (tag); j > 0; --j)
|
for (j = width - strlen (tag); j > 0; --j)
|
||||||
fputc (' ', out);
|
fputc (' ', out);
|
||||||
fputs (_("error (nonassociative)\n"), out);
|
fputs (_("error (nonassociative)\n"), out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,8 +214,8 @@ print_errs (FILE *out, state *s)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
print_reduction (FILE *out, size_t width,
|
print_reduction (FILE *out, size_t width,
|
||||||
const char *lookahead_token,
|
const char *lookahead_token,
|
||||||
rule *r, bool enabled)
|
rule *r, bool enabled)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
fprintf (out, " %s", lookahead_token);
|
fprintf (out, " %s", lookahead_token);
|
||||||
@@ -267,22 +267,22 @@ print_reductions (FILE *out, state *s)
|
|||||||
if (reds->lookahead_tokens)
|
if (reds->lookahead_tokens)
|
||||||
for (i = 0; i < ntokens; i++)
|
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)
|
for (j = 0; j < reds->num; ++j)
|
||||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||||
{
|
{
|
||||||
if (! count)
|
if (! count)
|
||||||
{
|
{
|
||||||
if (reds->rules[j] != default_reduction)
|
if (reds->rules[j] != default_reduction)
|
||||||
max_length (&width, symbols[i]->tag);
|
max_length (&width, symbols[i]->tag);
|
||||||
count = true;
|
count = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
max_length (&width, symbols[i]->tag);
|
max_length (&width, symbols[i]->tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Nothing to report. */
|
/* Nothing to report. */
|
||||||
@@ -296,40 +296,40 @@ print_reductions (FILE *out, state *s)
|
|||||||
if (reds->lookahead_tokens)
|
if (reds->lookahead_tokens)
|
||||||
for (i = 0; i < ntokens; i++)
|
for (i = 0; i < ntokens; i++)
|
||||||
{
|
{
|
||||||
bool defaulted = false;
|
bool defaulted = false;
|
||||||
bool count = bitset_test (no_reduce_set, i);
|
bool count = bitset_test (no_reduce_set, i);
|
||||||
if (count)
|
if (count)
|
||||||
default_reduction_only = false;
|
default_reduction_only = false;
|
||||||
|
|
||||||
for (j = 0; j < reds->num; ++j)
|
for (j = 0; j < reds->num; ++j)
|
||||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||||
{
|
{
|
||||||
if (! count)
|
if (! count)
|
||||||
{
|
{
|
||||||
if (reds->rules[j] != default_reduction)
|
if (reds->rules[j] != default_reduction)
|
||||||
{
|
{
|
||||||
default_reduction_only = false;
|
default_reduction_only = false;
|
||||||
print_reduction (out, width,
|
print_reduction (out, width,
|
||||||
symbols[i]->tag,
|
symbols[i]->tag,
|
||||||
reds->rules[j], true);
|
reds->rules[j], true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
defaulted = true;
|
defaulted = true;
|
||||||
count = true;
|
count = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
default_reduction_only = false;
|
default_reduction_only = false;
|
||||||
if (defaulted)
|
if (defaulted)
|
||||||
print_reduction (out, width,
|
print_reduction (out, width,
|
||||||
symbols[i]->tag,
|
symbols[i]->tag,
|
||||||
default_reduction, true);
|
default_reduction, true);
|
||||||
defaulted = false;
|
defaulted = false;
|
||||||
print_reduction (out, width,
|
print_reduction (out, width,
|
||||||
symbols[i]->tag,
|
symbols[i]->tag,
|
||||||
reds->rules[j], false);
|
reds->rules[j], false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (default_reduction)
|
if (default_reduction)
|
||||||
@@ -411,25 +411,25 @@ print_grammar (FILE *out)
|
|||||||
for (i = 0; i < max_user_token_number + 1; i++)
|
for (i = 0; i < max_user_token_number + 1; i++)
|
||||||
if (token_translations[i] != undeftoken->number)
|
if (token_translations[i] != undeftoken->number)
|
||||||
{
|
{
|
||||||
const char *tag = symbols[token_translations[i]]->tag;
|
const char *tag = symbols[token_translations[i]]->tag;
|
||||||
rule_number r;
|
rule_number r;
|
||||||
item_number *rhsp;
|
item_number *rhsp;
|
||||||
|
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
column = strlen (tag);
|
column = strlen (tag);
|
||||||
fputs (tag, out);
|
fputs (tag, out);
|
||||||
END_TEST (65);
|
END_TEST (65);
|
||||||
sprintf (buffer, " (%d)", i);
|
sprintf (buffer, " (%d)", i);
|
||||||
|
|
||||||
for (r = 0; r < nrules; r++)
|
for (r = 0; r < nrules; r++)
|
||||||
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
|
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
|
||||||
if (item_number_as_symbol_number (*rhsp) == token_translations[i])
|
if (item_number_as_symbol_number (*rhsp) == token_translations[i])
|
||||||
{
|
{
|
||||||
END_TEST (65);
|
END_TEST (65);
|
||||||
sprintf (buffer + strlen (buffer), " %d", r);
|
sprintf (buffer + strlen (buffer), " %d", r);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fprintf (out, "%s\n", buffer);
|
fprintf (out, "%s\n", buffer);
|
||||||
}
|
}
|
||||||
fputs ("\n\n", out);
|
fputs ("\n\n", out);
|
||||||
|
|
||||||
@@ -442,17 +442,17 @@ print_grammar (FILE *out)
|
|||||||
const char *tag = symbols[i]->tag;
|
const char *tag = symbols[i]->tag;
|
||||||
|
|
||||||
for (r = 0; r < nrules; r++)
|
for (r = 0; r < nrules; r++)
|
||||||
{
|
{
|
||||||
item_number *rhsp;
|
item_number *rhsp;
|
||||||
if (rules[r].lhs->number == i)
|
if (rules[r].lhs->number == i)
|
||||||
left_count++;
|
left_count++;
|
||||||
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
|
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
|
||||||
if (item_number_as_symbol_number (*rhsp) == i)
|
if (item_number_as_symbol_number (*rhsp) == i)
|
||||||
{
|
{
|
||||||
right_count++;
|
right_count++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
fputs (tag, out);
|
fputs (tag, out);
|
||||||
@@ -461,38 +461,38 @@ print_grammar (FILE *out)
|
|||||||
END_TEST (0);
|
END_TEST (0);
|
||||||
|
|
||||||
if (left_count > 0)
|
if (left_count > 0)
|
||||||
{
|
{
|
||||||
END_TEST (65);
|
END_TEST (65);
|
||||||
sprintf (buffer + strlen (buffer), _(" on left:"));
|
sprintf (buffer + strlen (buffer), _(" on left:"));
|
||||||
|
|
||||||
for (r = 0; r < nrules; r++)
|
for (r = 0; r < nrules; r++)
|
||||||
{
|
{
|
||||||
if (rules[r].lhs->number == i)
|
if (rules[r].lhs->number == i)
|
||||||
{
|
{
|
||||||
END_TEST (65);
|
END_TEST (65);
|
||||||
sprintf (buffer + strlen (buffer), " %d", r);
|
sprintf (buffer + strlen (buffer), " %d", r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (right_count > 0)
|
if (right_count > 0)
|
||||||
{
|
{
|
||||||
if (left_count > 0)
|
if (left_count > 0)
|
||||||
sprintf (buffer + strlen (buffer), ",");
|
sprintf (buffer + strlen (buffer), ",");
|
||||||
END_TEST (65);
|
END_TEST (65);
|
||||||
sprintf (buffer + strlen (buffer), _(" on right:"));
|
sprintf (buffer + strlen (buffer), _(" on right:"));
|
||||||
for (r = 0; r < nrules; r++)
|
for (r = 0; r < nrules; r++)
|
||||||
{
|
{
|
||||||
item_number *rhsp;
|
item_number *rhsp;
|
||||||
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
|
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
|
||||||
if (item_number_as_symbol_number (*rhsp) == i)
|
if (item_number_as_symbol_number (*rhsp) == i)
|
||||||
{
|
{
|
||||||
END_TEST (65);
|
END_TEST (65);
|
||||||
sprintf (buffer + strlen (buffer), " %d", r);
|
sprintf (buffer + strlen (buffer), " %d", r);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf (out, "%s\n", buffer);
|
fprintf (out, "%s\n", buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -508,7 +508,7 @@ print_results (void)
|
|||||||
|
|
||||||
reduce_output (out);
|
reduce_output (out);
|
||||||
grammar_rules_partial_print (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);
|
rule_useless_in_parser_p);
|
||||||
conflicts_output (out);
|
conflicts_output (out);
|
||||||
|
|
||||||
|
|||||||
@@ -66,43 +66,43 @@ print_core (struct obstack *oout, state *s)
|
|||||||
sp1 = sp = ritem + sitems[i];
|
sp1 = sp = ritem + sitems[i];
|
||||||
|
|
||||||
while (*sp >= 0)
|
while (*sp >= 0)
|
||||||
sp++;
|
sp++;
|
||||||
|
|
||||||
r = item_number_as_rule_number (*sp);
|
r = item_number_as_rule_number (*sp);
|
||||||
|
|
||||||
obstack_fgrow1 (oout, "\n%s -> ", rules[r].lhs->tag);
|
obstack_fgrow1 (oout, "\n%s -> ", rules[r].lhs->tag);
|
||||||
|
|
||||||
for (sp = rules[r].rhs; sp < sp1; sp++)
|
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, '.');
|
obstack_1grow (oout, '.');
|
||||||
|
|
||||||
for (/* Nothing */; *sp >= 0; ++sp)
|
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. */
|
/* Experimental feature: display the lookahead tokens. */
|
||||||
if (report_flag & report_lookahead_tokens
|
if (report_flag & report_lookahead_tokens
|
||||||
&& item_number_is_rule_number (*sp1))
|
&& item_number_is_rule_number (*sp1))
|
||||||
{
|
{
|
||||||
/* Find the reduction we are handling. */
|
/* Find the reduction we are handling. */
|
||||||
reductions *reds = s->reductions;
|
reductions *reds = s->reductions;
|
||||||
int redno = state_reduction_find (s, &rules[r]);
|
int redno = state_reduction_find (s, &rules[r]);
|
||||||
|
|
||||||
/* Print them if there are. */
|
/* Print them if there are. */
|
||||||
if (reds->lookahead_tokens && redno != -1)
|
if (reds->lookahead_tokens && redno != -1)
|
||||||
{
|
{
|
||||||
bitset_iterator biter;
|
bitset_iterator biter;
|
||||||
int k;
|
int k;
|
||||||
char const *sep = "";
|
char const *sep = "";
|
||||||
obstack_sgrow (oout, "[");
|
obstack_sgrow (oout, "[");
|
||||||
BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0)
|
BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0)
|
||||||
{
|
{
|
||||||
obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag);
|
obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag);
|
||||||
sep = ", ";
|
sep = ", ";
|
||||||
}
|
}
|
||||||
obstack_sgrow (oout, "]");
|
obstack_sgrow (oout, "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,21 +125,21 @@ print_actions (state const *s, FILE *fgraph)
|
|||||||
for (i = 0; i < trans->num; i++)
|
for (i = 0; i < trans->num; i++)
|
||||||
if (!TRANSITION_IS_DISABLED (trans, i))
|
if (!TRANSITION_IS_DISABLED (trans, i))
|
||||||
{
|
{
|
||||||
state *s1 = trans->states[i];
|
state *s1 = trans->states[i];
|
||||||
symbol_number sym = s1->accessing_symbol;
|
symbol_number sym = s1->accessing_symbol;
|
||||||
|
|
||||||
/* Shifts are solid, gotos are dashed, and error is dotted. */
|
/* Shifts are solid, gotos are dashed, and error is dotted. */
|
||||||
char const *style =
|
char const *style =
|
||||||
(TRANSITION_IS_ERROR (trans, i) ? "dotted"
|
(TRANSITION_IS_ERROR (trans, i) ? "dotted"
|
||||||
: TRANSITION_IS_SHIFT (trans, i) ? "solid"
|
: TRANSITION_IS_SHIFT (trans, i) ? "solid"
|
||||||
: "dashed");
|
: "dashed");
|
||||||
|
|
||||||
if (TRANSITION_IS_ERROR (trans, i)
|
if (TRANSITION_IS_ERROR (trans, i)
|
||||||
&& strcmp (symbols[sym]->tag, "error") != 0)
|
&& strcmp (symbols[sym]->tag, "error") != 0)
|
||||||
abort ();
|
abort ();
|
||||||
output_edge (s->number, s1->number,
|
output_edge (s->number, s1->number,
|
||||||
TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
|
TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
|
||||||
style, fgraph);
|
style, fgraph);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
102
src/reader.c
102
src/reader.c
@@ -95,7 +95,7 @@ get_merge_function (uniqstr name)
|
|||||||
syms->next = xmalloc (sizeof syms->next[0]);
|
syms->next = xmalloc (sizeof syms->next[0]);
|
||||||
syms->next->name = uniqstr_new (name);
|
syms->next->name = uniqstr_new (name);
|
||||||
/* After all symbol type declarations have been parsed, packgram invokes
|
/* 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->type = NULL;
|
||||||
syms->next->next = NULL;
|
syms->next->next = NULL;
|
||||||
merge_functions = head.next;
|
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))
|
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
|
||||||
{
|
{
|
||||||
complain_at (declaration_loc,
|
complain_at (declaration_loc,
|
||||||
_("result type clash on merge function `%s': <%s> != <%s>"),
|
_("result type clash on merge function `%s': <%s> != <%s>"),
|
||||||
merge_function->name, type, merge_function->type);
|
merge_function->name, type, merge_function->type);
|
||||||
complain_at (merge_function->type_declaration_location,
|
complain_at (merge_function->type_declaration_location,
|
||||||
_("previous declaration"));
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
merge_function->type = uniqstr_new (type);
|
merge_function->type = uniqstr_new (type);
|
||||||
merge_function->type_declaration_location = declaration_loc;
|
merge_function->type_declaration_location = declaration_loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------.
|
/*--------------------------------------.
|
||||||
| Free all merge-function definitions. |
|
| Free all merge-function definitions. |
|
||||||
`--------------------------------------*/
|
`--------------------------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -199,8 +199,8 @@ assign_named_ref (symbol_list *p, named_ref *name)
|
|||||||
if (name->id == sym->tag)
|
if (name->id == sym->tag)
|
||||||
{
|
{
|
||||||
warn_at (name->loc,
|
warn_at (name->loc,
|
||||||
_("duplicated symbol name for %s ignored"),
|
_("duplicated symbol name for %s ignored"),
|
||||||
quote (sym->tag));
|
quote (sym->tag));
|
||||||
named_ref_free (name);
|
named_ref_free (name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -221,7 +221,7 @@ static symbol_list *previous_rule_end = NULL;
|
|||||||
|
|
||||||
void
|
void
|
||||||
grammar_current_rule_begin (symbol *lhs, location loc,
|
grammar_current_rule_begin (symbol *lhs, location loc,
|
||||||
named_ref *lhs_name)
|
named_ref *lhs_name)
|
||||||
{
|
{
|
||||||
symbol_list* p;
|
symbol_list* p;
|
||||||
|
|
||||||
@@ -292,19 +292,19 @@ grammar_rule_check (const symbol_list *r)
|
|||||||
symbol *first_rhs = r->next->content.sym;
|
symbol *first_rhs = r->next->content.sym;
|
||||||
/* If $$ is being set in default way, report if any type mismatch. */
|
/* If $$ is being set in default way, report if any type mismatch. */
|
||||||
if (first_rhs)
|
if (first_rhs)
|
||||||
{
|
{
|
||||||
char const *lhs_type = r->content.sym->type_name;
|
char const *lhs_type = r->content.sym->type_name;
|
||||||
const char *rhs_type =
|
const char *rhs_type =
|
||||||
first_rhs->type_name ? first_rhs->type_name : "";
|
first_rhs->type_name ? first_rhs->type_name : "";
|
||||||
if (!UNIQSTR_EQ (lhs_type, rhs_type))
|
if (!UNIQSTR_EQ (lhs_type, rhs_type))
|
||||||
warn_at (r->location,
|
warn_at (r->location,
|
||||||
_("type clash on default action: <%s> != <%s>"),
|
_("type clash on default action: <%s> != <%s>"),
|
||||||
lhs_type, rhs_type);
|
lhs_type, rhs_type);
|
||||||
}
|
}
|
||||||
/* Warn if there is no default for $$ but we need one. */
|
/* Warn if there is no default for $$ but we need one. */
|
||||||
else
|
else
|
||||||
warn_at (r->location,
|
warn_at (r->location,
|
||||||
_("empty rule for typed nonterminal, and no action"));
|
_("empty rule for typed nonterminal, and no action"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that symbol values that should be used are in fact used. */
|
/* 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.code,
|
||||||
current_rule->action_props.location,
|
current_rule->action_props.location,
|
||||||
midrule, 0,
|
midrule, 0,
|
||||||
current_rule->action_props.is_predicate);
|
current_rule->action_props.is_predicate);
|
||||||
code_props_none_init (¤t_rule->action_props);
|
code_props_none_init (¤t_rule->action_props);
|
||||||
|
|
||||||
if (previous_rule_end)
|
if (previous_rule_end)
|
||||||
@@ -463,7 +463,7 @@ grammar_current_rule_merge_set (uniqstr name, location loc)
|
|||||||
|
|
||||||
void
|
void
|
||||||
grammar_current_rule_symbol_append (symbol *sym, location loc,
|
grammar_current_rule_symbol_append (symbol *sym, location loc,
|
||||||
named_ref *name)
|
named_ref *name)
|
||||||
{
|
{
|
||||||
symbol_list *p;
|
symbol_list *p;
|
||||||
if (current_rule->action_props.code)
|
if (current_rule->action_props.code)
|
||||||
@@ -477,7 +477,7 @@ grammar_current_rule_symbol_append (symbol *sym, location loc,
|
|||||||
|
|
||||||
void
|
void
|
||||||
grammar_current_rule_action_append (const char *action, location loc,
|
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)
|
if (current_rule->action_props.code)
|
||||||
grammar_midrule_action ();
|
grammar_midrule_action ();
|
||||||
@@ -512,7 +512,7 @@ packgram (void)
|
|||||||
int rule_length = 0;
|
int rule_length = 0;
|
||||||
symbol *ruleprec = p->ruleprec;
|
symbol *ruleprec = p->ruleprec;
|
||||||
record_merge_function_type (p->merger, p->content.sym->type_name,
|
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].user_number = ruleno;
|
||||||
rules[ruleno].number = ruleno;
|
rules[ruleno].number = ruleno;
|
||||||
rules[ruleno].lhs = p->content.sym;
|
rules[ruleno].lhs = p->content.sym;
|
||||||
@@ -528,47 +528,47 @@ packgram (void)
|
|||||||
rules[ruleno].is_predicate = p->action_props.is_predicate;
|
rules[ruleno].is_predicate = p->action_props.is_predicate;
|
||||||
|
|
||||||
/* If the midrule's $$ is set or its $n is used, remove the `$' from the
|
/* 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
|
symbol name so that it's a user-defined symbol so that the default
|
||||||
%destructor and %printer apply. */
|
%destructor and %printer apply. */
|
||||||
if (p->midrule_parent_rule
|
if (p->midrule_parent_rule
|
||||||
&& (p->action_props.is_value_used
|
&& (p->action_props.is_value_used
|
||||||
|| symbol_list_n_get (p->midrule_parent_rule,
|
|| symbol_list_n_get (p->midrule_parent_rule,
|
||||||
p->midrule_parent_rhs_index)
|
p->midrule_parent_rhs_index)
|
||||||
->action_props.is_value_used))
|
->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
|
/* Don't check the generated rule 0. It has no action, so some rhs
|
||||||
symbols may appear unused, but the parsing algorithm ensures that
|
symbols may appear unused, but the parsing algorithm ensures that
|
||||||
%destructor's are invoked appropriately. */
|
%destructor's are invoked appropriately. */
|
||||||
if (p != grammar)
|
if (p != grammar)
|
||||||
grammar_rule_check (p);
|
grammar_rule_check (p);
|
||||||
|
|
||||||
for (p = p->next; p && p->content.sym; p = p->next)
|
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
|
/* Don't allow rule_length == INT_MAX, since that might
|
||||||
cause confusion with strtol if INT_MAX == LONG_MAX. */
|
cause confusion with strtol if INT_MAX == LONG_MAX. */
|
||||||
if (rule_length == INT_MAX)
|
if (rule_length == INT_MAX)
|
||||||
fatal_at (rules[ruleno].location, _("rule is too long"));
|
fatal_at (rules[ruleno].location, _("rule is too long"));
|
||||||
|
|
||||||
/* item_number = symbol_number.
|
/* item_number = symbol_number.
|
||||||
But the former needs to contain more: negative rule numbers. */
|
But the former needs to contain more: negative rule numbers. */
|
||||||
ritem[itemno++] =
|
ritem[itemno++] =
|
||||||
symbol_number_as_item_number (p->content.sym->number);
|
symbol_number_as_item_number (p->content.sym->number);
|
||||||
/* A rule gets by default the precedence and associativity
|
/* A rule gets by default the precedence and associativity
|
||||||
of its last token. */
|
of its last token. */
|
||||||
if (p->content.sym->class == token_sym && default_prec)
|
if (p->content.sym->class == token_sym && default_prec)
|
||||||
rules[ruleno].prec = p->content.sym;
|
rules[ruleno].prec = p->content.sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this rule has a %prec,
|
/* If this rule has a %prec,
|
||||||
the specified symbol's precedence replaces the default. */
|
the specified symbol's precedence replaces the default. */
|
||||||
if (ruleprec)
|
if (ruleprec)
|
||||||
{
|
{
|
||||||
rules[ruleno].precsym = ruleprec;
|
rules[ruleno].precsym = ruleprec;
|
||||||
rules[ruleno].prec = ruleprec;
|
rules[ruleno].prec = ruleprec;
|
||||||
}
|
}
|
||||||
/* An item ends by the rule number (negated). */
|
/* An item ends by the rule number (negated). */
|
||||||
ritem[itemno++] = rule_number_as_item_number (ruleno);
|
ritem[itemno++] = rule_number_as_item_number (ruleno);
|
||||||
aver (itemno < ITEM_NUMBER_MAX);
|
aver (itemno < ITEM_NUMBER_MAX);
|
||||||
@@ -576,7 +576,7 @@ packgram (void)
|
|||||||
aver (ruleno < RULE_NUMBER_MAX);
|
aver (ruleno < RULE_NUMBER_MAX);
|
||||||
|
|
||||||
if (p)
|
if (p)
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
aver (itemno == nritems);
|
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 |
|
| Check the grammar that has just been read, and convert it to |
|
||||||
| internal form. |
|
| internal form. |
|
||||||
`-------------------------------------------------------------*/
|
`-------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -44,16 +44,16 @@ char const *token_name (int type);
|
|||||||
/* From reader.c. */
|
/* From reader.c. */
|
||||||
void grammar_start_symbol_set (symbol *sym, location loc);
|
void grammar_start_symbol_set (symbol *sym, location loc);
|
||||||
void grammar_current_rule_begin (symbol *lhs, 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_current_rule_end (location loc);
|
||||||
void grammar_midrule_action (void);
|
void grammar_midrule_action (void);
|
||||||
void grammar_current_rule_prec_set (symbol *precsym, location loc);
|
void grammar_current_rule_prec_set (symbol *precsym, location loc);
|
||||||
void grammar_current_rule_dprec_set (int dprec, 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_merge_set (uniqstr name, location loc);
|
||||||
void grammar_current_rule_symbol_append (symbol *sym, 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,
|
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 reader (void);
|
||||||
void free_merger_functions (void);
|
void free_merger_functions (void);
|
||||||
|
|
||||||
|
|||||||
120
src/reduce.c
120
src/reduce.c
@@ -115,14 +115,14 @@ useless_nonterminals (void)
|
|||||||
{
|
{
|
||||||
bitset_copy (Np, N);
|
bitset_copy (Np, N);
|
||||||
for (r = 0; r < nrules; r++)
|
for (r = 0; r < nrules; r++)
|
||||||
if (!bitset_test (P, r)
|
if (!bitset_test (P, r)
|
||||||
&& useful_production (r, N))
|
&& useful_production (r, N))
|
||||||
{
|
{
|
||||||
bitset_set (Np, rules[r].lhs->number - ntokens);
|
bitset_set (Np, rules[r].lhs->number - ntokens);
|
||||||
bitset_set (P, r);
|
bitset_set (P, r);
|
||||||
}
|
}
|
||||||
if (bitset_equal_p (N, Np))
|
if (bitset_equal_p (N, Np))
|
||||||
break;
|
break;
|
||||||
Ns = Np;
|
Ns = Np;
|
||||||
Np = N;
|
Np = N;
|
||||||
N = Ns;
|
N = Ns;
|
||||||
@@ -169,37 +169,37 @@ inaccessable_symbols (void)
|
|||||||
bitset_set (V, accept->number);
|
bitset_set (V, accept->number);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
rule_number r;
|
rule_number r;
|
||||||
bitset_copy (Vp, V);
|
bitset_copy (Vp, V);
|
||||||
for (r = 0; r < nrules; r++)
|
for (r = 0; r < nrules; r++)
|
||||||
{
|
{
|
||||||
if (!bitset_test (Pp, r)
|
if (!bitset_test (Pp, r)
|
||||||
&& bitset_test (P, r)
|
&& bitset_test (P, r)
|
||||||
&& bitset_test (V, rules[r].lhs->number))
|
&& bitset_test (V, rules[r].lhs->number))
|
||||||
{
|
{
|
||||||
item_number *rhsp;
|
item_number *rhsp;
|
||||||
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
|
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
|
||||||
if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens))
|
if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens))
|
||||||
bitset_set (Vp, *rhsp);
|
bitset_set (Vp, *rhsp);
|
||||||
bitset_set (Pp, r);
|
bitset_set (Pp, r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bitset_equal_p (V, Vp))
|
if (bitset_equal_p (V, Vp))
|
||||||
break;
|
break;
|
||||||
Vs = Vp;
|
Vs = Vp;
|
||||||
Vp = V;
|
Vp = V;
|
||||||
V = Vs;
|
V = Vs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bitset_free (V);
|
bitset_free (V);
|
||||||
V = Vp;
|
V = Vp;
|
||||||
|
|
||||||
/* Tokens 0, 1, and 2 are internal to Bison. Consider them useful. */
|
/* Tokens 0, 1, and 2 are internal to Bison. Consider them useful. */
|
||||||
bitset_set (V, endtoken->number); /* end-of-input token */
|
bitset_set (V, endtoken->number); /* end-of-input token */
|
||||||
bitset_set (V, errtoken->number); /* error token */
|
bitset_set (V, errtoken->number); /* error token */
|
||||||
bitset_set (V, undeftoken->number); /* some undefined token */
|
bitset_set (V, undeftoken->number); /* some undefined token */
|
||||||
|
|
||||||
bitset_free (P);
|
bitset_free (P);
|
||||||
P = Pp;
|
P = Pp;
|
||||||
@@ -212,7 +212,7 @@ inaccessable_symbols (void)
|
|||||||
symbol_number i;
|
symbol_number i;
|
||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
if (bitset_test (V, i))
|
if (bitset_test (V, i))
|
||||||
nuseful_nonterminals++;
|
nuseful_nonterminals++;
|
||||||
}
|
}
|
||||||
nuseless_nonterminals = nvars - nuseful_nonterminals;
|
nuseless_nonterminals = nvars - nuseful_nonterminals;
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ inaccessable_symbols (void)
|
|||||||
rule_number r;
|
rule_number r;
|
||||||
for (r = 0; r < nrules; ++r)
|
for (r = 0; r < nrules; ++r)
|
||||||
if (rules[r].precsym != 0)
|
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. */
|
/* Renumber the rules markers in RITEMS. */
|
||||||
for (r = 0; r < nrules; ++r)
|
for (r = 0; r < nrules; ++r)
|
||||||
{
|
{
|
||||||
item_number *rhsp = rules[r].rhs;
|
item_number *rhsp = rules[r].rhs;
|
||||||
for (/* Nothing. */; *rhsp >= 0; ++rhsp)
|
for (/* Nothing. */; *rhsp >= 0; ++rhsp)
|
||||||
/* Nothing. */;
|
/* Nothing. */;
|
||||||
*rhsp = rule_number_as_item_number (r);
|
*rhsp = rule_number_as_item_number (r);
|
||||||
rules[r].number = r;
|
rules[r].number = r;
|
||||||
}
|
}
|
||||||
nrules -= nuseless_productions;
|
nrules -= nuseless_productions;
|
||||||
}
|
}
|
||||||
@@ -272,8 +272,8 @@ reduce_grammar_tables (void)
|
|||||||
int length;
|
int length;
|
||||||
for (r = nrules; r < nrules + nuseless_productions; ++r)
|
for (r = nrules; r < nrules + nuseless_productions; ++r)
|
||||||
{
|
{
|
||||||
length = rule_rhs_length (&rules[r]);
|
length = rule_rhs_length (&rules[r]);
|
||||||
nritems -= length + 1;
|
nritems -= length + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,9 +299,9 @@ nonterminals_reduce (void)
|
|||||||
for (i = ntokens; i < nsyms; i++)
|
for (i = ntokens; i < nsyms; i++)
|
||||||
if (!bitset_test (V, i))
|
if (!bitset_test (V, i))
|
||||||
{
|
{
|
||||||
nontermmap[i - ntokens] = n++;
|
nontermmap[i - ntokens] = n++;
|
||||||
warn_at (symbols[i]->location, _("nonterminal useless in grammar: %s"),
|
warn_at (symbols[i]->location, _("nonterminal useless in grammar: %s"),
|
||||||
symbols[i]->tag);
|
symbols[i]->tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -322,11 +322,11 @@ nonterminals_reduce (void)
|
|||||||
rule_number r;
|
rule_number r;
|
||||||
for (r = 0; r < nrules; ++r)
|
for (r = 0; r < nrules; ++r)
|
||||||
{
|
{
|
||||||
item_number *rhsp;
|
item_number *rhsp;
|
||||||
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
||||||
if (ISVAR (*rhsp))
|
if (ISVAR (*rhsp))
|
||||||
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp
|
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp
|
||||||
- ntokens]);
|
- ntokens]);
|
||||||
}
|
}
|
||||||
accept->number = nontermmap[accept->number - ntokens];
|
accept->number = nontermmap[accept->number - ntokens];
|
||||||
}
|
}
|
||||||
@@ -350,7 +350,7 @@ reduce_output (FILE *out)
|
|||||||
int i;
|
int i;
|
||||||
fprintf (out, "%s\n\n", _("Nonterminals useless in grammar"));
|
fprintf (out, "%s\n\n", _("Nonterminals useless in grammar"));
|
||||||
for (i = 0; i < nuseless_nonterminals; ++i)
|
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);
|
fputs ("\n\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,19 +359,19 @@ reduce_output (FILE *out)
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < ntokens; i++)
|
for (i = 0; i < ntokens; i++)
|
||||||
if (reduce_token_unused_in_grammar (i))
|
if (reduce_token_unused_in_grammar (i))
|
||||||
{
|
{
|
||||||
if (!b)
|
if (!b)
|
||||||
fprintf (out, "%s\n\n", _("Terminals unused in grammar"));
|
fprintf (out, "%s\n\n", _("Terminals unused in grammar"));
|
||||||
b = true;
|
b = true;
|
||||||
fprintf (out, " %s\n", symbols[i]->tag);
|
fprintf (out, " %s\n", symbols[i]->tag);
|
||||||
}
|
}
|
||||||
if (b)
|
if (b)
|
||||||
fputs ("\n\n", out);
|
fputs ("\n\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nuseless_productions > 0)
|
if (nuseless_productions > 0)
|
||||||
grammar_rules_partial_print (out, _("Rules useless in grammar"),
|
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))
|
if (!bitset_test (N, accept->number - ntokens))
|
||||||
fatal_at (startsymbol_location,
|
fatal_at (startsymbol_location,
|
||||||
_("start symbol %s does not derive any sentence"),
|
_("start symbol %s does not derive any sentence"),
|
||||||
startsymbol->tag);
|
startsymbol->tag);
|
||||||
|
|
||||||
/* First reduce the nonterminals, as they renumber themselves in the
|
/* First reduce the nonterminals, as they renumber themselves in the
|
||||||
whole grammar. If you change the order, nonterms would be
|
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\
|
fprintf (stderr, "reduced %s defines %d terminals, %d nonterminals\
|
||||||
, and %d productions.\n",
|
, and %d productions.\n",
|
||||||
grammar_file, ntokens, nvars, nrules);
|
grammar_file, ntokens, nvars, nrules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ relation_print (relation r, relation_node size, FILE *out)
|
|||||||
{
|
{
|
||||||
fprintf (out, "%3lu: ", (unsigned long int) i);
|
fprintf (out, "%3lu: ", (unsigned long int) i);
|
||||||
if (r[i])
|
if (r[i])
|
||||||
for (j = 0; r[i][j] != END_NODE; ++j)
|
for (j = 0; r[i][j] != END_NODE; ++j)
|
||||||
fprintf (out, "%3lu ", (unsigned long int) r[i][j]);
|
fprintf (out, "%3lu ", (unsigned long int) r[i][j]);
|
||||||
fputc ('\n', out);
|
fputc ('\n', out);
|
||||||
}
|
}
|
||||||
fputc ('\n', out);
|
fputc ('\n', out);
|
||||||
@@ -70,25 +70,25 @@ traverse (relation_node i)
|
|||||||
if (R[i])
|
if (R[i])
|
||||||
for (j = 0; R[i][j] != END_NODE; ++j)
|
for (j = 0; R[i][j] != END_NODE; ++j)
|
||||||
{
|
{
|
||||||
if (INDEX[R[i][j]] == 0)
|
if (INDEX[R[i][j]] == 0)
|
||||||
traverse (R[i][j]);
|
traverse (R[i][j]);
|
||||||
|
|
||||||
if (INDEX[i] > INDEX[R[i][j]])
|
if (INDEX[i] > INDEX[R[i][j]])
|
||||||
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)
|
if (INDEX[i] == height)
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
j = VERTICES[top--];
|
j = VERTICES[top--];
|
||||||
INDEX[j] = infinity;
|
INDEX[j] = infinity;
|
||||||
|
|
||||||
if (i == j)
|
if (i == j)
|
||||||
break;
|
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++)
|
for (i = 0; i < n; i++)
|
||||||
if (r[i])
|
if (r[i])
|
||||||
for (j = 0; r[i][j] != END_NODE; ++j)
|
for (j = 0; r[i][j] != END_NODE; ++j)
|
||||||
++nedges[r[i][j]];
|
++nedges[r[i][j]];
|
||||||
|
|
||||||
/* Allocate. */
|
/* Allocate. */
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
relation_node *sp = NULL;
|
relation_node *sp = NULL;
|
||||||
if (nedges[i] > 0)
|
if (nedges[i] > 0)
|
||||||
{
|
{
|
||||||
sp = xnmalloc (nedges[i] + 1, sizeof *sp);
|
sp = xnmalloc (nedges[i] + 1, sizeof *sp);
|
||||||
sp[nedges[i]] = END_NODE;
|
sp[nedges[i]] = END_NODE;
|
||||||
}
|
}
|
||||||
new_R[i] = sp;
|
new_R[i] = sp;
|
||||||
end_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++)
|
for (i = 0; i < n; i++)
|
||||||
if (r[i])
|
if (r[i])
|
||||||
for (j = 0; r[i][j] != END_NODE; ++j)
|
for (j = 0; r[i][j] != END_NODE; ++j)
|
||||||
*end_R[r[i][j]]++ = i;
|
*end_R[r[i][j]]++ = i;
|
||||||
|
|
||||||
free (nedges);
|
free (nedges);
|
||||||
free (end_R);
|
free (end_R);
|
||||||
|
|||||||
238
src/scan-code.l
238
src/scan-code.l
@@ -48,7 +48,7 @@ YY_DECL;
|
|||||||
#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
|
#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
|
||||||
|
|
||||||
static void handle_action_dollar (symbol_list *rule, char *cp,
|
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);
|
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. */
|
/* 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
|
/* 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
|
historically almost any character is allowed in a tag. We disallow
|
||||||
NUL and newline, as this simplifies our implementation. */
|
NUL and newline, as this simplifies our implementation. */
|
||||||
tag [^\0\n>]+
|
tag [^\0\n>]+
|
||||||
|
|
||||||
/* Zero or more instances of backslash-newline. Following GCC, allow
|
/* Zero or more instances of backslash-newline. Following GCC, allow
|
||||||
white space between the backslash and the newline. */
|
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
|
/* C style identifier. Must start with letter. Will be used for
|
||||||
named symbol references. Shall be kept synchronized with
|
named symbol references. Shall be kept synchronized with
|
||||||
scan-gram.l "letter" and "id". */
|
scan-gram.l "letter" and "id". */
|
||||||
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
|
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
|
||||||
id {letter}({letter}|[-0-9])*
|
id {letter}({letter}|[-0-9])*
|
||||||
ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@@ -112,8 +112,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
|||||||
is expected to return only once. This initialization is
|
is expected to return only once. This initialization is
|
||||||
therefore done once per action to translate. */
|
therefore done once per action to translate. */
|
||||||
aver (sc_context == SC_SYMBOL_ACTION
|
aver (sc_context == SC_SYMBOL_ACTION
|
||||||
|| sc_context == SC_RULE_ACTION
|
|| sc_context == SC_RULE_ACTION
|
||||||
|| sc_context == INITIAL);
|
|| sc_context == INITIAL);
|
||||||
BEGIN sc_context;
|
BEGIN sc_context;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -133,8 +133,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
|||||||
|
|
||||||
<SC_LINE_COMMENT>
|
<SC_LINE_COMMENT>
|
||||||
{
|
{
|
||||||
"\n" STRING_GROW; BEGIN sc_context;
|
"\n" STRING_GROW; BEGIN sc_context;
|
||||||
{splice} STRING_GROW;
|
{splice} STRING_GROW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -144,17 +144,17 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
|||||||
|
|
||||||
<SC_CHARACTER,SC_STRING>
|
<SC_CHARACTER,SC_STRING>
|
||||||
{
|
{
|
||||||
{splice}|\\{splice}. STRING_GROW;
|
{splice}|\\{splice}. STRING_GROW;
|
||||||
}
|
}
|
||||||
|
|
||||||
<SC_CHARACTER>
|
<SC_CHARACTER>
|
||||||
{
|
{
|
||||||
"'" STRING_GROW; BEGIN sc_context;
|
"'" STRING_GROW; BEGIN sc_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
<SC_STRING>
|
<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
|
if (outer_brace && !yacc_flag && language_prio == default_prio
|
||||||
&& skeleton_prio == default_prio && need_semicolon && ! in_cpp)
|
&& skeleton_prio == default_prio && need_semicolon && ! in_cpp)
|
||||||
{
|
{
|
||||||
warn_at (*loc, _("a `;' might be needed at the end of action code"));
|
warn_at (*loc, _("a `;' might be needed at the end of action code"));
|
||||||
warn_at (*loc, _("future versions of Bison will not add the `;'"));
|
warn_at (*loc, _("future versions of Bison will not add the `;'"));
|
||||||
obstack_1grow (&obstack_for_string, ';');
|
obstack_1grow (&obstack_for_string, ';');
|
||||||
}
|
}
|
||||||
|
|
||||||
STRING_GROW;
|
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. |
|
| By default, grow the string obstack with the input. |
|
||||||
`-----------------------------------------------------*/
|
`-----------------------------------------------------*/
|
||||||
|
|
||||||
<*>.|\n STRING_GROW;
|
<*>.|\n STRING_GROW;
|
||||||
|
|
||||||
/* End of processing. */
|
/* End of processing. */
|
||||||
<*><<EOF>> {
|
<*><<EOF>> {
|
||||||
STRING_FINISH;
|
STRING_FINISH;
|
||||||
return last_string;
|
return last_string;
|
||||||
}
|
}
|
||||||
@@ -357,9 +357,9 @@ variant_table_grow (void)
|
|||||||
if (variant_count > variant_table_size)
|
if (variant_count > variant_table_size)
|
||||||
{
|
{
|
||||||
while (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,
|
variant_table = xnrealloc (variant_table, variant_table_size,
|
||||||
sizeof *variant_table);
|
sizeof *variant_table);
|
||||||
}
|
}
|
||||||
return &variant_table[variant_count - 1];
|
return &variant_table[variant_count - 1];
|
||||||
}
|
}
|
||||||
@@ -389,7 +389,7 @@ find_prefix_end (const char *prefix, char *begin, char *end)
|
|||||||
|
|
||||||
static variant *
|
static variant *
|
||||||
variant_add (uniqstr id, location id_loc, unsigned symbol_index,
|
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;
|
char *prefix_end;
|
||||||
|
|
||||||
@@ -443,53 +443,53 @@ show_sub_messages (const char* cp, bool explicit_bracketing,
|
|||||||
dollar_or_at, var->id, at_spec);
|
dollar_or_at, var->id, at_spec);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
static struct obstack msg_buf;
|
static struct obstack msg_buf;
|
||||||
const char *tail = explicit_bracketing ? "" :
|
const char *tail = explicit_bracketing ? "" :
|
||||||
cp + strlen (var->id);
|
cp + strlen (var->id);
|
||||||
const char *id = var->hidden_by ? var->hidden_by->id :
|
const char *id = var->hidden_by ? var->hidden_by->id :
|
||||||
var->id;
|
var->id;
|
||||||
location id_loc = var->hidden_by ? var->hidden_by->loc :
|
location id_loc = var->hidden_by ? var->hidden_by->loc :
|
||||||
var->loc;
|
var->loc;
|
||||||
|
|
||||||
/* Create the explanation message. */
|
/* Create the explanation message. */
|
||||||
obstack_init (&msg_buf);
|
obstack_init (&msg_buf);
|
||||||
|
|
||||||
obstack_fgrow1 (&msg_buf, _("possibly meant: %c"), dollar_or_at);
|
obstack_fgrow1 (&msg_buf, _("possibly meant: %c"), dollar_or_at);
|
||||||
if (contains_dot_or_dash (id))
|
if (contains_dot_or_dash (id))
|
||||||
obstack_fgrow1 (&msg_buf, "[%s]", id);
|
obstack_fgrow1 (&msg_buf, "[%s]", id);
|
||||||
else
|
else
|
||||||
obstack_sgrow (&msg_buf, id);
|
obstack_sgrow (&msg_buf, id);
|
||||||
obstack_sgrow (&msg_buf, tail);
|
obstack_sgrow (&msg_buf, tail);
|
||||||
|
|
||||||
if (var->err & VARIANT_HIDDEN)
|
if (var->err & VARIANT_HIDDEN)
|
||||||
{
|
{
|
||||||
obstack_fgrow1 (&msg_buf, _(", hiding %c"), dollar_or_at);
|
obstack_fgrow1 (&msg_buf, _(", hiding %c"), dollar_or_at);
|
||||||
if (contains_dot_or_dash (var->id))
|
if (contains_dot_or_dash (var->id))
|
||||||
obstack_fgrow1 (&msg_buf, "[%s]", var->id);
|
obstack_fgrow1 (&msg_buf, "[%s]", var->id);
|
||||||
else
|
else
|
||||||
obstack_sgrow (&msg_buf, var->id);
|
obstack_sgrow (&msg_buf, var->id);
|
||||||
obstack_sgrow (&msg_buf, tail);
|
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 =
|
const char *format =
|
||||||
_(", cannot be accessed from mid-rule action at $%d");
|
_(", cannot be accessed from mid-rule action at $%d");
|
||||||
obstack_fgrow1 (&msg_buf, format, midrule_rhs_index);
|
obstack_fgrow1 (&msg_buf, format, midrule_rhs_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
obstack_1grow (&msg_buf, '\0');
|
obstack_1grow (&msg_buf, '\0');
|
||||||
if (is_warning)
|
if (is_warning)
|
||||||
warn_at_indent (id_loc, &indent, "%s",
|
warn_at_indent (id_loc, &indent, "%s",
|
||||||
(char *) obstack_finish (&msg_buf));
|
(char *) obstack_finish (&msg_buf));
|
||||||
else
|
else
|
||||||
complain_at_indent (id_loc, &indent, "%s",
|
complain_at_indent (id_loc, &indent, "%s",
|
||||||
(char *) obstack_finish (&msg_buf));
|
(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. */
|
accesses. */
|
||||||
static long int
|
static long int
|
||||||
parse_ref (char *cp, symbol_list *rule, int rule_length,
|
parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||||
int midrule_rhs_index, char *text, location text_loc,
|
int midrule_rhs_index, char *text, location text_loc,
|
||||||
char dollar_or_at)
|
char dollar_or_at)
|
||||||
{
|
{
|
||||||
symbol_list *l;
|
symbol_list *l;
|
||||||
char *cp_end;
|
char *cp_end;
|
||||||
@@ -526,13 +526,13 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
|||||||
{
|
{
|
||||||
long int num = strtol (cp, &cp, 10);
|
long int num = strtol (cp, &cp, 10);
|
||||||
if (1 - INT_MAX + rule_length <= num && num <= rule_length)
|
if (1 - INT_MAX + rule_length <= num && num <= rule_length)
|
||||||
return num;
|
return num;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
complain_at (text_loc, _("integer out of range: %s"),
|
complain_at (text_loc, _("integer out of range: %s"),
|
||||||
quote (text));
|
quote (text));
|
||||||
return INVALID_REF;
|
return INVALID_REF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('[' == *cp)
|
if ('[' == *cp)
|
||||||
@@ -540,7 +540,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
|||||||
/* Ignore the brackets. */
|
/* Ignore the brackets. */
|
||||||
char *p;
|
char *p;
|
||||||
for (p = ++cp; *p != ']'; ++p)
|
for (p = ++cp; *p != ']'; ++p)
|
||||||
continue;
|
continue;
|
||||||
cp_end = p;
|
cp_end = p;
|
||||||
|
|
||||||
explicit_bracketing = true;
|
explicit_bracketing = true;
|
||||||
@@ -550,13 +550,13 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
|||||||
/* Take all characters of the name. */
|
/* Take all characters of the name. */
|
||||||
char* p;
|
char* p;
|
||||||
for (p = cp; *p; ++p)
|
for (p = cp; *p; ++p)
|
||||||
if (is_dot_or_dash (*p))
|
if (is_dot_or_dash (*p))
|
||||||
{
|
{
|
||||||
ref_tail_fields = p;
|
ref_tail_fields = p;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (p = cp; *p; ++p)
|
for (p = cp; *p; ++p)
|
||||||
continue;
|
continue;
|
||||||
cp_end = p;
|
cp_end = p;
|
||||||
|
|
||||||
explicit_bracketing = false;
|
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);
|
for (symbol_index = 0, l = rule; !symbol_list_null (l);
|
||||||
++symbol_index, l = l->next)
|
++symbol_index, l = l->next)
|
||||||
{
|
{
|
||||||
variant *var;
|
variant *var;
|
||||||
if (l->content_type != SYMLIST_SYMBOL)
|
if (l->content_type != SYMLIST_SYMBOL)
|
||||||
continue;
|
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);
|
symbol_index, cp, cp_end, explicit_bracketing);
|
||||||
if (var && l->named_ref)
|
if (var && l->named_ref)
|
||||||
var->hidden_by = l->named_ref;
|
var->hidden_by = l->named_ref;
|
||||||
|
|
||||||
if (l->named_ref)
|
if (l->named_ref)
|
||||||
variant_add (l->named_ref->id, l->named_ref->loc,
|
variant_add (l->named_ref->id, l->named_ref->loc,
|
||||||
symbol_index, cp, cp_end, explicit_bracketing);
|
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. */
|
/* Check visibility from mid-rule actions. */
|
||||||
if (midrule_rhs_index != 0
|
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;
|
var->err |= VARIANT_NOT_VISIBLE_FROM_MIDRULE;
|
||||||
|
|
||||||
/* Check correct bracketing. */
|
/* Check correct bracketing. */
|
||||||
@@ -723,19 +723,19 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
|||||||
{
|
{
|
||||||
type_name = ++cp;
|
type_name = ++cp;
|
||||||
while (*cp != '>')
|
while (*cp != '>')
|
||||||
++cp;
|
++cp;
|
||||||
|
|
||||||
/* The '>' symbol will be later replaced by '\0'. Original
|
/* The '>' symbol will be later replaced by '\0'. Original
|
||||||
'text' is needed for error messages. */
|
'text' is needed for error messages. */
|
||||||
gt_ptr = cp;
|
gt_ptr = cp;
|
||||||
++cp;
|
++cp;
|
||||||
if (untyped_var_seen)
|
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;
|
tag_seen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = parse_ref (cp, effective_rule, effective_rule_length,
|
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)
|
if (gt_ptr)
|
||||||
*gt_ptr = '\0';
|
*gt_ptr = '\0';
|
||||||
@@ -747,54 +747,54 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
|||||||
|
|
||||||
case LHS_REF:
|
case LHS_REF:
|
||||||
if (!type_name)
|
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 (!type_name)
|
||||||
{
|
{
|
||||||
if (union_seen | tag_seen)
|
if (union_seen | tag_seen)
|
||||||
{
|
{
|
||||||
if (rule->midrule_parent_rule)
|
if (rule->midrule_parent_rule)
|
||||||
complain_at (dollar_loc,
|
complain_at (dollar_loc,
|
||||||
_("$$ for the midrule at $%d of `%s'"
|
_("$$ for the midrule at $%d of `%s'"
|
||||||
" has no declared type"),
|
" has no declared type"),
|
||||||
rule->midrule_parent_rhs_index,
|
rule->midrule_parent_rhs_index,
|
||||||
effective_rule->content.sym->tag);
|
effective_rule->content.sym->tag);
|
||||||
else
|
else
|
||||||
complain_at (dollar_loc, _("$$ of `%s' has no declared type"),
|
complain_at (dollar_loc, _("$$ of `%s' has no declared type"),
|
||||||
rule->content.sym->tag);
|
rule->content.sym->tag);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
untyped_var_seen = true;
|
untyped_var_seen = true;
|
||||||
type_name = "";
|
type_name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
obstack_fgrow1 (&obstack_for_string,
|
obstack_fgrow1 (&obstack_for_string,
|
||||||
"]b4_lhs_value([%s])[", type_name);
|
"]b4_lhs_value([%s])[", type_name);
|
||||||
rule->action_props.is_value_used = true;
|
rule->action_props.is_value_used = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (max_left_semantic_context < 1 - n)
|
if (max_left_semantic_context < 1 - n)
|
||||||
max_left_semantic_context = 1 - n;
|
max_left_semantic_context = 1 - n;
|
||||||
if (!type_name && 0 < n)
|
if (!type_name && 0 < n)
|
||||||
type_name =
|
type_name =
|
||||||
symbol_list_n_type_name_get (effective_rule, dollar_loc, n);
|
symbol_list_n_type_name_get (effective_rule, dollar_loc, n);
|
||||||
if (!type_name)
|
if (!type_name)
|
||||||
{
|
{
|
||||||
if (union_seen | tag_seen)
|
if (union_seen | tag_seen)
|
||||||
complain_at (dollar_loc, _("$%s of `%s' has no declared type"),
|
complain_at (dollar_loc, _("$%s of `%s' has no declared type"),
|
||||||
cp, effective_rule->content.sym->tag);
|
cp, effective_rule->content.sym->tag);
|
||||||
else
|
else
|
||||||
untyped_var_seen = true;
|
untyped_var_seen = true;
|
||||||
type_name = "";
|
type_name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
obstack_fgrow3 (&obstack_for_string,
|
obstack_fgrow3 (&obstack_for_string,
|
||||||
"]b4_rhs_value(%d, %d, [%s])[",
|
"]b4_rhs_value(%d, %d, [%s])[",
|
||||||
effective_rule_length, n, type_name);
|
effective_rule_length, n, type_name);
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
|
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
|
||||||
true;
|
true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -827,7 +827,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
|
|||||||
muscle_percent_define_ensure("locations", at_loc, true);
|
muscle_percent_define_ensure("locations", at_loc, true);
|
||||||
|
|
||||||
n = parse_ref (cp, effective_rule, effective_rule_length,
|
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)
|
switch (n)
|
||||||
{
|
{
|
||||||
case INVALID_REF:
|
case INVALID_REF:
|
||||||
@@ -839,7 +839,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
|
obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
|
||||||
effective_rule_length, n);
|
effective_rule_length, n);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -886,7 +886,7 @@ code_props const code_props_none = CODE_PROPS_NONE_INIT;
|
|||||||
|
|
||||||
void
|
void
|
||||||
code_props_plain_init (code_props *self, char const *code,
|
code_props_plain_init (code_props *self, char const *code,
|
||||||
location code_loc)
|
location code_loc)
|
||||||
{
|
{
|
||||||
self->kind = CODE_PROPS_PLAIN;
|
self->kind = CODE_PROPS_PLAIN;
|
||||||
self->code = code;
|
self->code = code;
|
||||||
@@ -911,7 +911,7 @@ code_props_symbol_action_init (code_props *self, char const *code,
|
|||||||
void
|
void
|
||||||
code_props_rule_action_init (code_props *self, char const *code,
|
code_props_rule_action_init (code_props *self, char const *code,
|
||||||
location code_loc, symbol_list *rule,
|
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->kind = CODE_PROPS_RULE_ACTION;
|
||||||
self->code = code;
|
self->code = code;
|
||||||
|
|||||||
220
src/scan-gram.l
220
src/scan-gram.l
@@ -44,8 +44,8 @@
|
|||||||
|
|
||||||
#define YY_DECL GRAM_LEX_DECL
|
#define YY_DECL GRAM_LEX_DECL
|
||||||
|
|
||||||
#define YY_USER_INIT \
|
#define YY_USER_INIT \
|
||||||
code_start = scanner_cursor = loc->start; \
|
code_start = scanner_cursor = loc->start; \
|
||||||
|
|
||||||
/* Location of scanner cursor. */
|
/* Location of scanner cursor. */
|
||||||
static boundary scanner_cursor;
|
static boundary scanner_cursor;
|
||||||
@@ -69,7 +69,7 @@ static size_t no_cr_read (FILE *, char *, size_t);
|
|||||||
|
|
||||||
#define ROLLBACK_CURRENT_TOKEN \
|
#define ROLLBACK_CURRENT_TOKEN \
|
||||||
do { \
|
do { \
|
||||||
scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0); \
|
scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0); \
|
||||||
yyless (0); \
|
yyless (0); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@@ -118,21 +118,21 @@ static void unexpected_newline (boundary, char const *);
|
|||||||
/* Bracketed identifiers support. */
|
/* Bracketed identifiers support. */
|
||||||
%x SC_BRACKETED_ID SC_RETURN_BRACKETED_ID
|
%x SC_BRACKETED_ID SC_RETURN_BRACKETED_ID
|
||||||
|
|
||||||
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
|
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
|
||||||
id {letter}({letter}|[-0-9])*
|
id {letter}({letter}|[-0-9])*
|
||||||
directive %{id}
|
directive %{id}
|
||||||
int [0-9]+
|
int [0-9]+
|
||||||
|
|
||||||
/* POSIX says that a tag must be both an id and a C union member, but
|
/* 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
|
historically almost any character is allowed in a tag. We disallow
|
||||||
NUL, as this simplifies our implementation. We disallow angle
|
NUL, as this simplifies our implementation. We disallow angle
|
||||||
bracket to match them in nested pairs: several languages use them
|
bracket to match them in nested pairs: several languages use them
|
||||||
for generics/template types. */
|
for generics/template types. */
|
||||||
tag [^\0<>]+
|
tag [^\0<>]+
|
||||||
|
|
||||||
/* Zero or more instances of backslash-newline. Following GCC, allow
|
/* Zero or more instances of backslash-newline. Following GCC, allow
|
||||||
white space between the backslash and the newline. */
|
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>
|
<INITIAL,SC_AFTER_IDENTIFIER,SC_BRACKETED_ID,SC_RETURN_BRACKETED_ID>
|
||||||
{
|
{
|
||||||
/* Comments and white space. */
|
/* Comments and white space. */
|
||||||
"," warn_at (*loc, _("stray `,' treated as white space"));
|
"," warn_at (*loc, _("stray `,' treated as white space"));
|
||||||
[ \f\n\t\v] |
|
[ \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
|
/* For directives that are also command line options, the regex must be
|
||||||
"%..."
|
"%..."
|
||||||
after "[-_]"s are removed, and the directive must match the --long
|
after "[-_]"s are removed, and the directive must match the --long
|
||||||
option name, with a single string argument. Otherwise, add exceptions
|
option name, with a single string argument. Otherwise, add exceptions
|
||||||
to ../build-aux/cross-options.pl. */
|
to ../build-aux/cross-options.pl. */
|
||||||
@@ -269,10 +269,10 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Characters. */
|
/* Characters. */
|
||||||
"'" token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER;
|
"'" token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER;
|
||||||
|
|
||||||
/* Strings. */
|
/* Strings. */
|
||||||
"\"" token_start = loc->start; BEGIN SC_ESCAPED_STRING;
|
"\"" token_start = loc->start; BEGIN SC_ESCAPED_STRING;
|
||||||
|
|
||||||
/* Prologue. */
|
/* Prologue. */
|
||||||
"%{" code_start = loc->start; BEGIN SC_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>
|
<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)
|
if (bracketed_id_str)
|
||||||
{
|
{
|
||||||
ROLLBACK_CURRENT_TOKEN;
|
ROLLBACK_CURRENT_TOKEN;
|
||||||
BEGIN SC_RETURN_BRACKETED_ID;
|
BEGIN SC_RETURN_BRACKETED_ID;
|
||||||
*loc = id_loc;
|
*loc = id_loc;
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bracketed_id_start = loc->start;
|
bracketed_id_start = loc->start;
|
||||||
bracketed_id_context_state = YY_START;
|
bracketed_id_context_state = YY_START;
|
||||||
BEGIN SC_BRACKETED_ID;
|
BEGIN SC_BRACKETED_ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
":" {
|
":" {
|
||||||
@@ -392,33 +392,33 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
{id} {
|
{id} {
|
||||||
if (bracketed_id_str)
|
if (bracketed_id_str)
|
||||||
{
|
{
|
||||||
complain_at (*loc, _("unexpected identifier in bracketed name: %s"),
|
complain_at (*loc, _("unexpected identifier in bracketed name: %s"),
|
||||||
quote (yytext));
|
quote (yytext));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bracketed_id_str = uniqstr_new (yytext);
|
bracketed_id_str = uniqstr_new (yytext);
|
||||||
bracketed_id_loc = *loc;
|
bracketed_id_loc = *loc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"]" {
|
"]" {
|
||||||
BEGIN bracketed_id_context_state;
|
BEGIN bracketed_id_context_state;
|
||||||
if (bracketed_id_str)
|
if (bracketed_id_str)
|
||||||
{
|
{
|
||||||
if (INITIAL == bracketed_id_context_state)
|
if (INITIAL == bracketed_id_context_state)
|
||||||
{
|
{
|
||||||
val->uniqstr = bracketed_id_str;
|
val->uniqstr = bracketed_id_str;
|
||||||
bracketed_id_str = 0;
|
bracketed_id_str = 0;
|
||||||
*loc = bracketed_id_loc;
|
*loc = bracketed_id_loc;
|
||||||
return BRACKETED_ID;
|
return BRACKETED_ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
complain_at (*loc, _("an identifier expected"));
|
complain_at (*loc, _("an identifier expected"));
|
||||||
}
|
}
|
||||||
. {
|
. {
|
||||||
complain_at (*loc, _("invalid character in bracketed name: %s"),
|
complain_at (*loc, _("invalid character in bracketed name: %s"),
|
||||||
quote (yytext));
|
quote (yytext));
|
||||||
}
|
}
|
||||||
<<EOF>> {
|
<<EOF>> {
|
||||||
BEGIN bracketed_id_context_state;
|
BEGIN bracketed_id_context_state;
|
||||||
@@ -446,7 +446,7 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
<SC_YACC_COMMENT>
|
<SC_YACC_COMMENT>
|
||||||
{
|
{
|
||||||
"*/" BEGIN context_state;
|
"*/" BEGIN context_state;
|
||||||
.|\n ;
|
.|\n ;
|
||||||
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
|
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,7 +458,7 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
<SC_COMMENT>
|
<SC_COMMENT>
|
||||||
{
|
{
|
||||||
"*"{splice}"/" STRING_GROW; BEGIN context_state;
|
"*"{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>
|
<SC_LINE_COMMENT>
|
||||||
{
|
{
|
||||||
"\n" STRING_GROW; BEGIN context_state;
|
"\n" STRING_GROW; BEGIN context_state;
|
||||||
{splice} STRING_GROW;
|
{splice} STRING_GROW;
|
||||||
<<EOF>> BEGIN context_state;
|
<<EOF>> BEGIN context_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -502,7 +502,7 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
|
|
||||||
/*----------------------------------------------------------.
|
/*----------------------------------------------------------.
|
||||||
| Scanning a Bison character literal, decoding its escapes. |
|
| Scanning a Bison character literal, decoding its escapes. |
|
||||||
| The initial quote is already eaten. |
|
| The initial quote is already eaten. |
|
||||||
`----------------------------------------------------------*/
|
`----------------------------------------------------------*/
|
||||||
|
|
||||||
<SC_ESCAPED_CHARACTER>
|
<SC_ESCAPED_CHARACTER>
|
||||||
@@ -610,13 +610,13 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
obstack_1grow (&obstack_for_string, c);
|
obstack_1grow (&obstack_for_string, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
\\a obstack_1grow (&obstack_for_string, '\a');
|
\\a obstack_1grow (&obstack_for_string, '\a');
|
||||||
\\b obstack_1grow (&obstack_for_string, '\b');
|
\\b obstack_1grow (&obstack_for_string, '\b');
|
||||||
\\f obstack_1grow (&obstack_for_string, '\f');
|
\\f obstack_1grow (&obstack_for_string, '\f');
|
||||||
\\n obstack_1grow (&obstack_for_string, '\n');
|
\\n obstack_1grow (&obstack_for_string, '\n');
|
||||||
\\r obstack_1grow (&obstack_for_string, '\r');
|
\\r obstack_1grow (&obstack_for_string, '\r');
|
||||||
\\t obstack_1grow (&obstack_for_string, '\t');
|
\\t obstack_1grow (&obstack_for_string, '\t');
|
||||||
\\v obstack_1grow (&obstack_for_string, '\v');
|
\\v obstack_1grow (&obstack_for_string, '\v');
|
||||||
|
|
||||||
/* \\[\"\'?\\] would be shorter, but it confuses xgettext. */
|
/* \\[\"\'?\\] would be shorter, but it confuses xgettext. */
|
||||||
\\("\""|"'"|"?"|"\\") obstack_1grow (&obstack_for_string, yytext[1]);
|
\\("\""|"'"|"?"|"\\") obstack_1grow (&obstack_for_string, yytext[1]);
|
||||||
@@ -629,7 +629,7 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
else
|
else
|
||||||
obstack_1grow (&obstack_for_string, c);
|
obstack_1grow (&obstack_for_string, c);
|
||||||
}
|
}
|
||||||
\\(.|\n) {
|
\\(.|\n) {
|
||||||
char const *p = yytext + 1;
|
char const *p = yytext + 1;
|
||||||
/* Quote only if escaping won't make the character visible. */
|
/* Quote only if escaping won't make the character visible. */
|
||||||
if (isspace ((unsigned char) *p) && isprint ((unsigned char) *p))
|
if (isspace ((unsigned char) *p) && isprint ((unsigned char) *p))
|
||||||
@@ -646,21 +646,21 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
|
|
||||||
<SC_CHARACTER,SC_STRING>
|
<SC_CHARACTER,SC_STRING>
|
||||||
{
|
{
|
||||||
{splice}|\\{splice}[^\n\[\]] STRING_GROW;
|
{splice}|\\{splice}[^\n\[\]] STRING_GROW;
|
||||||
}
|
}
|
||||||
|
|
||||||
<SC_CHARACTER>
|
<SC_CHARACTER>
|
||||||
{
|
{
|
||||||
"'" STRING_GROW; BEGIN context_state;
|
"'" STRING_GROW; BEGIN context_state;
|
||||||
\n unexpected_newline (token_start, "'"); BEGIN context_state;
|
\n unexpected_newline (token_start, "'"); BEGIN context_state;
|
||||||
<<EOF>> unexpected_eof (token_start, "'"); BEGIN context_state;
|
<<EOF>> unexpected_eof (token_start, "'"); BEGIN context_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
<SC_STRING>
|
<SC_STRING>
|
||||||
{
|
{
|
||||||
"\"" STRING_GROW; BEGIN context_state;
|
"\"" STRING_GROW; BEGIN context_state;
|
||||||
\n unexpected_newline (token_start, "\""); BEGIN context_state;
|
\n unexpected_newline (token_start, "\""); BEGIN context_state;
|
||||||
<<EOF>> unexpected_eof (token_start, "\""); BEGIN context_state;
|
<<EOF>> unexpected_eof (token_start, "\""); BEGIN context_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -730,11 +730,11 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
--nesting;
|
--nesting;
|
||||||
if (nesting < 0)
|
if (nesting < 0)
|
||||||
{
|
{
|
||||||
STRING_FINISH;
|
STRING_FINISH;
|
||||||
loc->start = code_start;
|
loc->start = code_start;
|
||||||
val->code = last_string;
|
val->code = last_string;
|
||||||
BEGIN INITIAL;
|
BEGIN INITIAL;
|
||||||
return BRACED_CODE;
|
return BRACED_CODE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -745,11 +745,11 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
--nesting;
|
--nesting;
|
||||||
if (nesting < 0)
|
if (nesting < 0)
|
||||||
{
|
{
|
||||||
STRING_FINISH;
|
STRING_FINISH;
|
||||||
loc->start = code_start;
|
loc->start = code_start;
|
||||||
val->code = last_string;
|
val->code = last_string;
|
||||||
BEGIN INITIAL;
|
BEGIN INITIAL;
|
||||||
return BRACED_PREDICATE;
|
return BRACED_PREDICATE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
obstack_1grow (&obstack_for_string, '}');
|
obstack_1grow (&obstack_for_string, '}');
|
||||||
@@ -802,8 +802,8 @@ splice (\\[ \f\t\v]*\n)*
|
|||||||
| By default, grow the string obstack with the input. |
|
| 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,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>\n STRING_GROW;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
@@ -819,35 +819,35 @@ no_cr_read (FILE *fp, char *buf, size_t size)
|
|||||||
{
|
{
|
||||||
char *w = memchr (buf, '\r', bytes_read);
|
char *w = memchr (buf, '\r', bytes_read);
|
||||||
if (w)
|
if (w)
|
||||||
{
|
{
|
||||||
char const *r = ++w;
|
char const *r = ++w;
|
||||||
char const *lim = buf + bytes_read;
|
char const *lim = buf + bytes_read;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Found an '\r'. Treat it like '\n', but ignore any
|
/* Found an '\r'. Treat it like '\n', but ignore any
|
||||||
'\n' that immediately follows. */
|
'\n' that immediately follows. */
|
||||||
w[-1] = '\n';
|
w[-1] = '\n';
|
||||||
if (r == lim)
|
if (r == lim)
|
||||||
{
|
{
|
||||||
int ch = getc (fp);
|
int ch = getc (fp);
|
||||||
if (ch != '\n' && ungetc (ch, fp) != ch)
|
if (ch != '\n' && ungetc (ch, fp) != ch)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (*r == '\n')
|
else if (*r == '\n')
|
||||||
r++;
|
r++;
|
||||||
|
|
||||||
/* Copy until the next '\r'. */
|
/* Copy until the next '\r'. */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (r == lim)
|
if (r == lim)
|
||||||
return w - buf;
|
return w - buf;
|
||||||
}
|
}
|
||||||
while ((*w++ = *r++) != '\r');
|
while ((*w++ = *r++) != '\r');
|
||||||
}
|
}
|
||||||
|
|
||||||
return w - buf;
|
return w - buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytes_read;
|
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, |
|
| Convert universal character name UCN to a single-byte character, |
|
||||||
| and return that character. Return -1 if UCN does not correspond |
|
| and return that character. Return -1 if UCN does not correspond |
|
||||||
| to a single-byte character. |
|
| to a single-byte character. |
|
||||||
`------------------------------------------------------------------*/
|
`------------------------------------------------------------------*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -906,22 +906,22 @@ convert_ucn_to_byte (char const *ucn)
|
|||||||
about. */
|
about. */
|
||||||
static signed char const table[] =
|
static signed char const table[] =
|
||||||
{
|
{
|
||||||
'\0', -1, -1, -1, -1, -1, -1, '\a',
|
'\0', -1, -1, -1, -1, -1, -1, '\a',
|
||||||
'\b', '\t', '\n', '\v', '\f', '\r', -1, -1,
|
'\b', '\t', '\n', '\v', '\f', '\r', -1, -1,
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
-1, -1, -1, -1, -1, -1, -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',
|
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
||||||
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
||||||
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
||||||
'x', 'y', 'z', '{', '|', '}', '~'
|
'x', 'y', 'z', '{', '|', '}', '~'
|
||||||
};
|
};
|
||||||
|
|
||||||
code = code < sizeof table ? table[code] : -1;
|
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, |
|
| For a token or comment starting at START, report message MSGID, |
|
||||||
| which should say that an end marker was found before |
|
| which should say that an end marker was found before |
|
||||||
| the expected TOKEN_END. |
|
| the expected TOKEN_END. |
|
||||||
`----------------------------------------------------------------*/
|
`----------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ static void fail_for_invalid_at (char const *at);
|
|||||||
|
|
||||||
/* This pattern must not match more than the previous @ patterns. */
|
/* This pattern must not match more than the previous @ patterns. */
|
||||||
@[^@{}`(\n]* fail_for_invalid_at (yytext);
|
@[^@{}`(\n]* fail_for_invalid_at (yytext);
|
||||||
\n out_lineno++; ECHO;
|
\n out_lineno++; ECHO;
|
||||||
[^@\n]+ ECHO;
|
[^@\n]+ ECHO;
|
||||||
|
|
||||||
<INITIAL><<EOF>> {
|
<INITIAL><<EOF>> {
|
||||||
if (outname)
|
if (outname)
|
||||||
|
|||||||
54
src/state.c
54
src/state.c
@@ -28,9 +28,9 @@
|
|||||||
#include "print-xml.h"
|
#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);
|
aver (j < shifts->num);
|
||||||
if (TRANSITION_SYMBOL (shifts, j) == sym)
|
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;
|
state_number nstates = 0;
|
||||||
@@ -128,7 +128,7 @@ state *final_state = NULL;
|
|||||||
|
|
||||||
state *
|
state *
|
||||||
state_new (symbol_number accessing_symbol,
|
state_new (symbol_number accessing_symbol,
|
||||||
size_t nitems, item_number *core)
|
size_t nitems, item_number *core)
|
||||||
{
|
{
|
||||||
state *res;
|
state *res;
|
||||||
size_t items_size = nitems * sizeof *core;
|
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 = "";
|
char const *sep = "";
|
||||||
fprintf (out, " [");
|
fprintf (out, " [");
|
||||||
BITSET_FOR_EACH (biter, reds->lookahead_tokens[red], k, 0)
|
BITSET_FOR_EACH (biter, reds->lookahead_tokens[red], k, 0)
|
||||||
{
|
{
|
||||||
fprintf (out, "%s%s", sep, symbols[k]->tag);
|
fprintf (out, "%s%s", sep, symbols[k]->tag);
|
||||||
sep = ", ";
|
sep = ", ";
|
||||||
}
|
}
|
||||||
fprintf (out, "]");
|
fprintf (out, "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
state_rule_lookahead_tokens_print_xml (state *s, rule *r,
|
state_rule_lookahead_tokens_print_xml (state *s, rule *r,
|
||||||
FILE *out, int level)
|
FILE *out, int level)
|
||||||
{
|
{
|
||||||
/* Find the reduction we are handling. */
|
/* Find the reduction we are handling. */
|
||||||
reductions *reds = s->reductions;
|
reductions *reds = s->reductions;
|
||||||
@@ -287,10 +287,10 @@ state_rule_lookahead_tokens_print_xml (state *s, rule *r,
|
|||||||
int k;
|
int k;
|
||||||
xml_puts (out, level, "<lookaheads>");
|
xml_puts (out, level, "<lookaheads>");
|
||||||
BITSET_FOR_EACH (biter, reds->lookahead_tokens[red], k, 0)
|
BITSET_FOR_EACH (biter, reds->lookahead_tokens[red], k, 0)
|
||||||
{
|
{
|
||||||
xml_printf (out, level + 1, "<symbol>%s</symbol>",
|
xml_printf (out, level + 1, "<symbol>%s</symbol>",
|
||||||
xml_escape (symbols[k]->tag));
|
xml_escape (symbols[k]->tag));
|
||||||
}
|
}
|
||||||
xml_puts (out, level, "</lookaheads>");
|
xml_puts (out, level, "</lookaheads>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -353,10 +353,10 @@ void
|
|||||||
state_hash_new (void)
|
state_hash_new (void)
|
||||||
{
|
{
|
||||||
state_table = hash_initialize (HT_INITIAL_CAPACITY,
|
state_table = hash_initialize (HT_INITIAL_CAPACITY,
|
||||||
NULL,
|
NULL,
|
||||||
state_hasher,
|
state_hasher,
|
||||||
state_comparator,
|
state_comparator,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
16
src/state.h
16
src/state.h
@@ -148,12 +148,12 @@ typedef struct
|
|||||||
|
|
||||||
|
|
||||||
/* Iterate over each transition over a token (shifts). */
|
/* Iterate over each transition over a token (shifts). */
|
||||||
#define FOR_EACH_SHIFT(Transitions, Iter) \
|
#define FOR_EACH_SHIFT(Transitions, Iter) \
|
||||||
for (Iter = 0; \
|
for (Iter = 0; \
|
||||||
Iter < Transitions->num \
|
Iter < Transitions->num \
|
||||||
&& (TRANSITION_IS_DISABLED (Transitions, Iter) \
|
&& (TRANSITION_IS_DISABLED (Transitions, Iter) \
|
||||||
|| TRANSITION_IS_SHIFT (Transitions, Iter)); \
|
|| TRANSITION_IS_SHIFT (Transitions, Iter)); \
|
||||||
++Iter) \
|
++Iter) \
|
||||||
if (!TRANSITION_IS_DISABLED (Transitions, 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. */
|
/* Create a new state with ACCESSING_SYMBOL for those items. */
|
||||||
state *state_new (symbol_number accessing_symbol,
|
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);
|
state *state_new_isocore (state const *s);
|
||||||
|
|
||||||
/* Set the transitions of STATE. */
|
/* Set the transitions of STATE. */
|
||||||
@@ -246,7 +246,7 @@ void state_errs_set (state *s, int num, symbol **errors);
|
|||||||
reduce R. */
|
reduce R. */
|
||||||
void state_rule_lookahead_tokens_print (state *s, rule *r, FILE *out);
|
void state_rule_lookahead_tokens_print (state *s, rule *r, FILE *out);
|
||||||
void state_rule_lookahead_tokens_print_xml (state *s, rule *r,
|
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. */
|
/* Create/destroy the states hash table. */
|
||||||
void state_hash_new (void);
|
void state_hash_new (void);
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ symbol_list_syms_print (const symbol_list *l, FILE *f)
|
|||||||
symbol_print (l->content.sym, f);
|
symbol_print (l->content.sym, f);
|
||||||
fprintf (stderr, l->action_props.is_value_used ? " used" : " unused");
|
fprintf (stderr, l->action_props.is_value_used ? " used" : " unused");
|
||||||
if (l && l->content.sym)
|
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;
|
l = l->next;
|
||||||
if (l == NULL
|
if (l == NULL
|
||||||
|| (l->content_type == SYMLIST_SYMBOL && l->content.sym == NULL))
|
|| (l->content_type == SYMLIST_SYMBOL && l->content.sym == NULL))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
|
|||||||
98
src/symtab.c
98
src/symtab.c
@@ -90,7 +90,7 @@ symbol_new (uniqstr tag, location loc)
|
|||||||
|
|
||||||
if (nsyms == SYMBOL_NUMBER_MAXIMUM)
|
if (nsyms == SYMBOL_NUMBER_MAXIMUM)
|
||||||
fatal (_("too many symbols in input grammar (limit is %d)"),
|
fatal (_("too many symbols in input grammar (limit is %d)"),
|
||||||
SYMBOL_NUMBER_MAXIMUM);
|
SYMBOL_NUMBER_MAXIMUM);
|
||||||
nsyms++;
|
nsyms++;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -117,8 +117,8 @@ semantic_type_new (uniqstr tag)
|
|||||||
| Print a symbol. |
|
| Print a symbol. |
|
||||||
`-----------------*/
|
`-----------------*/
|
||||||
|
|
||||||
#define SYMBOL_ATTR_PRINT(Attr) \
|
#define SYMBOL_ATTR_PRINT(Attr) \
|
||||||
if (s->Attr) \
|
if (s->Attr) \
|
||||||
fprintf (f, " %s { %s }", #Attr, s->Attr)
|
fprintf (f, " %s { %s }", #Attr, s->Attr)
|
||||||
|
|
||||||
#define SYMBOL_CODE_PRINT(Attr) \
|
#define SYMBOL_CODE_PRINT(Attr) \
|
||||||
@@ -211,7 +211,7 @@ symbol_type_set (symbol *sym, uniqstr type_name, location loc)
|
|||||||
if (type_name)
|
if (type_name)
|
||||||
{
|
{
|
||||||
if (sym->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);
|
uniqstr_assert (type_name);
|
||||||
sym->type_name = type_name;
|
sym->type_name = type_name;
|
||||||
sym->type_location = loc;
|
sym->type_location = loc;
|
||||||
@@ -340,7 +340,7 @@ symbol_precedence_set (symbol *sym, int prec, assoc a, location loc)
|
|||||||
if (a != undef_assoc)
|
if (a != undef_assoc)
|
||||||
{
|
{
|
||||||
if (sym->prec != 0)
|
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);
|
loc);
|
||||||
sym->prec = prec;
|
sym->prec = prec;
|
||||||
sym->assoc = a;
|
sym->assoc = a;
|
||||||
@@ -375,7 +375,7 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring)
|
|||||||
if (declaring)
|
if (declaring)
|
||||||
{
|
{
|
||||||
if (sym->declared)
|
if (sym->declared)
|
||||||
warn_at (loc, _("symbol %s redeclared"), sym->tag);
|
warn_at (loc, _("symbol %s redeclared"), sym->tag);
|
||||||
sym->declared = true;
|
sym->declared = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -404,7 +404,7 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
|
|||||||
{
|
{
|
||||||
endtoken = sym;
|
endtoken = sym;
|
||||||
/* It is always mapped to 0, so it was already counted in
|
/* It is always mapped to 0, so it was already counted in
|
||||||
NTOKENS. */
|
NTOKENS. */
|
||||||
if (endtoken->number != NUMBER_UNDEFINED)
|
if (endtoken->number != NUMBER_UNDEFINED)
|
||||||
--ntokens;
|
--ntokens;
|
||||||
endtoken->number = 0;
|
endtoken->number = 0;
|
||||||
@@ -423,9 +423,9 @@ symbol_check_defined (symbol *sym)
|
|||||||
if (sym->class == unknown_sym)
|
if (sym->class == unknown_sym)
|
||||||
{
|
{
|
||||||
complain_at
|
complain_at
|
||||||
(sym->location,
|
(sym->location,
|
||||||
_("symbol %s is used, but is not defined as a token and has no rules"),
|
_("symbol %s is used, but is not defined as a token and has no rules"),
|
||||||
sym->tag);
|
sym->tag);
|
||||||
sym->class = nterm_sym;
|
sym->class = nterm_sym;
|
||||||
sym->number = nvars++;
|
sym->number = nvars++;
|
||||||
}
|
}
|
||||||
@@ -445,10 +445,10 @@ symbol_make_alias (symbol *sym, symbol *str, location loc)
|
|||||||
{
|
{
|
||||||
if (str->alias)
|
if (str->alias)
|
||||||
warn_at (loc, _("symbol `%s' used more than once as a literal string"),
|
warn_at (loc, _("symbol `%s' used more than once as a literal string"),
|
||||||
str->tag);
|
str->tag);
|
||||||
else if (sym->alias)
|
else if (sym->alias)
|
||||||
warn_at (loc, _("symbol `%s' given more than one literal string"),
|
warn_at (loc, _("symbol `%s' given more than one literal string"),
|
||||||
sym->tag);
|
sym->tag);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
str->class = token_sym;
|
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 != sym->type_name)
|
||||||
{
|
{
|
||||||
if (str->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
|
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 || sym->destructor.code)
|
||||||
{
|
{
|
||||||
if (str->destructor.code)
|
if (str->destructor.code)
|
||||||
symbol_destructor_set (sym, &str->destructor);
|
symbol_destructor_set (sym, &str->destructor);
|
||||||
else
|
else
|
||||||
symbol_destructor_set (str, &sym->destructor);
|
symbol_destructor_set (str, &sym->destructor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str->printer.code || sym->printer.code)
|
if (str->printer.code || sym->printer.code)
|
||||||
{
|
{
|
||||||
if (str->printer.code)
|
if (str->printer.code)
|
||||||
symbol_printer_set (sym, &str->printer);
|
symbol_printer_set (sym, &str->printer);
|
||||||
else
|
else
|
||||||
symbol_printer_set (str, &sym->printer);
|
symbol_printer_set (str, &sym->printer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sym->prec || str->prec)
|
if (sym->prec || str->prec)
|
||||||
{
|
{
|
||||||
if (str->prec)
|
if (str->prec)
|
||||||
symbol_precedence_set (sym, str->prec, str->assoc,
|
symbol_precedence_set (sym, str->prec, str->assoc,
|
||||||
str->prec_location);
|
str->prec_location);
|
||||||
else
|
else
|
||||||
symbol_precedence_set (str, sym->prec, sym->assoc,
|
symbol_precedence_set (str, sym->prec, sym->assoc,
|
||||||
sym->prec_location);
|
sym->prec_location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
symbol_check_alias_consistency_processor (void *this,
|
symbol_check_alias_consistency_processor (void *this,
|
||||||
void *null ATTRIBUTE_UNUSED)
|
void *null ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
symbol_check_alias_consistency (this);
|
symbol_check_alias_consistency (this);
|
||||||
return true;
|
return true;
|
||||||
@@ -582,7 +582,7 @@ symbol_translation (symbol *this)
|
|||||||
{
|
{
|
||||||
/* A token which translation has already been set? */
|
/* A token which translation has already been set? */
|
||||||
if (token_translations[this->user_token_number] != undeftoken->number)
|
if (token_translations[this->user_token_number] != undeftoken->number)
|
||||||
user_token_number_redeclaration
|
user_token_number_redeclaration
|
||||||
(this->user_token_number,
|
(this->user_token_number,
|
||||||
symbols[token_translations[this->user_token_number]],
|
symbols[token_translations[this->user_token_number]],
|
||||||
this);
|
this);
|
||||||
@@ -670,15 +670,15 @@ void
|
|||||||
symbols_new (void)
|
symbols_new (void)
|
||||||
{
|
{
|
||||||
symbol_table = hash_initialize (HT_INITIAL_CAPACITY,
|
symbol_table = hash_initialize (HT_INITIAL_CAPACITY,
|
||||||
NULL,
|
NULL,
|
||||||
hash_symbol_hasher,
|
hash_symbol_hasher,
|
||||||
hash_symbol_comparator,
|
hash_symbol_comparator,
|
||||||
free);
|
free);
|
||||||
semantic_type_table = hash_initialize (HT_INITIAL_CAPACITY,
|
semantic_type_table = hash_initialize (HT_INITIAL_CAPACITY,
|
||||||
NULL,
|
NULL,
|
||||||
hash_semantic_type_hasher,
|
hash_semantic_type_hasher,
|
||||||
hash_semantic_type_comparator,
|
hash_semantic_type_comparator,
|
||||||
free);
|
free);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -862,12 +862,12 @@ symbols_token_translations_init (void)
|
|||||||
{
|
{
|
||||||
symbol *this = symbols[i];
|
symbol *this = symbols[i];
|
||||||
if (this->user_token_number != USER_NUMBER_UNDEFINED)
|
if (this->user_token_number != USER_NUMBER_UNDEFINED)
|
||||||
{
|
{
|
||||||
if (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;
|
||||||
if (this->user_token_number == 256)
|
if (this->user_token_number == 256)
|
||||||
num_256_available_p = false;
|
num_256_available_p = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If 256 is not used, assign it to error, to follow POSIX. */
|
/* 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];
|
symbol *this = symbols[i];
|
||||||
if (this->user_token_number == USER_NUMBER_UNDEFINED)
|
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)
|
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,
|
token_translations = xnmalloc (max_user_token_number + 1,
|
||||||
sizeof *token_translations);
|
sizeof *token_translations);
|
||||||
|
|
||||||
/* Initialize all entries for literal tokens to the internal token
|
/* Initialize all entries for literal tokens to the internal token
|
||||||
number for $undefined, which represents all invalid inputs. */
|
number for $undefined, which represents all invalid inputs. */
|
||||||
@@ -940,12 +940,12 @@ symbols_pack (void)
|
|||||||
|
|
||||||
if (startsymbol->class == unknown_sym)
|
if (startsymbol->class == unknown_sym)
|
||||||
fatal_at (startsymbol_location,
|
fatal_at (startsymbol_location,
|
||||||
_("the start symbol %s is undefined"),
|
_("the start symbol %s is undefined"),
|
||||||
startsymbol->tag);
|
startsymbol->tag);
|
||||||
else if (startsymbol->class == token_sym)
|
else if (startsymbol->class == token_sym)
|
||||||
fatal_at (startsymbol_location,
|
fatal_at (startsymbol_location,
|
||||||
_("the start symbol %s is a token"),
|
_("the start symbol %s is a token"),
|
||||||
startsymbol->tag);
|
startsymbol->tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -961,7 +961,7 @@ default_tagged_destructor_set (code_props const *destructor)
|
|||||||
complain_at (destructor->location,
|
complain_at (destructor->location,
|
||||||
_("redeclaration for default tagged %%destructor"));
|
_("redeclaration for default tagged %%destructor"));
|
||||||
complain_at (default_tagged_destructor.location,
|
complain_at (default_tagged_destructor.location,
|
||||||
_("previous declaration"));
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
default_tagged_destructor = *destructor;
|
default_tagged_destructor = *destructor;
|
||||||
}
|
}
|
||||||
@@ -974,7 +974,7 @@ default_tagless_destructor_set (code_props const *destructor)
|
|||||||
complain_at (destructor->location,
|
complain_at (destructor->location,
|
||||||
_("redeclaration for default tagless %%destructor"));
|
_("redeclaration for default tagless %%destructor"));
|
||||||
complain_at (default_tagless_destructor.location,
|
complain_at (default_tagless_destructor.location,
|
||||||
_("previous declaration"));
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
default_tagless_destructor = *destructor;
|
default_tagless_destructor = *destructor;
|
||||||
}
|
}
|
||||||
@@ -987,7 +987,7 @@ default_tagged_printer_set (code_props const *printer)
|
|||||||
complain_at (printer->location,
|
complain_at (printer->location,
|
||||||
_("redeclaration for default tagged %%printer"));
|
_("redeclaration for default tagged %%printer"));
|
||||||
complain_at (default_tagged_printer.location,
|
complain_at (default_tagged_printer.location,
|
||||||
_("previous declaration"));
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
default_tagged_printer = *printer;
|
default_tagged_printer = *printer;
|
||||||
}
|
}
|
||||||
@@ -1000,7 +1000,7 @@ default_tagless_printer_set (code_props const *printer)
|
|||||||
complain_at (printer->location,
|
complain_at (printer->location,
|
||||||
_("redeclaration for default tagless %%printer"));
|
_("redeclaration for default tagless %%printer"));
|
||||||
complain_at (default_tagless_printer.location,
|
complain_at (default_tagless_printer.location,
|
||||||
_("previous declaration"));
|
_("previous declaration"));
|
||||||
}
|
}
|
||||||
default_tagless_printer = *printer;
|
default_tagless_printer = *printer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,8 @@
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
unknown_sym, /**< Undefined. */
|
unknown_sym, /**< Undefined. */
|
||||||
token_sym, /**< Terminal. */
|
token_sym, /**< Terminal. */
|
||||||
nterm_sym /**< Non-terminal. */
|
nterm_sym /**< Non-terminal. */
|
||||||
} symbol_class;
|
} 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. */
|
/** Set the \c class associated with \c sym. */
|
||||||
void symbol_class_set (symbol *sym, symbol_class class, location loc,
|
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. */
|
/** Set the \c user_token_number associated with \c sym. */
|
||||||
void symbol_user_token_number_set (symbol *sym, int user_number, location loc);
|
void symbol_user_token_number_set (symbol *sym, int user_number, location loc);
|
||||||
|
|||||||
56
src/system.h
56
src/system.h
@@ -161,32 +161,32 @@ typedef size_t uintptr_t;
|
|||||||
#define obstack_sgrow(Obs, Str) \
|
#define obstack_sgrow(Obs, Str) \
|
||||||
obstack_grow (Obs, Str, strlen (Str))
|
obstack_grow (Obs, Str, strlen (Str))
|
||||||
|
|
||||||
#define obstack_fgrow1(Obs, Format, Arg1) \
|
#define obstack_fgrow1(Obs, Format, Arg1) \
|
||||||
do { \
|
do { \
|
||||||
char buf[4096]; \
|
char buf[4096]; \
|
||||||
sprintf (buf, Format, Arg1); \
|
sprintf (buf, Format, Arg1); \
|
||||||
obstack_grow (Obs, buf, strlen (buf)); \
|
obstack_grow (Obs, buf, strlen (buf)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
|
#define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
|
||||||
do { \
|
do { \
|
||||||
char buf[4096]; \
|
char buf[4096]; \
|
||||||
sprintf (buf, Format, Arg1, Arg2); \
|
sprintf (buf, Format, Arg1, Arg2); \
|
||||||
obstack_grow (Obs, buf, strlen (buf)); \
|
obstack_grow (Obs, buf, strlen (buf)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
|
#define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
|
||||||
do { \
|
do { \
|
||||||
char buf[4096]; \
|
char buf[4096]; \
|
||||||
sprintf (buf, Format, Arg1, Arg2, Arg3); \
|
sprintf (buf, Format, Arg1, Arg2, Arg3); \
|
||||||
obstack_grow (Obs, buf, strlen (buf)); \
|
obstack_grow (Obs, buf, strlen (buf)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
|
#define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
|
||||||
do { \
|
do { \
|
||||||
char buf[4096]; \
|
char buf[4096]; \
|
||||||
sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
|
sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
|
||||||
obstack_grow (Obs, buf, strlen (buf)); \
|
obstack_grow (Obs, buf, strlen (buf)); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
@@ -213,14 +213,14 @@ do { \
|
|||||||
| Free a linked list. |
|
| Free a linked list. |
|
||||||
`---------------------*/
|
`---------------------*/
|
||||||
|
|
||||||
#define LIST_FREE(Type, List) \
|
#define LIST_FREE(Type, List) \
|
||||||
do { \
|
do { \
|
||||||
Type *_node, *_next; \
|
Type *_node, *_next; \
|
||||||
for (_node = List; _node; _node = _next) \
|
for (_node = List; _node; _node = _next) \
|
||||||
{ \
|
{ \
|
||||||
_next = _node->next; \
|
_next = _node->next; \
|
||||||
free (_node); \
|
free (_node); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
294
src/tables.c
294
src/tables.c
@@ -152,11 +152,11 @@ table_grow (int desired)
|
|||||||
|
|
||||||
if (trace_flag & trace_resource)
|
if (trace_flag & trace_resource)
|
||||||
fprintf (stderr, "growing table and check from: %d to %d\n",
|
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);
|
table = xnrealloc (table, table_size, sizeof *table);
|
||||||
conflict_table = xnrealloc (conflict_table, table_size,
|
conflict_table = xnrealloc (conflict_table, table_size,
|
||||||
sizeof *conflict_table);
|
sizeof *conflict_table);
|
||||||
check = xnrealloc (check, table_size, sizeof *check);
|
check = xnrealloc (check, table_size, sizeof *check);
|
||||||
|
|
||||||
for (/* Nothing. */; old_size < table_size; ++old_size)
|
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 |
|
| For GLR parsers, for each conflicted token in S, as indicated |
|
||||||
| by non-zero entries in CONFLROW, create a list of possible |
|
| by non-zero entries in CONFLROW, create a list of possible |
|
||||||
| reductions that are alternatives to the shift or reduction |
|
| reductions that are alternatives to the shift or reduction |
|
||||||
| currently recorded for that token in S. Store the alternative |
|
| 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 |
|
| CONFLICT_LIST_CNT, and storing an index to the start of the list |
|
||||||
| back into CONFLROW. |
|
| back into CONFLROW. |
|
||||||
`-------------------------------------------------------------------*/
|
`-------------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -192,26 +192,26 @@ conflict_row (state *s)
|
|||||||
for (j = 0; j < ntokens; j += 1)
|
for (j = 0; j < ntokens; j += 1)
|
||||||
if (conflrow[j])
|
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
|
/* Find all reductions for token J, and record all that do not
|
||||||
match ACTROW[J]. */
|
match ACTROW[J]. */
|
||||||
for (i = 0; i < reds->num; i += 1)
|
for (i = 0; i < reds->num; i += 1)
|
||||||
if (bitset_test (reds->lookahead_tokens[i], j)
|
if (bitset_test (reds->lookahead_tokens[i], j)
|
||||||
&& (actrow[j]
|
&& (actrow[j]
|
||||||
!= rule_number_as_item_number (reds->rules[i]->number)))
|
!= rule_number_as_item_number (reds->rules[i]->number)))
|
||||||
{
|
{
|
||||||
aver (0 < conflict_list_free);
|
aver (0 < conflict_list_free);
|
||||||
conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
|
conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
|
||||||
conflict_list_cnt += 1;
|
conflict_list_cnt += 1;
|
||||||
conflict_list_free -= 1;
|
conflict_list_free -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Leave a 0 at the end. */
|
/* Leave a 0 at the end. */
|
||||||
aver (0 < conflict_list_free);
|
aver (0 < conflict_list_free);
|
||||||
conflict_list[conflict_list_cnt] = 0;
|
conflict_list[conflict_list_cnt] = 0;
|
||||||
conflict_list_cnt += 1;
|
conflict_list_cnt += 1;
|
||||||
conflict_list_free -= 1;
|
conflict_list_free -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,9 +222,9 @@ conflict_row (state *s)
|
|||||||
| default action (yydefact) for the state. In addition, ACTROW is |
|
| default action (yydefact) for the state. In addition, ACTROW is |
|
||||||
| filled with what to do for each kind of token, index by symbol |
|
| filled with what to do for each kind of token, index by symbol |
|
||||||
| number, with zero meaning do the default action. The value |
|
| number, with zero meaning do the default action. The value |
|
||||||
| ACTION_NUMBER_MINIMUM, a very negative number, means this |
|
| ACTION_NUMBER_MINIMUM, a very negative number, means this |
|
||||||
| situation is an error. The parser recognizes this value |
|
| situation is an error. The parser recognizes this value |
|
||||||
| specially. |
|
| specially. |
|
||||||
| |
|
| |
|
||||||
| This is where conflicts are resolved. The loop over lookahead |
|
| This is where conflicts are resolved. The loop over lookahead |
|
||||||
| rules considered lower-numbered rules last, and the last rule |
|
| rules considered lower-numbered rules last, and the last rule |
|
||||||
@@ -256,22 +256,22 @@ action_row (state *s)
|
|||||||
int j;
|
int j;
|
||||||
bitset_iterator biter;
|
bitset_iterator biter;
|
||||||
/* loop over all the rules available here which require
|
/* loop over all the rules available here which require
|
||||||
lookahead (in reverse order to give precedence to the first
|
lookahead (in reverse order to give precedence to the first
|
||||||
rule) */
|
rule) */
|
||||||
for (i = reds->num - 1; i >= 0; --i)
|
for (i = reds->num - 1; i >= 0; --i)
|
||||||
/* and find each token which the rule finds acceptable
|
/* and find each token which the rule finds acceptable
|
||||||
to come next */
|
to come next */
|
||||||
BITSET_FOR_EACH (biter, reds->lookahead_tokens[i], j, 0)
|
BITSET_FOR_EACH (biter, reds->lookahead_tokens[i], j, 0)
|
||||||
{
|
{
|
||||||
/* and record this rule as the rule to use if that
|
/* and record this rule as the rule to use if that
|
||||||
token follows. */
|
token follows. */
|
||||||
if (actrow[j] != 0)
|
if (actrow[j] != 0)
|
||||||
{
|
{
|
||||||
conflicted = true;
|
conflicted = true;
|
||||||
conflrow[j] = 1;
|
conflrow[j] = 1;
|
||||||
}
|
}
|
||||||
actrow[j] = rule_number_as_item_number (reds->rules[i]->number);
|
actrow[j] = rule_number_as_item_number (reds->rules[i]->number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now see which tokens are allowed for shifts in this state. For
|
/* 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];
|
state *shift_state = trans->states[i];
|
||||||
|
|
||||||
if (actrow[sym] != 0)
|
if (actrow[sym] != 0)
|
||||||
{
|
{
|
||||||
conflicted = true;
|
conflicted = true;
|
||||||
conflrow[sym] = 1;
|
conflrow[sym] = 1;
|
||||||
}
|
}
|
||||||
actrow[sym] = state_number_as_int (shift_state->number);
|
actrow[sym] = state_number_as_int (shift_state->number);
|
||||||
|
|
||||||
/* Do not use any default reduction if there is a shift for
|
/* Do not use any default reduction if there is a shift for
|
||||||
error */
|
error */
|
||||||
if (sym == errtoken->number)
|
if (sym == errtoken->number)
|
||||||
nodefault = true;
|
nodefault = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See which tokens are an explicit error in this state (due to
|
/* 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 (reds->num >= 1 && !nodefault)
|
||||||
{
|
{
|
||||||
if (s->consistent)
|
if (s->consistent)
|
||||||
default_reduction = reds->rules[0];
|
default_reduction = reds->rules[0];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int max = 0;
|
int max = 0;
|
||||||
for (i = 0; i < reds->num; i++)
|
for (i = 0; i < reds->num; i++)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
rule *r = reds->rules[i];
|
rule *r = reds->rules[i];
|
||||||
symbol_number j;
|
symbol_number j;
|
||||||
|
|
||||||
for (j = 0; j < ntokens; j++)
|
for (j = 0; j < ntokens; j++)
|
||||||
if (actrow[j] == rule_number_as_item_number (r->number))
|
if (actrow[j] == rule_number_as_item_number (r->number))
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (count > max)
|
if (count > max)
|
||||||
{
|
{
|
||||||
max = count;
|
max = count;
|
||||||
default_reduction = r;
|
default_reduction = r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GLR parsers need space for conflict lists, so we can't
|
/* GLR parsers need space for conflict lists, so we can't
|
||||||
default conflicted entries. For non-conflicted entries
|
default conflicted entries. For non-conflicted entries
|
||||||
or as long as we are not building a GLR parser,
|
or as long as we are not building a GLR parser,
|
||||||
actions that match the default are replaced with zero,
|
actions that match the default are replaced with zero,
|
||||||
which means "use the default". */
|
which means "use the default". */
|
||||||
|
|
||||||
if (max > 0)
|
if (max > 0)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < ntokens; j++)
|
for (j = 0; j < ntokens; j++)
|
||||||
if (actrow[j]
|
if (actrow[j]
|
||||||
== rule_number_as_item_number (default_reduction->number)
|
== rule_number_as_item_number (default_reduction->number)
|
||||||
&& ! (nondeterministic_parser && conflrow[j]))
|
&& ! (nondeterministic_parser && conflrow[j]))
|
||||||
actrow[j] = 0;
|
actrow[j] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If have no default reduction, the default is an error.
|
/* If have no default reduction, the default is an error.
|
||||||
@@ -366,7 +366,7 @@ action_row (state *s)
|
|||||||
if (!default_reduction)
|
if (!default_reduction)
|
||||||
for (i = 0; i < ntokens; i++)
|
for (i = 0; i < ntokens; i++)
|
||||||
if (actrow[i] == ACTION_NUMBER_MINIMUM)
|
if (actrow[i] == ACTION_NUMBER_MINIMUM)
|
||||||
actrow[i] = 0;
|
actrow[i] = 0;
|
||||||
|
|
||||||
if (conflicted)
|
if (conflicted)
|
||||||
conflict_row (s);
|
conflict_row (s);
|
||||||
@@ -408,10 +408,10 @@ save_row (state_number s)
|
|||||||
for (i = 0; i < ntokens; i++)
|
for (i = 0; i < ntokens; i++)
|
||||||
if (actrow[i] != 0)
|
if (actrow[i] != 0)
|
||||||
{
|
{
|
||||||
*sp1++ = i;
|
*sp1++ = i;
|
||||||
*sp2++ = actrow[i];
|
*sp2++ = actrow[i];
|
||||||
if (nondeterministic_parser)
|
if (nondeterministic_parser)
|
||||||
*sp3++ = conflrow[i];
|
*sp3++ = conflrow[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
tally[s] = count;
|
tally[s] = count;
|
||||||
@@ -457,16 +457,16 @@ token_actions (void)
|
|||||||
save_row (i);
|
save_row (i);
|
||||||
|
|
||||||
/* Now that the parser was computed, we can find which rules are
|
/* Now that the parser was computed, we can find which rules are
|
||||||
really reduced, and which are not because of SR or RR
|
really reduced, and which are not because of SR or RR
|
||||||
conflicts. */
|
conflicts. */
|
||||||
if (!nondeterministic_parser)
|
if (!nondeterministic_parser)
|
||||||
{
|
{
|
||||||
for (j = 0; j < ntokens; ++j)
|
for (j = 0; j < ntokens; ++j)
|
||||||
if (actrow[j] < 0 && actrow[j] != ACTION_NUMBER_MINIMUM)
|
if (actrow[j] < 0 && actrow[j] != ACTION_NUMBER_MINIMUM)
|
||||||
rules[item_number_as_rule_number (actrow[j])].useful = true;
|
rules[item_number_as_rule_number (actrow[j])].useful = true;
|
||||||
if (yydefact[i])
|
if (yydefact[i])
|
||||||
rules[yydefact[i] - 1].useful = true;
|
rules[yydefact[i] - 1].useful = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free (actrow);
|
free (actrow);
|
||||||
@@ -513,8 +513,8 @@ save_column (symbol_number sym, state_number default_state)
|
|||||||
for (i = begin; i < end; i++)
|
for (i = begin; i < end; i++)
|
||||||
if (to_state[i] != default_state)
|
if (to_state[i] != default_state)
|
||||||
{
|
{
|
||||||
*sp1++ = from_state[i];
|
*sp1++ = from_state[i];
|
||||||
*sp2++ = to_state[i];
|
*sp2++ = to_state[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
tally[symno] = count;
|
tally[symno] = count;
|
||||||
@@ -548,8 +548,8 @@ default_goto (symbol_number sym, size_t state_count[])
|
|||||||
for (s = 0; s < nstates; s++)
|
for (s = 0; s < nstates; s++)
|
||||||
if (state_count[s] > max)
|
if (state_count[s] > max)
|
||||||
{
|
{
|
||||||
max = state_count[s];
|
max = state_count[s];
|
||||||
default_state = s;
|
default_state = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
return default_state;
|
return default_state;
|
||||||
@@ -599,22 +599,22 @@ sort_actions (void)
|
|||||||
for (i = 0; i < nvectors; i++)
|
for (i = 0; i < nvectors; i++)
|
||||||
if (tally[i] > 0)
|
if (tally[i] > 0)
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
int t = tally[i];
|
int t = tally[i];
|
||||||
int w = width[i];
|
int w = width[i];
|
||||||
int j = nentries - 1;
|
int j = nentries - 1;
|
||||||
|
|
||||||
while (j >= 0 && (width[order[j]] < w))
|
while (j >= 0 && (width[order[j]] < w))
|
||||||
j--;
|
j--;
|
||||||
|
|
||||||
while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
|
while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
|
||||||
j--;
|
j--;
|
||||||
|
|
||||||
for (k = nentries - 1; k > j; k--)
|
for (k = nentries - 1; k > j; k--)
|
||||||
order[k + 1] = order[k];
|
order[k + 1] = order[k];
|
||||||
|
|
||||||
order[j + 1] = i;
|
order[j + 1] = i;
|
||||||
nentries++;
|
nentries++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,8 +645,8 @@ matching_state (vector_number vector)
|
|||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < t; j += 1)
|
for (j = 0; j < t; j += 1)
|
||||||
if (conflict_tos[i][j] != 0)
|
if (conflict_tos[i][j] != 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (prev = vector - 1; prev >= 0; prev--)
|
for (prev = vector - 1; prev >= 0; prev--)
|
||||||
@@ -656,17 +656,17 @@ matching_state (vector_number vector)
|
|||||||
int match = 1;
|
int match = 1;
|
||||||
|
|
||||||
/* Given how ORDER was computed, if the WIDTH or TALLY is
|
/* 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)
|
if (width[j] != w || tally[j] != t)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (k = 0; match && k < t; k++)
|
for (k = 0; match && k < t; k++)
|
||||||
if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k]
|
if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k]
|
||||||
|| (conflict_tos[j] != NULL && conflict_tos[j][k] != 0))
|
|| (conflict_tos[j] != NULL && conflict_tos[j][k] != 0))
|
||||||
match = 0;
|
match = 0;
|
||||||
|
|
||||||
if (match)
|
if (match)
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@@ -694,39 +694,39 @@ pack_vector (vector_number vector)
|
|||||||
aver (j < table_size);
|
aver (j < table_size);
|
||||||
|
|
||||||
for (k = 0; ok && k < t; k++)
|
for (k = 0; ok && k < t; k++)
|
||||||
{
|
{
|
||||||
loc = j + state_number_as_int (from[k]);
|
loc = j + state_number_as_int (from[k]);
|
||||||
if (table_size <= loc)
|
if (table_size <= loc)
|
||||||
table_grow (loc);
|
table_grow (loc);
|
||||||
|
|
||||||
if (table[loc] != 0)
|
if (table[loc] != 0)
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (k = 0; ok && k < vector; k++)
|
for (k = 0; ok && k < vector; k++)
|
||||||
if (pos[k] == j)
|
if (pos[k] == j)
|
||||||
ok = false;
|
ok = false;
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
for (k = 0; k < t; k++)
|
for (k = 0; k < t; k++)
|
||||||
{
|
{
|
||||||
loc = j + from[k];
|
loc = j + from[k];
|
||||||
table[loc] = to[k];
|
table[loc] = to[k];
|
||||||
if (nondeterministic_parser && conflict_to != NULL)
|
if (nondeterministic_parser && conflict_to != NULL)
|
||||||
conflict_table[loc] = conflict_to[k];
|
conflict_table[loc] = conflict_to[k];
|
||||||
check[loc] = from[k];
|
check[loc] = from[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
while (table[lowzero] != 0)
|
while (table[lowzero] != 0)
|
||||||
lowzero++;
|
lowzero++;
|
||||||
|
|
||||||
if (loc > high)
|
if (loc > high)
|
||||||
high = loc;
|
high = loc;
|
||||||
|
|
||||||
aver (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
|
aver (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -784,11 +784,11 @@ pack_table (void)
|
|||||||
base_number place;
|
base_number place;
|
||||||
|
|
||||||
if (s < 0)
|
if (s < 0)
|
||||||
/* A new set of state actions, or a nonterminal. */
|
/* A new set of state actions, or a nonterminal. */
|
||||||
place = pack_vector (i);
|
place = pack_vector (i);
|
||||||
else
|
else
|
||||||
/* Action of I were already coded for S. */
|
/* Action of I were already coded for S. */
|
||||||
place = base[s];
|
place = base[s];
|
||||||
|
|
||||||
pos[i] = place;
|
pos[i] = place;
|
||||||
base[order[i]] = place;
|
base[order[i]] = place;
|
||||||
@@ -817,7 +817,7 @@ tables_generate (void)
|
|||||||
correlated. In particular the signedness is not taken into
|
correlated. In particular the signedness is not taken into
|
||||||
account. But it's not useless. */
|
account. But it's not useless. */
|
||||||
verify (sizeof nstates <= sizeof nvectors
|
verify (sizeof nstates <= sizeof nvectors
|
||||||
&& sizeof nvars <= sizeof nvectors);
|
&& sizeof nvars <= sizeof nvectors);
|
||||||
|
|
||||||
nvectors = state_number_as_int (nstates) + nvars;
|
nvectors = state_number_as_int (nstates) + nvars;
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ uniqstr_assert (char const *str)
|
|||||||
if (!hash_lookup (uniqstrs_table, str))
|
if (!hash_lookup (uniqstrs_table, str))
|
||||||
{
|
{
|
||||||
error (0, 0,
|
error (0, 0,
|
||||||
"not a uniqstr: %s", quotearg (str));
|
"not a uniqstr: %s", quotearg (str));
|
||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,10 +128,10 @@ void
|
|||||||
uniqstrs_new (void)
|
uniqstrs_new (void)
|
||||||
{
|
{
|
||||||
uniqstrs_table = hash_initialize (HT_INITIAL_CAPACITY,
|
uniqstrs_table = hash_initialize (HT_INITIAL_CAPACITY,
|
||||||
NULL,
|
NULL,
|
||||||
hash_uniqstr,
|
hash_uniqstr,
|
||||||
hash_compare_uniqstr,
|
hash_compare_uniqstr,
|
||||||
free);
|
free);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -298,11 +298,11 @@ input:
|
|||||||
printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
|
printf ("input (%d@%d-%d): /* Nothing */\n", $$, RANGE (@$));
|
||||||
}
|
}
|
||||||
| line input /* Right recursive to load the stack so that popping at
|
| line input /* Right recursive to load the stack so that popping at
|
||||||
END can be exercised. */
|
END can be exercised. */
|
||||||
{
|
{
|
||||||
$$ = 2;
|
$$ = 2;
|
||||||
printf ("input (%d@%d-%d): line (%d@%d-%d) input (%d@%d-%d)\n",
|
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;
|
start: test2 test1 test0 testc;
|
||||||
|
|
||||||
test2
|
test2
|
||||||
: 'a' { semi; /* TEST:N:2 */ }
|
: 'a' { semi; /* TEST:N:2 */ }
|
||||||
| 'b' { if (0) {no_semi} /* TEST:N:2 */ }
|
| 'b' { if (0) {no_semi} /* TEST:N:2 */ }
|
||||||
| 'c' { if (0) {semi;} /* TEST:N:2 */ }
|
| 'c' { if (0) {semi;} /* TEST:N:2 */ }
|
||||||
| 'd' { semi; no_semi /* TEST:Y:2 */ }
|
| 'd' { semi; no_semi /* TEST:Y:2 */ }
|
||||||
| 'e' { semi(); no_semi() /* TEST:Y:2 */ }
|
| 'e' { semi(); no_semi() /* TEST:Y:2 */ }
|
||||||
| 'f' { semi[]; no_semi[] /* TEST:Y:2 */ }
|
| 'f' { semi[]; no_semi[] /* TEST:Y:2 */ }
|
||||||
| 'g' { semi++; no_semi++ /* TEST:Y:2 */ }
|
| 'g' { semi++; no_semi++ /* TEST:Y:2 */ }
|
||||||
| 'h' { {no_semi} no_semi /* TEST:Y:2 */ }
|
| 'h' { {no_semi} no_semi /* TEST:Y:2 */ }
|
||||||
| 'i' { {semi;} no_semi /* TEST:Y:2 */ }
|
| 'i' { {semi;} no_semi /* TEST:Y:2 */ }
|
||||||
;
|
;
|
||||||
test1
|
test1
|
||||||
: 'a' { semi; // TEST:N:1 ;
|
: 'a' { semi; // TEST:N:1 ;
|
||||||
} | 'b' { if (0) {no_semi} // TEST:N:1 ;
|
} | 'b' { if (0) {no_semi} // TEST:N:1 ;
|
||||||
} | 'c' { if (0) {semi;} // TEST:N:1 ;
|
} | 'c' { if (0) {semi;} // TEST:N:1 ;
|
||||||
} | 'd' { semi; no_semi // TEST:Y:1 ;
|
} | 'd' { semi; no_semi // TEST:Y:1 ;
|
||||||
} | 'e' { semi(); no_semi() // TEST:Y:1 ;
|
} | 'e' { semi(); no_semi() // TEST:Y:1 ;
|
||||||
} | 'f' { semi[]; no_semi[] // TEST:Y:1 ;
|
} | 'f' { semi[]; no_semi[] // TEST:Y:1 ;
|
||||||
} | 'g' { semi++; no_semi++ // TEST:Y:1 ;
|
} | 'g' { semi++; no_semi++ // TEST:Y:1 ;
|
||||||
} | 'h' { {no_semi} no_semi // TEST:Y:1 ;
|
} | 'h' { {no_semi} no_semi // TEST:Y:1 ;
|
||||||
} | 'i' { {semi;} no_semi // TEST:Y:1 ;
|
} | 'i' { {semi;} no_semi // TEST:Y:1 ;
|
||||||
} ;
|
} ;
|
||||||
test0
|
test0
|
||||||
: 'a' { semi; // TEST:N:1 {}
|
: 'a' { semi; // TEST:N:1 {}
|
||||||
} | 'b' { if (0) {no_semi} // TEST:N:1 {}
|
} | 'b' { if (0) {no_semi} // TEST:N:1 {}
|
||||||
} | 'c' { if (0) {semi;} // TEST:N:1 {}
|
} | 'c' { if (0) {semi;} // TEST:N:1 {}
|
||||||
} | 'd' { semi; no_semi // TEST:Y:1 {}
|
} | 'd' { semi; no_semi // TEST:Y:1 {}
|
||||||
} | 'e' { semi(); no_semi() // TEST:Y:1 {}
|
} | 'e' { semi(); no_semi() // TEST:Y:1 {}
|
||||||
} | 'f' { semi[]; no_semi[] // TEST:Y:1 {}
|
} | 'f' { semi[]; no_semi[] // TEST:Y:1 {}
|
||||||
} | 'g' { semi++; no_semi++ // TEST:Y:1 {}
|
} | 'g' { semi++; no_semi++ // TEST:Y:1 {}
|
||||||
} | 'h' { {no_semi} no_semi // TEST:Y:1 {}
|
} | 'h' { {no_semi} no_semi // TEST:Y:1 {}
|
||||||
} | 'i' { {semi;} no_semi // TEST:Y:1 {}
|
} | 'i' { {semi;} no_semi // TEST:Y:1 {}
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
testc
|
testc
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# @configure_input@ -*- shell-script -*-
|
# @configure_input@ -*- shell-script -*-
|
||||||
# Configurable variable values for Bison test suite.
|
# Configurable variable values for Bison test suite.
|
||||||
|
|
||||||
# Copyright (C) 2000-2011 Free Software Foundation, Inc.
|
# Copyright (C) 2000-2011 Free Software Foundation, Inc.
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ m4_define([AT_CHECK_DOXYGEN],
|
|||||||
[m4_case([$1],
|
[m4_case([$1],
|
||||||
[Public], [m4_pushdef([AT_DOXYGEN_PRIVATE], [NO])],
|
[Public], [m4_pushdef([AT_DOXYGEN_PRIVATE], [NO])],
|
||||||
[Private], [m4_pushdef([AT_DOXYGEN_PRIVATE], [YES])],
|
[Private], [m4_pushdef([AT_DOXYGEN_PRIVATE], [YES])],
|
||||||
[m4_fatal([invalid argument: $1])])
|
[m4_fatal([invalid argument: $1])])
|
||||||
AT_SETUP([Doxygen $1 Documentation])
|
AT_SETUP([Doxygen $1 Documentation])
|
||||||
|
|
||||||
AT_DATA([input.yy],
|
AT_DATA([input.yy],
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ int yylex (]AT_LEX_FORMALS[);
|
|||||||
%token <ival> NUM "number"
|
%token <ival> NUM "number"
|
||||||
%type <ival> exp
|
%type <ival> exp
|
||||||
|
|
||||||
%nonassoc '=' /* comparison */
|
%nonassoc '=' /* comparison */
|
||||||
%left '-' '+'
|
%left '-' '+'
|
||||||
%left '*' '/'
|
%left '*' '/'
|
||||||
%precedence NEG /* negation--unary minus */
|
%precedence NEG /* negation--unary minus */
|
||||||
@@ -332,10 +332,10 @@ AT_YYERROR_SEES_LOC_IF([
|
|||||||
AT_LOC_FIRST_LINE, AT_LOC_FIRST_COLUMN);
|
AT_LOC_FIRST_LINE, AT_LOC_FIRST_COLUMN);
|
||||||
if (AT_LOC_FIRST_LINE != AT_LOC_LAST_LINE)
|
if (AT_LOC_FIRST_LINE != AT_LOC_LAST_LINE)
|
||||||
fprintf (stderr, "-%d.%d",
|
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)
|
else if (AT_LOC_FIRST_COLUMN != AT_LOC_LAST_COLUMN - 1)
|
||||||
fprintf (stderr, "-%d",
|
fprintf (stderr, "-%d",
|
||||||
AT_LOC_LAST_COLUMN - 1);
|
AT_LOC_LAST_COLUMN - 1);
|
||||||
fprintf (stderr, ": ");])
|
fprintf (stderr, ": ");])
|
||||||
fprintf (stderr, "%s\n", s);
|
fprintf (stderr, "%s\n", s);
|
||||||
}])[
|
}])[
|
||||||
|
|||||||
@@ -92,35 +92,35 @@ $1
|
|||||||
|
|
||||||
prog :
|
prog :
|
||||||
| prog stmt {
|
| prog stmt {
|
||||||
char *output;]AT_LOCATION_IF([
|
char *output;]AT_LOCATION_IF([
|
||||||
printf ("%d.%d-%d.%d: ",
|
printf ("%d.%d-%d.%d: ",
|
||||||
@2.first_line, @2.first_column,
|
@2.first_line, @2.first_column,
|
||||||
@2.last_line, @2.last_column);])[
|
@2.last_line, @2.last_column);])[
|
||||||
output = node_to_string (]$[2);
|
output = node_to_string (]$[2);
|
||||||
printf ("%s\n", output);
|
printf ("%s\n", output);
|
||||||
free (output);
|
free (output);
|
||||||
free_node (]$[2);
|
free_node (]$[2);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
stmt : expr ';' $2 { $$ = ]$[1; }
|
stmt : expr ';' $2 { $$ = ]$[1; }
|
||||||
| decl $3
|
| decl $3
|
||||||
| error ';' { $$ = new_nterm ("<error>", 0, 0, 0); }
|
| error ';' { $$ = new_nterm ("<error>", 0, 0, 0); }
|
||||||
| '@' { YYACCEPT; }
|
| '@' { YYACCEPT; }
|
||||||
;
|
;
|
||||||
|
|
||||||
expr : ID
|
expr : ID
|
||||||
| TYPENAME '(' expr ')'
|
| TYPENAME '(' expr ')'
|
||||||
{ $$ = new_nterm ("<cast>(%s,%s)", ]$[3, ]$[1, 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); }
|
||||||
| expr '=' expr { $$ = new_nterm ("=(%s,%s)", ]$[1, ]$[3, 0); }
|
| expr '=' expr { $$ = new_nterm ("=(%s,%s)", ]$[1, ]$[3, 0); }
|
||||||
;
|
;
|
||||||
|
|
||||||
decl : TYPENAME declarator ';'
|
decl : TYPENAME declarator ';'
|
||||||
{ $$ = new_nterm ("<declare>(%s,%s)", ]$[1, ]$[2, 0); }
|
{ $$ = new_nterm ("<declare>(%s,%s)", ]$[1, ]$[2, 0); }
|
||||||
| TYPENAME declarator '=' expr ';'
|
| TYPENAME declarator '=' expr ';'
|
||||||
{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", ]$[1,
|
{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", ]$[1,
|
||||||
]$[2, ]$[4); }
|
]$[2, ]$[4); }
|
||||||
;
|
;
|
||||||
|
|
||||||
declarator : ID
|
declarator : ID
|
||||||
@@ -163,60 +163,60 @@ yylex (LEX_PARAMETERS)
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (feof (stdin))
|
if (feof (stdin))
|
||||||
abort ();
|
abort ();
|
||||||
c = getchar ();
|
c = getchar ();
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case EOF:
|
case EOF:
|
||||||
return 0;
|
return 0;
|
||||||
case '\t':
|
case '\t':
|
||||||
colNum = (colNum + 7) & ~7;
|
colNum = (colNum + 7) & ~7;
|
||||||
break;
|
break;
|
||||||
case ' ': case '\f':
|
case ' ': case '\f':
|
||||||
colNum += 1;
|
colNum += 1;
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
lineNum += 1;
|
lineNum += 1;
|
||||||
colNum = 0;
|
colNum = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
int tok;
|
int tok;
|
||||||
#if YYLSP_NEEDED
|
#if YYLSP_NEEDED
|
||||||
yylloc.first_line = yylloc.last_line = lineNum;
|
yylloc.first_line = yylloc.last_line = lineNum;
|
||||||
yylloc.first_column = colNum;
|
yylloc.first_column = colNum;
|
||||||
#endif
|
#endif
|
||||||
if (isalpha (c))
|
if (isalpha (c))
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
buffer[i++] = c;
|
buffer[i++] = c;
|
||||||
colNum += 1;
|
colNum += 1;
|
||||||
if (i == sizeof buffer - 1)
|
if (i == sizeof buffer - 1)
|
||||||
abort ();
|
abort ();
|
||||||
c = getchar ();
|
c = getchar ();
|
||||||
}
|
}
|
||||||
while (isalnum (c) || c == '_');
|
while (isalnum (c) || c == '_');
|
||||||
|
|
||||||
ungetc (c, stdin);
|
ungetc (c, stdin);
|
||||||
buffer[i++] = 0;
|
buffer[i++] = 0;
|
||||||
tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
|
tok = isupper ((unsigned char) buffer[0]) ? TYPENAME : ID;
|
||||||
yylval = new_term (strcpy ((char *) malloc (i), buffer));
|
yylval = new_term (strcpy ((char *) malloc (i), buffer));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
colNum += 1;
|
colNum += 1;
|
||||||
tok = c;
|
tok = c;
|
||||||
yylval = 0;
|
yylval = 0;
|
||||||
}
|
}
|
||||||
#if YYLSP_NEEDED
|
#if YYLSP_NEEDED
|
||||||
yylloc.last_column = colNum-1;
|
yylloc.last_column = colNum-1;
|
||||||
#endif
|
#endif
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +298,7 @@ node_to_string (Node *node)
|
|||||||
child1 = node_to_string (node->nterm.children[1]);
|
child1 = node_to_string (node->nterm.children[1]);
|
||||||
child2 = node_to_string (node->nterm.children[2]);
|
child2 = node_to_string (node->nterm.children[2]);
|
||||||
buffer = (char *) malloc (strlen (node->nterm.form) + strlen (child0)
|
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);
|
sprintf (buffer, node->nterm.form, child0, child1, child2);
|
||||||
free (child0);
|
free (child0);
|
||||||
free (child1);
|
free (child1);
|
||||||
@@ -412,61 +412,61 @@ m4_define([_AT_VERBOSE_GLR_STDERR],
|
|||||||
|
|
||||||
AT_SETUP([GLR: Resolve ambiguity, impure, no locations])
|
AT_SETUP([GLR: Resolve ambiguity, impure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([],
|
_AT_TEST_GLR_CXXTYPES([],
|
||||||
[%dprec 1], [%dprec 2])
|
[%dprec 1], [%dprec 2])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
|
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Resolve ambiguity, impure, locations])
|
AT_SETUP([GLR: Resolve ambiguity, impure, locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%locations],[%dprec 1],[%dprec 2])
|
_AT_TEST_GLR_CXXTYPES([%locations],[%dprec 1],[%dprec 2])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
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_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Resolve ambiguity, pure, no locations])
|
AT_SETUP([GLR: Resolve ambiguity, pure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define api.pure],
|
_AT_TEST_GLR_CXXTYPES([%define api.pure],
|
||||||
[%dprec 1], [%dprec 2])
|
[%dprec 1], [%dprec 2])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
|
_AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR)
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Resolve ambiguity, pure, locations])
|
AT_SETUP([GLR: Resolve ambiguity, pure, locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define api.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_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_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Merge conflicting parses, impure, no locations])
|
AT_SETUP([GLR: Merge conflicting parses, impure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([],
|
_AT_TEST_GLR_CXXTYPES([],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
|
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Merge conflicting parses, impure, locations])
|
AT_SETUP([GLR: Merge conflicting parses, impure, locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%locations],
|
_AT_TEST_GLR_CXXTYPES([%locations],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
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_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Merge conflicting parses, pure, no locations])
|
AT_SETUP([GLR: Merge conflicting parses, pure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define api.pure],
|
_AT_TEST_GLR_CXXTYPES([%define api.pure],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
AT_PARSER_CHECK([[./types test-input]], 0,
|
||||||
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
|
_AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR)
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
AT_SETUP([GLR: Merge conflicting parses, pure, locations])
|
AT_SETUP([GLR: Merge conflicting parses, pure, locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%define api.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_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_CLEANUP
|
||||||
|
|
||||||
AT_SETUP([GLR: Verbose messages, resolve ambiguity, impure, no locations])
|
AT_SETUP([GLR: Verbose messages, resolve ambiguity, impure, no locations])
|
||||||
_AT_TEST_GLR_CXXTYPES([%error-verbose],
|
_AT_TEST_GLR_CXXTYPES([%error-verbose],
|
||||||
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
[%merge <stmtMerge>], [%merge <stmtMerge>])
|
||||||
AT_PARSER_CHECK([[./types test-input]], 0,
|
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
|
AT_CLEANUP
|
||||||
|
|||||||
1954
tests/existing.at
1954
tests/existing.at
File diff suppressed because it is too large
Load Diff
@@ -85,12 +85,12 @@ yylex (void)
|
|||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
if (feof (stdin))
|
if (feof (stdin))
|
||||||
abort ();
|
abort ();
|
||||||
ch = getchar ();
|
ch = getchar ();
|
||||||
if (ch == EOF)
|
if (ch == EOF)
|
||||||
return 0;
|
return 0;
|
||||||
else if (ch == 'B' || ch == 'P')
|
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>. ##
|
## <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>. ##
|
## <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>. ##
|
## <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>. ##
|
## <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 ##
|
## 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 ##
|
## 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 ##
|
## 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
|
PortClause : T_PORT InterfaceDeclaration T_PORT
|
||||||
{ printf("%d/%d - %d/%d - %d/%d\n",
|
{ printf("%d/%d - %d/%d - %d/%d\n",
|
||||||
@1.first_column, @1.last_column,
|
@1.first_column, @1.last_column,
|
||||||
@2.first_column, @2.last_column,
|
@2.first_column, @2.last_column,
|
||||||
@3.first_column, @3.last_column); }
|
@3.first_column, @3.last_column); }
|
||||||
;
|
;
|
||||||
|
|
||||||
InterfaceDeclaration : OptConstantWord %dprec 1
|
InterfaceDeclaration : OptConstantWord %dprec 1
|
||||||
| OptSignalWord %dprec 2
|
| OptSignalWord %dprec 2
|
||||||
;
|
;
|
||||||
|
|
||||||
OptConstantWord : /* empty */
|
OptConstantWord : /* empty */
|
||||||
| T_CONSTANT
|
| T_CONSTANT
|
||||||
;
|
;
|
||||||
|
|
||||||
OptSignalWord : /* empty */
|
OptSignalWord : /* empty */
|
||||||
{ printf("empty: %d/%d\n", @$.first_column, @$.last_column); }
|
{ printf("empty: %d/%d\n", @$.first_column, @$.last_column); }
|
||||||
| T_SIGNAL
|
| 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>. ##
|
## <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])
|
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])
|
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])
|
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/help-bison/2005-07/msg00017.html> and ##
|
||||||
## <http://lists.gnu.org/archive/html/bison-patches/2006-01/msg00060.html>. ##
|
## <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);
|
printf ("'%c', yylval='", yychar);
|
||||||
if (yylval.value > ' ')
|
if (yylval.value > ' ')
|
||||||
printf ("%c", yylval.value);
|
printf ("%c", yylval.value);
|
||||||
printf ("', yylloc=(%d,%d),(%d,%d)",
|
printf ("', yylloc=(%d,%d),(%d,%d)",
|
||||||
yylloc.first_line, yylloc.first_column,
|
yylloc.first_line, yylloc.first_column,
|
||||||
yylloc.last_line, yylloc.last_column);
|
yylloc.last_line, yylloc.last_column);
|
||||||
}
|
}
|
||||||
printf ("\n");
|
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])
|
AT_SETUP([Incorrect lookahead during nondeterministic GLR])
|
||||||
@@ -1318,7 +1318,7 @@ merge:
|
|||||||
| conflict defstate_look 'a' nonconflict2 'b' defstate_shift %dprec 2 {
|
| conflict defstate_look 'a' nonconflict2 'b' defstate_shift %dprec 2 {
|
||||||
USE ($3); USE ($5);
|
USE ($3); USE ($5);
|
||||||
print_lookahead ("merge <- conflict defstate_look 'a' nonconflict2 'b'"
|
print_lookahead ("merge <- conflict defstate_look 'a' nonconflict2 'b'"
|
||||||
" defstate_shift");
|
" defstate_shift");
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -1365,7 +1365,7 @@ alt1:
|
|||||||
USE ($1);
|
USE ($1);
|
||||||
if (yychar != 'd' && yychar != YYEOF)
|
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);
|
USE ($1);
|
||||||
if (yychar != 'd' && yychar != YYEOF)
|
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);
|
USE ($1);
|
||||||
if (yychar != 'd' && yychar != YYEOF)
|
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)
|
if (yychar != YYEMPTY)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Found lookahead where shouldn't during stack explosion.\n");
|
"Found lookahead where shouldn't during stack explosion.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@@ -1430,10 +1430,10 @@ print_lookahead (char const *reduction)
|
|||||||
{
|
{
|
||||||
printf ("'%c', yylval='", yychar);
|
printf ("'%c', yylval='", yychar);
|
||||||
if (yylval.value > ' ')
|
if (yylval.value > ' ')
|
||||||
printf ("%c", yylval.value);
|
printf ("%c", yylval.value);
|
||||||
printf ("', yylloc=(%d,%d),(%d,%d)",
|
printf ("', yylloc=(%d,%d),(%d,%d)",
|
||||||
yylloc.first_line, yylloc.first_column,
|
yylloc.first_line, yylloc.first_column,
|
||||||
yylloc.last_line, yylloc.last_column);
|
yylloc.last_line, yylloc.last_column);
|
||||||
}
|
}
|
||||||
printf ("\n");
|
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])
|
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])
|
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])
|
AT_SETUP([Uninitialized location when reporting ambiguity])
|
||||||
@@ -1690,7 +1690,7 @@ static void
|
|||||||
yyerror (YYLTYPE *locp, char const *msg)
|
yyerror (YYLTYPE *locp, char const *msg)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Error at %d.%d-%d.%d: %s.\n", locp->first_line,
|
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
|
static int
|
||||||
|
|||||||
@@ -418,8 +418,8 @@ AT_JAVA_COMPILE([[YYParser.java]])
|
|||||||
|
|
||||||
|
|
||||||
# AT_CHECK_JAVA_MINIMAL_W_LEXER([1:DIRECTIVES], [2:LEX_THROWS],
|
# AT_CHECK_JAVA_MINIMAL_W_LEXER([1:DIRECTIVES], [2:LEX_THROWS],
|
||||||
# [3:YYLEX_ACTION], [4:LEXER_BODY], [5:PARSER_ACTION], [6:STYPE],
|
# [3:YYLEX_ACTION], [4:LEXER_BODY], [5:PARSER_ACTION], [6:STYPE],
|
||||||
# [7:POSITION_TYPE], [8:LOCATION_TYPE])
|
# [7:POSITION_TYPE], [8:LOCATION_TYPE])
|
||||||
# ---------------------------------------------------------------------
|
# ---------------------------------------------------------------------
|
||||||
# Check that a mininal parser with DIRECTIVES and a "%code lexer".
|
# Check that a mininal parser with DIRECTIVES and a "%code lexer".
|
||||||
# YYLEX is the body of yylex () which throws LEX_THROW.
|
# 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$
|
# Check that YYParser.java contains exactly COUNT lines matching ^LINE$
|
||||||
# with grep.
|
# with grep.
|
||||||
m4_define([AT_CHECK_JAVA_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])
|
AT_SETUP([Java throws specifications])
|
||||||
|
|
||||||
# %define throws - 0 1 2
|
# %define throws - 0 1 2
|
||||||
# %define lex-throws - 0 1 2
|
# %define lex-throws - 0 1 2
|
||||||
# %code lexer 0 1
|
# %code lexer 0 1
|
||||||
|
|
||||||
m4_define([AT_JT_lex_throws_define], [m4_case(AT_JT_lex_throws,
|
m4_define([AT_JT_lex_throws_define], [m4_case(AT_JT_lex_throws,
|
||||||
-1, [],
|
-1, [],
|
||||||
0, [[%define lex_throws ""]],
|
0, [[%define lex_throws ""]],
|
||||||
1, [[%define lex_throws "InterruptedException"]],
|
1, [[%define lex_throws "InterruptedException"]],
|
||||||
2, [[%define lex_throws "InterruptedException, IllegalAccessException"]])])
|
2, [[%define lex_throws "InterruptedException, IllegalAccessException"]])])
|
||||||
|
|
||||||
m4_define([AT_JT_yylex_throws], [m4_case(AT_JT_lex_throws,
|
m4_define([AT_JT_yylex_throws], [m4_case(AT_JT_lex_throws,
|
||||||
-1, [[ throws java.io.IOException]],
|
-1, [[ throws java.io.IOException]],
|
||||||
0, [],
|
0, [],
|
||||||
1, [[ throws InterruptedException]],
|
1, [[ throws InterruptedException]],
|
||||||
2, [[ throws InterruptedException, IllegalAccessException]])])
|
2, [[ throws InterruptedException, IllegalAccessException]])])
|
||||||
|
|
||||||
m4_define([AT_JT_yylex_action], [m4_case(AT_JT_lex_throws,
|
m4_define([AT_JT_yylex_action], [m4_case(AT_JT_lex_throws,
|
||||||
-1, [[throw new java.io.IOException();]],
|
-1, [[throw new java.io.IOException();]],
|
||||||
0, [[return EOF;]],
|
0, [[return EOF;]],
|
||||||
1, [[throw new InterruptedException();]],
|
1, [[throw new InterruptedException();]],
|
||||||
2, [[throw new IllegalAccessException();]])])
|
2, [[throw new IllegalAccessException();]])])
|
||||||
|
|
||||||
|
|
||||||
m4_define([AT_JT_throws_define], [m4_case(AT_JT_throws,
|
m4_define([AT_JT_throws_define], [m4_case(AT_JT_throws,
|
||||||
-1, [],
|
-1, [],
|
||||||
0, [[%define throws ""]],
|
0, [[%define throws ""]],
|
||||||
1, [[%define throws "ClassNotFoundException"]],
|
1, [[%define throws "ClassNotFoundException"]],
|
||||||
2, [[%define throws "ClassNotFoundException, InstantiationException"]])])
|
2, [[%define throws "ClassNotFoundException, InstantiationException"]])])
|
||||||
|
|
||||||
m4_define([AT_JT_yyaction_throws], [m4_case(AT_JT_throws,
|
m4_define([AT_JT_yyaction_throws], [m4_case(AT_JT_throws,
|
||||||
-1, [],
|
-1, [],
|
||||||
0, [],
|
0, [],
|
||||||
1, [[ throws ClassNotFoundException]],
|
1, [[ throws ClassNotFoundException]],
|
||||||
2, [[ throws ClassNotFoundException, InstantiationException]])])
|
2, [[ throws ClassNotFoundException, InstantiationException]])])
|
||||||
|
|
||||||
m4_define([AT_JT_parse_throws_2], [m4_case(AT_JT_throws,
|
m4_define([AT_JT_parse_throws_2], [m4_case(AT_JT_throws,
|
||||||
-1, [],
|
-1, [],
|
||||||
0, [],
|
0, [],
|
||||||
1, [[, ClassNotFoundException]],
|
1, [[, ClassNotFoundException]],
|
||||||
2, [[, ClassNotFoundException, InstantiationException]])])
|
2, [[, ClassNotFoundException, InstantiationException]])])
|
||||||
|
|
||||||
m4_define([AT_JT_parse_throws],
|
m4_define([AT_JT_parse_throws],
|
||||||
[m4_if(m4_quote(AT_JT_yylex_throws), [],
|
[m4_if(m4_quote(AT_JT_yylex_throws), [],
|
||||||
[AT_JT_yyaction_throws],
|
[AT_JT_yyaction_throws],
|
||||||
[AT_JT_yylex_throws[]AT_JT_parse_throws_2])])
|
[AT_JT_yylex_throws[]AT_JT_parse_throws_2])])
|
||||||
|
|
||||||
m4_define([AT_JT_initial_action], [m4_case(AT_JT_throws,
|
m4_define([AT_JT_initial_action], [m4_case(AT_JT_throws,
|
||||||
-1, [],
|
-1, [],
|
||||||
0, [],
|
0, [],
|
||||||
1, [[%initial-action {if (true) throw new ClassNotFoundException();}]],
|
1, [[%initial-action {if (true) throw new ClassNotFoundException();}]],
|
||||||
2, [[%initial-action {if (true) throw new InstantiationException();}]])])
|
2, [[%initial-action {if (true) throw new InstantiationException();}]])])
|
||||||
|
|
||||||
m4_define([AT_JT_parse_action], [m4_case(AT_JT_throws,
|
m4_define([AT_JT_parse_action], [m4_case(AT_JT_throws,
|
||||||
-1, [],
|
-1, [],
|
||||||
0, [],
|
0, [],
|
||||||
1, [[throw new ClassNotFoundException();]],
|
1, [[throw new ClassNotFoundException();]],
|
||||||
2, [[throw new ClassNotFoundException();]])])
|
2, [[throw new ClassNotFoundException();]])])
|
||||||
|
|
||||||
m4_for([AT_JT_lexer], 0, 1, 1,
|
m4_for([AT_JT_lexer], 0, 1, 1,
|
||||||
[m4_for([AT_JT_lex_throws], -1, 2, 1,
|
[m4_for([AT_JT_lex_throws], -1, 2, 1,
|
||||||
[m4_for([AT_JT_throws], -1, 2, 1,
|
[m4_for([AT_JT_throws], -1, 2, 1,
|
||||||
[m4_if(AT_JT_lexer, 0,
|
[m4_if(AT_JT_lexer, 0,
|
||||||
[AT_CHECK_JAVA_MINIMAL([
|
[AT_CHECK_JAVA_MINIMAL([
|
||||||
AT_JT_throws_define
|
AT_JT_throws_define
|
||||||
AT_JT_lex_throws_define
|
AT_JT_lex_throws_define
|
||||||
AT_JT_initial_action],
|
AT_JT_initial_action],
|
||||||
[AT_JT_parse_action])],
|
[AT_JT_parse_action])],
|
||||||
[AT_CHECK_JAVA_MINIMAL_W_LEXER([
|
[AT_CHECK_JAVA_MINIMAL_W_LEXER([
|
||||||
AT_JT_throws_define
|
AT_JT_throws_define
|
||||||
AT_JT_lex_throws_define
|
AT_JT_lex_throws_define
|
||||||
AT_JT_initial_action],
|
AT_JT_initial_action],
|
||||||
|
|||||||
@@ -116,34 +116,34 @@ m4_pushdef([AT_TOKEN_PREFIX],
|
|||||||
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
|
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
|
||||||
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
|
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
|
||||||
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
|
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
|
||||||
[$2])])
|
[$2])])
|
||||||
# yyerror always sees the locations (when activated), except if
|
# yyerror always sees the locations (when activated), except if
|
||||||
# (yacc & pure & !param). FIXME: This is wrong. See the manual.
|
# (yacc & pure & !param). FIXME: This is wrong. See the manual.
|
||||||
m4_pushdef([AT_YYERROR_SEES_LOC_IF],
|
m4_pushdef([AT_YYERROR_SEES_LOC_IF],
|
||||||
[AT_LOCATION_IF([AT_YACC_IF([AT_PURE_IF([AT_PARAM_IF([$1], [$2])],
|
[AT_LOCATION_IF([AT_YACC_IF([AT_PURE_IF([AT_PARAM_IF([$1], [$2])],
|
||||||
[$1])],
|
[$1])],
|
||||||
[$1])],
|
[$1])],
|
||||||
[$2])])
|
[$2])])
|
||||||
|
|
||||||
# The interface is pure: either because %define api.pure, or because we
|
# The interface is pure: either because %define api.pure, or because we
|
||||||
# are using the C++ parsers.
|
# are using the C++ parsers.
|
||||||
m4_pushdef([AT_PURE_LEX_IF],
|
m4_pushdef([AT_PURE_LEX_IF],
|
||||||
[AT_PURE_IF([$1],
|
[AT_PURE_IF([$1],
|
||||||
[AT_SKEL_CC_IF([$1], [$2])])])
|
[AT_SKEL_CC_IF([$1], [$2])])])
|
||||||
|
|
||||||
AT_PURE_LEX_IF(
|
AT_PURE_LEX_IF(
|
||||||
[m4_pushdef([AT_LOC], [(*llocp)])
|
[m4_pushdef([AT_LOC], [(*llocp)])
|
||||||
m4_pushdef([AT_VAL], [(*lvalp)])
|
m4_pushdef([AT_VAL], [(*lvalp)])
|
||||||
m4_pushdef([AT_LEX_FORMALS],
|
m4_pushdef([AT_LEX_FORMALS],
|
||||||
[YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])])
|
[YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])])
|
||||||
m4_pushdef([AT_LEX_ARGS],
|
m4_pushdef([AT_LEX_ARGS],
|
||||||
[lvalp[]AT_LOCATION_IF([, llocp])])
|
[lvalp[]AT_LOCATION_IF([, llocp])])
|
||||||
m4_pushdef([AT_USE_LEX_ARGS],
|
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],
|
m4_pushdef([AT_LEX_PRE_FORMALS],
|
||||||
[AT_LEX_FORMALS, ])
|
[AT_LEX_FORMALS, ])
|
||||||
m4_pushdef([AT_LEX_PRE_ARGS],
|
m4_pushdef([AT_LEX_PRE_ARGS],
|
||||||
[AT_LEX_ARGS, ])
|
[AT_LEX_ARGS, ])
|
||||||
],
|
],
|
||||||
[m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]])
|
[m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]])
|
||||||
m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]])
|
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.
|
# assume that we are linking too; this is a hack.
|
||||||
m4_define([AT_COMPILE],
|
m4_define([AT_COMPILE],
|
||||||
[AT_CHECK([$CC $CFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.c])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
|
[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])
|
# AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc])
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
@@ -428,7 +428,7 @@ m4_define([AT_COMPILE_CXX],
|
|||||||
[AT_KEYWORDS(c++)
|
[AT_KEYWORDS(c++)
|
||||||
AT_CHECK([$BISON_CXX_WORKS], 0, ignore, ignore)
|
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])],
|
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)
|
# AT_JAVA_COMPILE(SOURCES)
|
||||||
# ------------------------
|
# ------------------------
|
||||||
|
|||||||
@@ -40,27 +40,27 @@ $(top_srcdir)/tests/package.m4: $(top_srcdir)/configure
|
|||||||
## Test suite. ##
|
## Test suite. ##
|
||||||
## ------------ ##
|
## ------------ ##
|
||||||
|
|
||||||
TESTSUITE_AT = \
|
TESTSUITE_AT = \
|
||||||
tests/actions.at \
|
tests/actions.at \
|
||||||
tests/c++.at \
|
tests/c++.at \
|
||||||
tests/calc.at \
|
tests/calc.at \
|
||||||
tests/conflicts.at \
|
tests/conflicts.at \
|
||||||
tests/cxx-type.at \
|
tests/cxx-type.at \
|
||||||
tests/existing.at \
|
tests/existing.at \
|
||||||
tests/glr-regression.at \
|
tests/glr-regression.at \
|
||||||
tests/headers.at \
|
tests/headers.at \
|
||||||
tests/input.at \
|
tests/input.at \
|
||||||
tests/java.at \
|
tests/java.at \
|
||||||
tests/local.at \
|
tests/local.at \
|
||||||
tests/named-refs.at \
|
tests/named-refs.at \
|
||||||
tests/output.at \
|
tests/output.at \
|
||||||
tests/push.at \
|
tests/push.at \
|
||||||
tests/reduce.at \
|
tests/reduce.at \
|
||||||
tests/regression.at \
|
tests/regression.at \
|
||||||
tests/sets.at \
|
tests/sets.at \
|
||||||
tests/skeletons.at \
|
tests/skeletons.at \
|
||||||
tests/synclines.at \
|
tests/synclines.at \
|
||||||
tests/testsuite.at \
|
tests/testsuite.at \
|
||||||
tests/torture.at
|
tests/torture.at
|
||||||
|
|
||||||
TESTSUITE = $(top_srcdir)/tests/testsuite
|
TESTSUITE = $(top_srcdir)/tests/testsuite
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ int yylex (void);
|
|||||||
%token <ival> NUM "number"
|
%token <ival> NUM "number"
|
||||||
%type <ival> exp
|
%type <ival> exp
|
||||||
|
|
||||||
%nonassoc '=' /* comparison */
|
%nonassoc '=' /* comparison */
|
||||||
%left '-' '+'
|
%left '-' '+'
|
||||||
%left '*' '/'
|
%left '*' '/'
|
||||||
%precedence NEG /* negation--unary minus */
|
%precedence NEG /* negation--unary minus */
|
||||||
@@ -215,7 +215,7 @@ int yylex (void);
|
|||||||
%token <ival> NUM "number"
|
%token <ival> NUM "number"
|
||||||
%type <ival> exp
|
%type <ival> exp
|
||||||
|
|
||||||
%nonassoc '=' /* comparison */
|
%nonassoc '=' /* comparison */
|
||||||
%left '-' '+'
|
%left '-' '+'
|
||||||
%left '*' '/'
|
%left '*' '/'
|
||||||
%precedence NEG /* negation--unary minus */
|
%precedence NEG /* negation--unary minus */
|
||||||
|
|||||||
@@ -42,65 +42,65 @@ AT_CLEANUP
|
|||||||
])
|
])
|
||||||
|
|
||||||
AT_CHECK_OUTPUT([foo.y], [], [-dv],
|
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
|
# 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
|
# "fgrep: write error: Bad file descriptor" when stdout is closed, so we
|
||||||
# skip this test group during maintainer-check-valgrind.
|
# skip this test group during maintainer-check-valgrind.
|
||||||
AT_CHECK_OUTPUT([foo.y], [], [-dv],
|
AT_CHECK_OUTPUT([foo.y], [], [-dv],
|
||||||
[foo.output foo.tab.c foo.tab.h],
|
[foo.output foo.tab.c foo.tab.h],
|
||||||
[>&-], [],
|
[>&-], [],
|
||||||
[AT_CHECK([[case "$PREBISON" in *valgrind*) exit 77;; esac]])])
|
[AT_CHECK([[case "$PREBISON" in *valgrind*) exit 77;; esac]])])
|
||||||
|
|
||||||
AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
|
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],
|
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],
|
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],
|
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],
|
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], [],
|
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],[],
|
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],[],
|
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 `='
|
# Exercise %output and %file-prefix including deprecated `='
|
||||||
AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %defines %verbose], [],
|
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],[],
|
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],
|
AT_CHECK_OUTPUT([foo.y],
|
||||||
[%file-prefix="baz" %output "bar.c" %defines %verbose %yacc],
|
[%file-prefix="baz" %output "bar.c" %defines %verbose %yacc],
|
||||||
[],
|
[],
|
||||||
[bar.output bar.c bar.h])
|
[bar.output bar.c bar.h])
|
||||||
|
|
||||||
|
|
||||||
# Check priorities of extension control.
|
# Check priorities of extension control.
|
||||||
AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [],
|
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],
|
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], [],
|
AT_CHECK_OUTPUT([foo.yy], [],
|
||||||
[--defines=foo.hpp -o foo.c++],
|
[--defines=foo.hpp -o foo.c++],
|
||||||
[foo.c++ foo.hpp])
|
[foo.c++ foo.hpp])
|
||||||
|
|
||||||
AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"],
|
AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"],
|
||||||
[-o foo.c++],
|
[-o foo.c++],
|
||||||
[foo.c++ foo.hpp])
|
[foo.c++ foo.hpp])
|
||||||
|
|
||||||
AT_CHECK_OUTPUT([foo.yy], [],
|
AT_CHECK_OUTPUT([foo.yy], [],
|
||||||
[-o foo.c++ --graph=foo.gph],
|
[-o foo.c++ --graph=foo.gph],
|
||||||
[foo.c++ 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], [],
|
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], [],
|
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], [],
|
AT_CHECK_OUTPUT([subdir/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_NO_SUBDIR_PART([foo.tab])])
|
[], [AT_CHECK_NO_SUBDIR_PART([foo.tab])])
|
||||||
|
|
||||||
AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations],
|
AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations],
|
||||||
[-o subdir/foo.cc],
|
[-o subdir/foo.cc],
|
||||||
[subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh],
|
[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_NO_SUBDIR_PART([subdir/foo])])
|
||||||
|
|
||||||
AT_CHECK_OUTPUT([gram_dir/foo.yy],
|
AT_CHECK_OUTPUT([gram_dir/foo.yy],
|
||||||
[%skeleton "lalr1.cc" %defines %verbose %file-prefix "output_dir/foo"],
|
[%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],
|
AT_CHECK_OUTPUT([gram_dir/foo.yy],
|
||||||
[%skeleton "lalr1.cc" %defines %locations %verbose %file-prefix "output_dir/foo"],
|
[%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,
|
# AT_CHECK_CONFLICTING_OUTPUT(INPUT-FILE, DIRECTIVES, FLAGS, STDERR,
|
||||||
|
|||||||
@@ -532,7 +532,7 @@ AT_SETUP([Web2c Report])
|
|||||||
AT_KEYWORDS([report])
|
AT_KEYWORDS([report])
|
||||||
|
|
||||||
AT_DATA([input.y],
|
AT_DATA([input.y],
|
||||||
[[%token undef_id_tok const_id_tok
|
[[%token undef_id_tok const_id_tok
|
||||||
|
|
||||||
%start CONST_DEC_PART
|
%start CONST_DEC_PART
|
||||||
|
|
||||||
@@ -542,12 +542,12 @@ CONST_DEC_PART:
|
|||||||
;
|
;
|
||||||
|
|
||||||
CONST_DEC_LIST:
|
CONST_DEC_LIST:
|
||||||
CONST_DEC
|
CONST_DEC
|
||||||
| CONST_DEC_LIST CONST_DEC
|
| CONST_DEC_LIST CONST_DEC
|
||||||
;
|
;
|
||||||
|
|
||||||
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:
|
start:
|
||||||
{
|
{
|
||||||
printf ("Bison would once convert this action to a midrule because of the"
|
printf ("Bison would once convert this action to a midrule because of the"
|
||||||
" subsequent braced code.\n");
|
" subsequent braced code.\n");
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -288,15 +288,15 @@ mv stdout expout
|
|||||||
# Get the final state in the report, from the "accept" action..
|
# Get the final state in the report, from the "accept" action..
|
||||||
AT_CHECK([sed -n '
|
AT_CHECK([sed -n '
|
||||||
/^state \(.*\)/{
|
/^state \(.*\)/{
|
||||||
s//final state \1/
|
s//final state \1/
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
/ accept/{
|
/ accept/{
|
||||||
x
|
x
|
||||||
p
|
p
|
||||||
q
|
q
|
||||||
}
|
}
|
||||||
' input.output],
|
' input.output],
|
||||||
0, [expout])
|
0, [expout])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|||||||
@@ -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
|
# Copyright (C) 2000-2004, 2006-2007, 2009-2011 Free Software
|
||||||
# Foundation, Inc.
|
# Foundation, Inc.
|
||||||
|
|||||||
@@ -89,9 +89,9 @@ for my $size (1 .. $max)
|
|||||||
{
|
{
|
||||||
use Text::Wrap;
|
use Text::Wrap;
|
||||||
print wrap ("| ", " ",
|
print wrap ("| ", " ",
|
||||||
(map { "\"$_\"" } (1 .. $size)),
|
(map { "\"$_\"" } (1 .. $size)),
|
||||||
" END \n"),
|
" END \n"),
|
||||||
" { \$\$ = $size; }\n";
|
" { \$\$ = $size; }\n";
|
||||||
};
|
};
|
||||||
print ";\n";
|
print ";\n";
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ EOF
|
|||||||
use Text::Wrap;
|
use Text::Wrap;
|
||||||
print
|
print
|
||||||
wrap ("exp: ", " ",
|
wrap ("exp: ", " ",
|
||||||
(map { "\"$_\"" } (1 .. $max)), ";"),
|
(map { "\"$_\"" } (1 .. $max)), ";"),
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
print <<EOF;
|
print <<EOF;
|
||||||
@@ -292,8 +292,8 @@ EOF
|
|||||||
|
|
||||||
print
|
print
|
||||||
wrap ("%type <val> ",
|
wrap ("%type <val> ",
|
||||||
" ",
|
" ",
|
||||||
map { "n$_" } (1 .. $max)),
|
map { "n$_" } (1 .. $max)),
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
print "%token\n";
|
print "%token\n";
|
||||||
@@ -334,7 +334,7 @@ yylex (void)
|
|||||||
if (counter > $max)
|
if (counter > $max)
|
||||||
{
|
{
|
||||||
if (counter++ != $max + 1)
|
if (counter++ != $max + 1)
|
||||||
abort ();
|
abort ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (return_token)
|
if (return_token)
|
||||||
@@ -435,8 +435,8 @@ main (int argc, const char **argv)
|
|||||||
abort ();
|
abort ();
|
||||||
yylval_init = strtol (argv[1], &endp, 10);
|
yylval_init = strtol (argv[1], &endp, 10);
|
||||||
if (! (argv[1] != endp
|
if (! (argv[1] != endp
|
||||||
&& 0 <= yylval_init && yylval_init <= INT_MAX
|
&& 0 <= yylval_init && yylval_init <= INT_MAX
|
||||||
&& errno != ERANGE))
|
&& errno != ERANGE))
|
||||||
abort ();
|
abort ();
|
||||||
yydebug = 1;
|
yydebug = 1;
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user