Akim Demaille [Wed, 30 Jan 2013 14:52:34 +0000 (15:52 +0100)]
build: avoid clang's colored diagnostics in the test suite
The syncline tests, which try to recognize compiler diagnostics,
are confused by escapes for colors.
* configure.ac (warn_tests): New, to factor the warnings for both
C and C++ tests.
Add -fno-color-diagnostics to it.
* tests/local.at (AT_TEST_TABLES_AND_PARSE): Do not remove glue
together compiler flags.
Reported by Rob Conde.
http://lists.gnu.org/archive/html/bug-bison/2013-03/msg00003.html
* data/c.m4 (b4_symbol_actions): Rename as...
(_b4_symbol_actions): this.
(b4_symbol_actions): New wrapper.
Do not emit empty switches.
Adjust all b4_symbol_actions callers.
Reported by Rob Conde.
http://lists.gnu.org/archive/html/bug-bison/2013-03/msg00003.html
* data/stack.hh (operator=, stack(const stack&)): Make this class
uncopyable, i.e., "undefine" these operators: make them private and
don't implement them.
(clear): New.
* data/lalr1.cc: Use it instead of an assignment.
(parser): Make this class uncopyable.
Reported by Victor Khomenko.
http://lists.gnu.org/archive/html/bug-bison/2013-04/msg00001.html
* data/glr.c (YYUSE, __attribute__): Fuse their definition into...
* data/c.m4 (b4_attribute_define): this new macro.
* data/yacc.c, data/glr.c: Use it.
Akim Demaille [Wed, 12 Dec 2012 10:37:02 +0000 (11:37 +0100)]
fix C90 compliance
* data/glr.c, src/graphviz.h, src/ielr.c, src/scan-gram.l,
* src/system.h, tests/actions.at, tests/glr-regression.at: Do not
use // comments.
Do not introduce variables after statements.
Provide "main" with a return value.
Akim Demaille [Sun, 9 Dec 2012 15:49:58 +0000 (16:49 +0100)]
doc: explain how mid-rule actions are translated
* doc/bison.texi (Actions in Mid-Rule): Mention and use named references.
Split into three subsections, among which...
(Mid-Rule Action Translation): this new section.
* src/reader.c (grammar_rule_check): When warning about the value of a
midrule action, use the location of the midrule action instead of the
location of the rule.
the location of the part of the rule.
* tests/actions.at (Default %printer and %destructor for mid-rule values):
Adjust expectations
* tests/input.at (Unused values with default %destructor): Ditto.
(AT_CHECK_UNUSED_VALUES): Ditto.
And use -fcaret.
Akim Demaille [Sat, 8 Dec 2012 15:18:07 +0000 (16:18 +0100)]
doc: various minor improvements and fixes
* doc/figs/example.dot, doc/figs/example.y: New.
* doc/bison.texi: Prefer "token" to TOKEN.
Use @group where appropriate.
Adjust with style changes in the output (State 0, not state 0).
Fix some @ref that were missing the third argument.
Fix some incorrect line numbers.
Use "nonterminal", not "non-terminal".
Fix overfull and underfull TeX hboxes.
Put the comments in the index.
Remove duplicate index entries.
Fuse glossary entries where appropriate.
(Understanding): Improve the continuity between sections.
Use example.dot to show the whole graph.
* doc/Makefile.am: Adjust.
Akim Demaille [Sat, 8 Dec 2012 18:33:50 +0000 (19:33 +0100)]
build: beware of Clang++ not supporting POSIXLY_CORRECT
* m4/c-working.m4 (BISON_LANG_COMPILER_POSIXLY_CORRECT): New.
(BISON_C_COMPILER_POSIXLY_CORRECT): Use it.
For consistency with C++, also define BISON_C_WORKS.
* m4/cxx.m4 (BISON_CXX_COMPILER_POSIXLY_CORRECT): New.
* configure.ac: Use it.
* tests/atlocal.in: Get its result.
Propagate properly CXX values when used to compile C.
When POSIXLY_CORRECT, adjust BISON_C_WORKS and BISON_CXX_WORKS.
* tests/local.at (AT_COMPILE): Use BISON_C_WORKS.
Akim Demaille [Fri, 7 Dec 2012 10:34:51 +0000 (11:34 +0100)]
build: fix syntax-check error.
* cfg.mk: Exclude names-refs, it includes a "double" if (end of first
line, first of second line below).
test.y:43.12-44.59: symbol not found in production: if
if-stmt-a: IF expr[cond] THEN stmt.list[then] ELSE stmt.list[else] FI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Akim Demaille [Fri, 7 Dec 2012 08:58:40 +0000 (09:58 +0100)]
build: keep -Wmissing-declarations and -Wmissing-prototypes for modern GCCs
Fixes a -Werror failure of xalloc.h used in src.
From Eric Blake.
http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00006.html
* configure.ac: Check whether GCC pragma diagnostic push/pop works.
Enable these warnings for bison if it does.
Enable these warnings for the test suite anyway.
* tests/actions.at: Unset value.
* tests/conflicts.at: Rule useless due to conflicts.
* tests/input.at: Missing terminator, unexpected end of file, command line
redefinition of variable.
* tests/named-refs.at: Many errors.
* tests/reduce.at: Useless nonterminals and rules.
* tests/regression.at: Large token.
Akim Demaille [Mon, 3 Dec 2012 14:29:44 +0000 (15:29 +0100)]
m4: use a safer pattern to enable/disable output
Work on some other areas of Bison revealed that some macros expanded
to be expanded only once were actually expanded several times. This
was due to the fact that changecom was not properly restored each
time, and macro names appearing in comments were then expanded.
Introduce begin/end macros which are easier to match that
changecom()/changecom(#).
Akim Demaille [Fri, 30 Nov 2012 10:19:43 +0000 (11:19 +0100)]
yacc.c, glr.c: check and fix the display of locations
In some case, negative column number could be displayed.
Make YY_LOCATION_PRINT similar to bison's own implementation of
locations. Since the macro is getting fat, make it a static
function.
Reported by Jonathan Fabrizio.
* data/c.m4 (yy_location_print_define): Improve the implementation,
and generate the yy_location_print_ function.
Adjust YY_LOCATION_PRINT.
* tests/actions.at (Location Print): New tests.
Akim Demaille [Fri, 30 Nov 2012 10:19:33 +0000 (11:19 +0100)]
formatting changes
* data/c.m4: Fix comments, put macros in a more natural order.
Space changes (from M-x whitespace-cleanup).
* src/location.c: Fix spaces.
* tests/actions.at: Space changes.
doc: introduce api.pure full, rearrange some examples
* NEWS: Add entry.
* doc/bison.texi (%define Summary): Show the old Yacc behaviour.
(Parser Function): Move parse-param examples here.
(Pure Calling): Remove parse-param examples.
(Error Reporting): Don't show the old behavior, stick to 'full'.
* tests/local.at (AT_YYERROR_FORMALS): Make llocp const.
(AT_PURE_AND_LOC_IF, AT_GLR_OR_PARAM_IF): Remove, expand...
(AT_YYERROR_ARG_LOC_IF): Here, and use m4_join for readability.
Akim Demaille [Mon, 26 Nov 2012 08:05:28 +0000 (09:05 +0100)]
Merge remote-tracking branch 'origin/branch-2.6' into maint
* origin/branch-2.6:
yacc.c: always initialize yylloc
doc: one of the fixes for an ambiguous grammar was ambiguous too
doc: fix the dangling else with precedence directives
doc: prefer "token" to TOKEN
doc: formatting changes
The initial location might be used if the parser starts by an empty
reduction, so really ensure proper initialization of the initial
location. The previous approach fails for PostgreSQL, which uses
Reported by Peter Eisentraut.
http://lists.gnu.org/archive/html/bug-bison/2012-11/msg00023.html
With help from Théophile Ranquet.
* data/yacc.c (b4_declare_scanner_communication_variables): Be sure
to initialize yylloc, even when its structure is unknown.
(yyparse): Simplify the call to b4_dollar_pushdef.
* tests/actions.at (Initial location): Check of similar pattern
as in the case of PostgreSQL.
Make the DOT produced by XSLT processing equivalent to the one made with the
--graph option.
* data/xslt/xml2dot.xsl: Stylistic changes, and add support for reductions.
* doc/bison.texi (Xml): Update.
* src/graphviz.c (conclude_red): Minor stylistic changes to DOT internals.
(output_red): Swap enabled and disabled reductions output, for coherence
with XSLT output.
* src/print_graph.c (print_core): Minor stylistic change to States' output.
(print_actions): Swap order of output for reductions and transitions.
* tests/local.at (AT_BISON_CHECK_XML): Ignore differences in order.
* tests/output.at: Adjust to changes in DOT internals.
Akim Demaille [Mon, 12 Nov 2012 08:39:41 +0000 (09:39 +0100)]
maint: address syntax-check errors.
* cfg.mk: Ignore the "error" call in tests/c++.at, it is not to be
translated.
* doc/bison.texi: Fix incorrect @pxref use.
* po/POTFILES.in: Add missing file.
* src/print_graph.c: Remove useless include.
Akim Demaille [Sat, 10 Nov 2012 08:26:40 +0000 (09:26 +0100)]
tests: use valgrind where appropriate
Reported by Théophile Ranquet.
* tests/glr-regression.at: Rewrite some test cases so that AT_PARSER_CHECK,
which runs valgrind, is exposed with the parser, not with "echo".
* tests/local.at, tests/regression.at, tests/headers.at:
Use AT_PARSER_CHECK for generated parsers.
Akim Demaille [Thu, 8 Nov 2012 18:34:29 +0000 (19:34 +0100)]
tests: don't expect $EGREP to support -w
Does not work on Solaris 10. Reported by Dennis Clarke.
http://lists.gnu.org/archive/html/bug-bison/2012-11/msg00009.html
* tests/headers.at (Several parsers): Use Perl instead.
While at it, run it only once, on all the generated headers.
Adjust to YY_NULL be defined in position.hh.
Akim Demaille [Thu, 8 Nov 2012 08:20:48 +0000 (09:20 +0100)]
Merge branch 'branch-2.6' into maint
* origin/branch-2.6:
maint: post-release administrivia
version 2.6.5
regen
tests: syntax-check
tests: beware of compilers that do not support POSIXLY_CORRECT
gnulib: update
Akim Demaille [Wed, 7 Nov 2012 16:23:06 +0000 (17:23 +0100)]
tests: beware of compilers that do not support POSIXLY_CORRECT
Running "maintainer-release-check" on OS X with Clang 2.9 fails,
because "clang-mp-2.9 -o test -g test.c" launches "/usr/bin/dsymutil
test -o test.dSYM" which fails with "error: unable to open executable
'-o'".
* m4/c-working.m4 (BISON_CHECK_WITH_POSIXLY_CORRECT)
(BISON_C_COMPILER_POSIXLY_CORRECT): New.
* configure.ac: Use the latter.
* tests/atlocal.in (POSIXLY_CORRECT_IS_EXPORTED): New.
* tests/local.at (AT_BISON_CHECK_WARNINGS_): Use it instead of computing its
value each time.
(AT_QUELL_VALGRIND): Skip tests that cannot work because of compilers
that do not support POSIXLY_CORRECT.
Akim Demaille [Tue, 6 Nov 2012 15:25:37 +0000 (16:25 +0100)]
tests: calc: modernize the use of locations
* tests/calc.at: Don't initialize the location, let the parser
do it.
Use a $printer.
Change some testing input to be easier to distinguish (instead of always
"0 0" for instance).
Akim Demaille [Tue, 6 Nov 2012 14:34:51 +0000 (15:34 +0100)]
glr.cc, yacc.c: initialize yylloc properly
There are several issues to address here. One is that yylloc should
be initialized when possible. Another is that the push parser needs
to update yypushed_loc when the user modified it. And if the parser
starts by a reduction of an empty, it uses the first location on the
stack, which, therefore, must also be initialized to this initial
location.
This is getting complex, especially since because initializing a
global (impure interface) is different from initializing a local
variable. To simplify, the local yylloc is not initialized during its
definition.
* data/c.m4 (b4_yyloc_default_define): Replace by...
(b4_yyloc_default): this.
Adjust dependencies.
* data/glr.cc: Initialize yylloc.
* data/yacc.c (b4_declare_scanner_communication_variables):
Initialize yylloc during its definition.
Don't define yyloc_default.
(yypush_parse): The location formal is not const, as we might
initialize it.
(yyparse): Define yyloc_default.
Use it before running the user initial action.
Possibly update the first location on the stack, and the pushed
location after the user initial action.
* tests/actions.at (Initial locations): Check that the initial
location is correct.
Akim Demaille [Mon, 5 Nov 2012 15:58:24 +0000 (16:58 +0100)]
yacc.c, glr.c: a better YY_LOCATION_PRINT
* data/c.m4 (b4_yy_location_print_define): New.
Now issues "short" locations, e.g., "1.1" instead of "1.1-1.1".
Was initially a function, but then we face "static but unused"
warnings.
Simpler as a macro.
* tests/local.at, data/glr.c, data/yacc.c: Use it instead of duplicating.
* tests/actions.at: Adjust expectations.
Akim Demaille [Mon, 5 Nov 2012 14:19:45 +0000 (15:19 +0100)]
yacc.c: simplify initialization
* data/yacc.c: Fuse the initializations of yyssp, yyss and the like.
Remove an obsolete comment: we do initialize these initial stack
members (in some cases).
Akim Demaille [Sat, 3 Nov 2012 16:15:43 +0000 (17:15 +0100)]
tests: fix locations in C
* tests/local.at (AT_YYERROR_DEFINE): Don't display the end of the location
if it is not after its beginning.
* tests/actions.at, tests/cxx-type.at: Adjust the expected output.