Akim Demaille [Fri, 12 Oct 2012 10:39:52 +0000 (12:39 +0200)]
Merge branch 'maint'
* origin/maint:
tests: check %no-lines
tests: minor simplification
graphs: stylistic changes.
graphs: minor style changes
graphs: show reductions
graphs: style: prefix state number with "state"
graphs: style: use left justification for states
graphs: style: prefix rules and change shapes
obstack: import obstack_finish0 from master
c++: api.location.type
muscles: a function for backward compatibility
maint: more macros
* src/graphviz.c (output_red): New, show reductions on the graph.
(no_reduce_bitset_init): New, initialize a bitset.
(print_token): New, print a lookahead token.
(escape): New, print "foo" as \"foo\" because Dot doesn't like quotes within
a label.
The label text of nodes is centered "by default" (by the use of '\n' as
a line feed). This gives bad readability to the grammar rules shown in
state nodes, a left justification is much nicer. This is done by using '\l'
as the line feed.
In order to allow \l in the DOT file, changes to the quoting system seem
necessary.
* data/c++.m4, data/lalr1.cc, data/glr.cc, data/java.m4: Use
api.location.type instead of location_type.
* src/muscle-tab.c (muscle_percent_variable_update): Map the latter to
the former.
* tests/local.at: Adjust.
* tests/calc.at: Use api.location.type.
Leave tests/java.at with location_type, at least for the time being,
to cover both names.
* doc/bison.texi: Document api.location.type.
(User Defined Location Type): New.
* NEWS: Update.
Akim Demaille [Mon, 8 Oct 2012 07:17:20 +0000 (09:17 +0200)]
warnings: avoid warnings from clang
Fix the following warning
parse-gram.c:2078:14: error: equality comparison with extraneous parentheses
[-Werror,-Wparentheses-equality]
if (((yyn) == (-91)))
~~~~~~^~~~~~~~
parse-gram.c:2078:14: note: remove extraneous parentheses around the
comparison to silence this warning
if (((yyn) == (-91)))
~ ^ ~
parse-gram.c:2078:14: note: use '=' to turn this equality comparison into
an assignment
if (((yyn) == (-91)))
^~
=
1 error generated.
and the following one:
input.cc:740:1: error: function declared 'noreturn' should not return
[-Werror,-Winvalid-noreturn]
static void yyMemoryExhausted (yyGLRStack* yystackp)
__attribute__ ((__noreturn__));
static void
yyMemoryExhausted (yyGLRStack* yystackp)
{
YYLONGJMP (yystackp->yyexception_buffer, 2);
}
^
1 warning and 1 error generated.
This is Apple clang version 3.1 (tags/Apple/clang-318.0.61).
* data/c.m4 (b4_table_value_equals): Use (!!(A == B)) instead of (A == B)
to avoid this warning.
Any reasonable compiler should generate the same code.
* src/uniqstr.h (UNIQSTR_EQ): Likewise.
* data/glr.c (LONGJMP): abort after longjmp to pacify clang.
Akim Demaille [Mon, 8 Oct 2012 07:02:09 +0000 (09:02 +0200)]
tests: no longer disable -O compiler options
Tests are running without -O since f377f69fec28013c79db4efe12bbb9d48987fb2c because some warnings (about
yylval not being initialized) show only when GCC is given -O2. The
previous patch fixes the warnings. Run the test suite with compiler
options unmodified.
* tests/atlocal.in (O0CFLAGS, O0CXXFLAGS): Remove, use CFLAGS and
CXXFLAGS.
Paul Eggert [Fri, 5 Oct 2012 17:55:11 +0000 (10:55 -0700)]
yacc.c: initialize yylval in pure-parser mode
See http://lists.gnu.org/archive/html/bison-patches/2012-08/msg00024.html
(spreading over September and October).
* data/yacc.c (YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN)
(YY_IGNORE_MAYBE_UNINITIALIZED_END, YYLVAL_INITIALIZE):
New macros. Use them to suppress an unwanted GCC diagnostic.
lalr1.cc: check exception safety of error handling
* tests/c++.at (Exception safety): Don't use swap here, it
is useless.
Cover more test cases: yyerror, YYERROR, YYABORT, and
error recovery.
(Object): Instead of just keeping a counter of instances, keep
a list of them.
* tests/c++.at (Exception safety): Let the parser support the --debug
option.
On 'p', throw an exception from the %printer.
* data/lalr1.cc (yyparse): Do not display the values we discard, as it
uses %printer, which might have thrown the exception.
* data/lalr1.cc: Check size > 1, rather than size != 1, when cleaning
the stack, as at the beginning, size is 0.
* tests/c++.at (Exception safety): Check exception safety in
%initial-action.
* data/lalr1.cc (YY_SYMBOL_PRINT, YY_REDUCE_PRINT, YY_STACK_PRINT):
Define to something so that, for instance, "if (foo) YY_SYMBOL_PRINT"
is valid even when !YYDEBUG.
Bison uses "/usr/bin/perl" or "perl" in several places, and it does
not appear to be a problem. But, at least to make it simpler to
change PERL on the make command line, check for perl in configure.
* configure.ac (PERL): New.
* doc/Doxyfile.in, doc/Makefile.am, tests/bison.in: Use it.
Akim Demaille [Thu, 4 Oct 2012 15:16:00 +0000 (17:16 +0200)]
Merge branch 'maint'
* origin/maint:
maint: word changes
lalr1.cc: fix test suite portability
maint: fix an erroneous include
tests: check that headers are self contained
doc: add missing documentation for --report
Akim Demaille [Thu, 4 Oct 2012 13:36:00 +0000 (15:36 +0200)]
scan-skel: use the scanner to reject all invalid directives
* src/scan-skel.l: Use a simpler and more consistent pattern escaping
scheme.
Catch all the invalid directives here by just removing the previous
catch-all-but-alphabetical rule.
scan-skel: recognize the @directives directly in scanner
* src/scan-skel.l (at_directive, at_init): New.
(at_ptr): New, function pointer used to call the right at_directive
function (at_basename, etc.).
(outname): Rename as...
(out_name): this, for consistency with out_lineno.
errors: support indented context info in m4 macros
* TODO: Address the issue, so remove it.
* data/bison.m4: Use b4_error with [[note]] rather than a complain_at
for context information.
* src/complain.c (complain_args): Take an additional argument, an
indentation pointer, to allow the dispatching of context information.
* src/complain.h (complain_args): Adjust prototype.
* src/scan-skel.l (at_directive_perform): Recognize the new @note mark.
* tests/input.at: Adjust.
* src/complain.c (complain_at_indent): Rename as...
(complaint_indent): This, and take the location as a pointer.
* src/complain.h, src/muscle-tab.c, src/reader.c, src/scan-code.l,
src/symtab.c: Adjust.
Akim Demaille [Thu, 4 Oct 2012 07:07:42 +0000 (09:07 +0200)]
lalr1.cc: fix test suite portability
Reported by Rob Vermaas' Hydra build farm on x86_64-darwin 10.2.0 with
G++ 4.6.3.
* tests/headers.at (Several parsers): Include AT_DATA_SOURCE_PROLOGUE
in the files to compile.
* data/location.cc: Do not include twice string and iostream (once
by position.hh, and then by location.hh).
* README-hacking (Typical errors): Some hints for other maintainers.
Akim Demaille [Mon, 1 Oct 2012 15:42:39 +0000 (17:42 +0200)]
build: use gnulib's non-recursive-gnulib-prefix-hack
Suggested by Jim Meyering.
* etc/prefix-gnulib-mk: Remove, as it is now provided by...
* bootstrap.conf (modules): the non-recursive-gnulib-prefix-hack module.
* build-aux/.gitignore, configure.ac, m4/.gitignore: Adjust.
The code here was too confusing, this seems more natural.
* src/complain.c (error_message): Move the indentation check and the category
output to complains. Also, no longer take a 'warnings' argument.
(complains): Factor calls to error_message.
errors: indent "user token number redeclaration" context
This is the continuation of the work on the readability of errors
context.
* src/symtab.c (user_token_number_redeclaration): Use
complain_at_indent to output with increased indentation level.
* tests/input:at: Apply this change.
errors: don't display "warnings treated as errors"
This line doesn't add any meaningful information anymore, the appended
[-Werror=CATEGORY] is enough. It is actually more insightful, as it
allows to distinguish warnings treated as errors from those that
aren't. This line is also removed by gcc 4.8.
* src/complain.c (set_warnings_issued): The only action left was
checking if the error bit corresponding to the warning issued was set,
and that function was only called once. Therefore, remove it, and do
its job directly in the caller...
(complains): here.
* src/complains.h: Adjust.
* tests/input.at: Adjust.
* NEWS: Document this change.
The prefix of warnings treated as errors is now "error: ". Also, their
suffix now reflects the changes in the Werror option format.
An output for -Werror=other used to be:
bison: warnings being treated as errors
input.y:1.1: warning: stray ',' treated as white space [-Wother]
It is now:
bison: warnings being treated as errors
input.y:1.1: error: stray ',' treated as white space [-Werror=other]
The line "warnings being treated as errors" no longer adds any info,
it will be removed in a forthcoming change.
* NEWS: Add entry "Enhancement of the -Werror"
* doc/bison.texi: Move the warnings-as-error to a new bullet.
* src/complain.c (complains): Refactor, change the prefix of warnings
that are treated as errors.
(warnings_print_categories): Support for [-Werror=CATEGORY] display
* src/getargc.c (getargs): -y implies -Werror=yacc
* tests/input.at: Update expected --yacc output for coherence.
This new option is a lot more flexible than the previous one. Its
details will be discussed in the NEWS and info file, in a forthcoming
change.
If no category is specified (ie: used as simply "-Werror"), the
functionality is the same as before.
* src/complain.c (errors_flag): New variable.
(set_warning_issued): Accept warning categories as an argument.
* src/complain.h (Wall): Better definition.
* src/getargs.c (flags_argmatch): Support for the new format.
(usage): Update -Werror to -Werror[=CATEGORY] format.
* src/complain.c (errors_flag): New variable.
(set_warning_issued): Accept warning categories as an argument.
* src/complain.h (Wall): Better definition.
* src/getargs.c (flags_argmatch): Support for the new format.
(usage): Update -Werror to -Werror=[CATEGORY] format.
This improves readability. This is also what gcc does.
* NEWS: Document this change.
* src/complain.c (complain_at): Prefix all errors with "error: ".
(complain_at_indent, warn_at_indent): Do not prefix the context
information of errors, which are basically just indented errors.
* tests/conflicts.at, tests/glr-regression.at, tests/input.at,
tests/named-refs.at, tests/output.at, tests/push.at,
tests/regression.at, tests/skeletons.at: Apply this change.
errors: indent "invalid value for %define" context
This is the continuation of the work on the readability of errors
context.
For example, what used to be:
input.y:1.9-29: invalid value for %define variable 'foo' : 'bar'
input.y:1.9-29: accepted value: 'most'
is now:
input.y:1.9-29: invalid value for %define variable 'foo' : 'bar'
input.y:1.9-29: accepted value: 'most'
* src/muscle-tab.c (muscle_percent_define_check_values): Use
complain_at_indent to output with increased indentation level.
* tests/input:at: Apply this change.
This is the continuation of the work on the readability of errors
context.
For example, what used to be:
input.y:2.9-11: %define variable 'var' redefined
input.y:1.9-11: previous definition
is now:
input.y:2.9-11: %define variable 'var' redefined
input.y:1.9-11: previous definition
* src/muscle-tab.c (muscle_percent_define_insert): Use
complain_at_indent to output with increased indentation level.
* tests/input.at: Apply this change.
input.y:6.5-10: result type clash on merge function 'merge': [...]
input.y:2.4-9: previous declaration
In order to distinguish the actual error from the context provided, we
rather this new output:
input.y:6.5-10: result type clash on merge function 'merge': [...]
input.y:2.4-9: previous declaration
Another patch will introduce an "error: " prefix to all non-indented
lines, giving yet better readability to the reports.
* src/complain.h (SUB_INDENT): Move to here.
* src/reader.c (record_merge_function_type): Use complain_at_indent to
output with increased indentation level.
* src/scan-code.l (SUB_INDENT): Remove from here.
* tests/glr-regression.at: Apply this change.
warnings: use the regular interface for s/r and r/r conflicts
The current routines used to display s/r and r/r conflicts are both
inconvenient from the programmer point of view (they do not use the
warning infrastructure) and for the user (the messages are rather
terse, not necessarily pleasant to read, and because they don't use
the same routines, they look different).
It was due to the belief (dating back to the initial checked-in
version of Bison) that, at some point, POSIX Yacc mandated the format
for these messages. Today, the Open Group's manual page for Yacc,
<http://pubs.opengroup.org/onlinepubs/009695399/utilities/yacc.html>,
explicitly states that the format of these messages is unspecified.
See commit be7280480c175bed203883f524c7dcd6cf37c13d and
<http://lists.gnu.org/archive/html/bison-patches/2002-12/msg00027.html>.
For a discussion on the chosen warning format, see
http://lists.gnu.org/archive/html/bison-patches/2012-09/msg00039.html
In an effort to factor the handling of errors and warnings, use the
Bison warning routines to report these messages.
* src/conflicts.c (conflicts_print): Rewrite with clearer sections
about S/R and then R/R conflicts.
(conflict_report): Remove, inlined in its sole
caller...
(conflicts_output): here.
* tests/conflicts.at, tests/existing.at, tests/glr-regression.at,
* tests/reduce.at, tests/regression.at: Adjust the expected results.
* NEWS: Update.
yacc: fix handling of CPP guards when no header is generated
When no header was to be generated, Bison would issue:
/* In a future release of Bison, this section will be replaced
by #include "". */
#ifndef YY_
# define YY_
It now properly generates nothing.
* data/c.m4 (b4_cpp_guard_open, b4_cpp_guard_close): Issue nothing when
the file name is empty.
* data/yacc.c: Do not generate the above comment when there is no header
to generate.
* NEWS: Update.
* src/conflicts.c (conflicts_print): Complain about %expect-rr if not
in GLR mode, regardless of the number of reduce/reduce conflicts.
* tests/conflicts.at (%expect-rr non GLR): New test.
* NEWS: Update.
* src/complain.h : errors_flag variable
* src/complain.c : actual stuff happens here
* src/conflits.c : differentiated SR and RR conflicts
* src/getargs.c : flags_argmatch recognizes the new -Werror format
* origin/maint:
maint: remove useless file
update files to ignore
remove useless include
use locale-indep. c_is* functions for parsing, not isspace, isprint etc
gnulib: update
--help: include a place to report translation issues
tests: style changes
tests: fix push-pull test
yacc.c: style changes
* doc/.gitignore: Don't ignore split info files as we don't split our
info file.
See <http://lists.gnu.org/archive/html/bug-bison/2012-08/msg00006.html>.
* src/system.h: Don't include sys/types.h.
Reported by Eric Blake,
<http://lists.gnu.org/archive/html/bug-bison/2012-09/msg00002.html>.
(FUNCTION_PRINT): Remove, unused.
Jim Meyering [Sun, 5 Aug 2012 11:28:01 +0000 (13:28 +0200)]
use locale-indep. c_is* functions for parsing, not isspace, isprint etc
* src/parse-gram.y: Include "c-ctype.h".
(add_param): Parse with c_isspace, not isspace.
* src/parse-gram.c: Likewise.
* src/scan-gram.l: Include c-ctype.h, not ctype.h.
(SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER): Use c_isspace and c_isprint,
not ctype.h's locale-dependent functions.
Akim Demaille [Fri, 31 Aug 2012 16:18:13 +0000 (18:18 +0200)]
--help: include a place to report translation issues
http://lists.gnu.org/archive/html/bug-bison/2012-08/msg00007.html
shows that it is useful to help users report translation issues.
While at it, include other informative bits that the coreutils shows.
* src/getargs.c (usage): Report more URLs where the user can
refer to.
Mostly copied/pasted from coreutils' emit_ancillary_info function.