Akim Demaille [Tue, 26 Jun 2012 14:43:22 +0000 (16:43 +0200)]
Merge remote-tracking branch 'origin/maint'
* origin/maint:
tests: do not output m4 set up.
tests: use the generic yyerror function.
tests: use assert instead of plain abort.
tests: improve the generic yylex implementation.
tests: generalize the compilation macros.
tests: fix confusion between api.prefix and name-prefix.
maint: gitignores.
yacc: work around the ylwrap limitation.
Victor Santet [Thu, 14 Jun 2012 12:20:07 +0000 (14:20 +0200)]
warnings: raise warning for useless printers or destructors
* src/scan-code.h (code_props): Add field 'is_used'.
(CODE_PROPS_NONE_INIT): Adjust.
* src/scan-code.l (code_props_plain_init, code_props_symbol_action_init)
(code_props_rule_action_init): Instead of implementing several
times the initialization of the code_props structures,
use code_props_none_init.
* src/symtab.c (symbol_check_defined): If a symbol does not have a
destructor (resp. printer) but has a type which has a destructor (resp.
printer), then set field 'is_used' to true.
(semantic_type_check_defined): If a type has a destructor (resp. printer)
but all symbols of this type have already a destructor (resp. printer),
then raise a warning.
* tests/input.at (Useless printers or destructors): New.
Akim Demaille [Tue, 26 Jun 2012 12:05:56 +0000 (14:05 +0200)]
tests: do not output m4 set up.
* tests/local.at (AT_BISON_OPTION_PUSHDEFS, AT_BISON_OPTION_POPDEFS):
Use a diversion to avoid outputting comments etc.
Removes 17k lines from testsuite (10% of the number of lines).
Akim Demaille [Tue, 26 Jun 2012 09:54:13 +0000 (11:54 +0200)]
tests: use the generic yyerror function.
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Factor.
Use AT_YYERROR_DEFINE.
Therefore, instead of using stdout, use and check stderr.
* tests/glr-regression.at (Uninitialized location when reporting ambiguity):
Use AT_YYERROR_DEFINE.
Akim Demaille [Mon, 25 Jun 2012 14:37:18 +0000 (16:37 +0200)]
tests: generalize the compilation macros.
* tests/local.at (AT_COMPILE, AT_COMPILE_CXX): If OUTPUT ends with ".o",
then append the "natural" extension for the input file (.c or .cc).
If there is no source, pass -c.
* tests/headers.at, tests/input.at, tests/regression.at: Adjust.
Akim Demaille [Tue, 26 Jun 2012 07:35:31 +0000 (09:35 +0200)]
tests: fix confusion between api.prefix and name-prefix.
* tests/local.at (AT_NAME_PREFIX): Take api.prefix into account.
(AT_API_PREFIX): Rename as...
(AT_API_prefix): this.
Do not take %name-prefix into account.
Fix misuses.
Victor Santet [Mon, 18 Jun 2012 13:44:38 +0000 (15:44 +0200)]
warnings: useless semantic types
* src/symtab.h (symbol_list): Represent semantic types as structure
'semantic_type'.
* src/symlist.c (symbol_list_type_new): Allocate this structure.
(symbol_list_code_props_set): Set this semantic type's status to used if it
was not declared.
* src/symtab.c (semantic_types_sorted): New.
(semantic_type_new): Set the new semantic type's location appropriately.
(symbol_check_defined): If a symbol has a type, then set this type's status
to "declared".
(semantic_type_check_defined, semantic_type_check_defined_processor): Same
as symbol_check_defined and symbol_check_defined_processor, but for semantic
types.
(symbol_check_defined): Check semantic types usefulness.
* src/symtab.h (semantic_type): New fields 'location' and 'status'.
* src/symtab.h, src/symtab.c (semantic_type_new)
(semantic_type_from_uniqstr, semantic_type_get): Accept a location as a
supplementary argument.
* tests/input.at (Unassociated types used for printer of destructor): New.
* tests/c++.at (AT_CHECK_VARIANTS): Fix an error caught by this commit.
Akim Demaille [Mon, 25 Jun 2012 08:15:44 +0000 (10:15 +0200)]
yacc: work around the ylwrap limitation.
* data/yacc.c (b4_shared_declarations): Include the header guards.
Do not include the header in the *.c file, duplicate it.
* NEWS (Future Changes): Extend, and announce the forthcoming change
about the use of the parser header.
Akim Demaille [Mon, 25 Jun 2012 07:26:48 +0000 (09:26 +0200)]
Merge remote-tracking branch 'origin/maint'
* origin/maint:
tests: more uniformity.
tests: handle locations in a more generic way.
tests: handle locations in the generic yyerror functions.
tests: fix AT_CHECK_CALC.
tests: improve infrastructure
tests: factor.
skeletons: minor style changes
tests: AT_LANG.
c skeletons: factor the declaration of yylloc and yylval.
news: condemn YYPARSE_PARAM and YYLEX_PARAM.
maint: regen.
Akim Demaille [Fri, 22 Jun 2012 12:47:31 +0000 (14:47 +0200)]
code_props: factor more.
* src/symtab.h, src/symtab.c (code_props_type_string): No longer static.
* src/output.c (CODE_PROPS): Remove, we can now iterate on both the
destructor and the printer.
(SET_KEY2): New.
Victor Santet [Fri, 22 Jun 2012 12:11:05 +0000 (14:11 +0200)]
maint: factor the handling of %printer and %destructor
There is too much code duplication between %printer and %destructor.
We used to have two functions for each action: the first one for
destructors, the second one for printers. Factor using a
'code_props_type', and an array of code_props instead of two
members.
Akim Demaille [Fri, 22 Jun 2012 10:08:02 +0000 (12:08 +0200)]
tests: more uniformity.
* tests/local.at (AT_LEX_FORMALS, AT_LEX_ARGS, AT_LEX_PRE_FORMALS)
(AT_LEX_PRE_ARGS): Rename as...
(AT_YYLEX_FORMALS, AT_YYLEX_ARGS, AT_YYLEX_PRE_FORMALS)
(AT_YYLEX_PRE_ARGS): these, for consistency.
(AT_API_PREFIX): Take %name-prefix into account.
(AT_YYLEX_PROTOTYPE): New.
Use it.
* tests/actions.at, tests/calc.at, tests/cxx-type.at: Adjust to
use them.
Akim Demaille [Fri, 22 Jun 2012 09:34:37 +0000 (11:34 +0200)]
tests: handle locations in a more generic way.
* tests/local.at (AT_YYERROR_PROTOTYPE): New.
Use it.
* tests/cxx-type.at: Extensive revamp to use a more traditional
quotation scheme, and to use the generic yyerror implementation.
Prefer Autotest macros to CPP macros.
* tests/java.at: .
Akim Demaille [Fri, 22 Jun 2012 08:20:28 +0000 (10:20 +0200)]
tests: handle locations in the generic yyerror functions.
* tests/local.at (AT_YYERROR_DECLARE_EXTERN, AT_YYERROR_DECLARE)
(AT_YYERROR_DEFINE): Handle locations for C and C++.
* tests/calc.at: Use it for C++ (as C has extra arguments which
are not yet handled by AT_BISON_OPTION_PUSHDEFS).
* tests/actions.at: Adjust.
Akim Demaille [Thu, 21 Jun 2012 21:05:05 +0000 (23:05 +0200)]
tests: improve infrastructure
* tests/local.at (AT_LANG): Use c++ instead of cxx for C++.
Adjust dependencies.
(AT_YYERROR_DECLARE_EXTERN, AT_YYERROR_DECLARE): Issue nothing
for C++/Java.
(AT_YYERROR_DEFINE): Use m4_case.
(AT_JAVA_COMPILE): Use AT_SKIP_IF.
Akim Demaille [Sun, 17 Jun 2012 10:10:44 +0000 (12:10 +0200)]
c skeletons: factor the declaration of yylloc and yylval.
There is one difference: now, even without --defines, we generate
extern declarations for these variables. The factoring is worth it.
* data/c.m4 (b4_declare_yylstype): Declare them.
* data/glr.c, data/yacc.c: Adjust.
Akim Demaille [Wed, 20 Jun 2012 10:33:34 +0000 (12:33 +0200)]
fix warnings for useless %printer/%destructor
The previous commit, which turns into a warning what used to be an
error:
%printer {} foo;
%%
exp: '0';
has two shortcomings: the warning is way too long (foo is reported
to be useless later), and besides, it also turns into a warning much
more serious errors:
%printer {} foo;
%%
exp: foo;
Reduce the amount to warnings in the first case, restore the error in
the second.
* src/symtab.h (status): Add a new inital state: undeclared.
* src/symtab.c (symbol_new): Initialize to undeclared.
(symbol_class_set): Simplify the logic of the code that neutralize
the "redeclared" warning after the "redefined" one.
(symbol_check_defined): "undeclared" is also an error.
* src/reader.c (grammar_current_rule_symbol_append): Symbols appearing
in a rule are "needed".
* src/symlist.c (symbol_list_destructor_set, symbol_list_printer_set):
An unknown symbol appearing in a %printer/%destructor is "used".
* src/reduce.c (nonterminals_reduce): Do not report as "useless" symbols
that are not used (e.g., those that for instance appeared only in a
%printer).
* tests/input.at (Undeclared symbols used for a printer or destructor):
Improve the cover the cases described above.
Victor Santet [Tue, 19 Jun 2012 14:14:55 +0000 (16:14 +0200)]
warnings: used but undeclared symbols are warnings
We used to raise an error if a symbol appears only in a %printer or
%destructor. Make it a warning.
* src/symtab.h (status): New enum.
(symbol): Replace the binary "declared" with the three-state "status".
Adjust dependencies.
* src/symtab.c (symbol_check_defined): Needed symbols are an error,
whereas "used" are simply warnings.
* src/symlist.c (symbol_list_destructor_set, symbol_list_printer): Set
symbol status to 'used' when associated to destructors or printers.
* input.at (Undeclared symbols used for a printer or destructor): New.
Akim Demaille [Tue, 19 Jun 2012 15:35:53 +0000 (17:35 +0200)]
Merge remote-tracking branch 'origin/maint'
* origin/maint:
maint: formatting changes.
tests: support api.prefix.
tests: pacify font-lock-mode.
tests: remove test covered elsewhere.
tests: factor the declaration/definition of yyerror and yylex.
regen.
tests: portability issues.
tests: call the parser from another compilation unit.
glr.c, yacc.c: declare yydebug in the header.
skeletons: use header guards.
tests: improve AT_FULL_COMPILE.
tests: reorder.
tests: strengthen the test on generated headers inclusion
yacc.c: instead of duplicating y.tab.h inside y.tac.c, include it.
yacc.c: factor.
Akim Demaille [Mon, 11 Jun 2012 14:47:46 +0000 (16:47 +0200)]
tests: call the parser from another compilation unit.
In order to improve the testing of %defines, which exports the
interface of the generated parser, change the calc.at tests so that
when %defines is passed, main will be in another compilation unit. It
loads the generated header.
* tests/calc.at (AT_CALC_MAIN): New.
Includes the definition of the global variables.
Therefore, now declare them from the %requires section of the parser.
Adjust to yydebug and yyparse being renamed by %name-prefix.
Akim Demaille [Fri, 15 Jun 2012 13:19:16 +0000 (15:19 +0200)]
glr.c, yacc.c: declare yydebug in the header.
* data/c.m4 (b4_declare_yydebug): New.
* data/glr.c, data/yacc.c (b4_shared_declarations): Use it.
Remove the corresponding code from the parser body.
* NEWS: Doc this.
Akim Demaille [Tue, 12 Jun 2012 12:40:18 +0000 (14:40 +0200)]
yacc.c: factor.
yacc.c used to include two almost identical sections: one for the *.h
file, and another for the *.c file. The main difference is that in
the *.c file we used the yy* names (as %name-prefix is handled by
"#define yy* <prefix>*" before), while the *.hh used <prefix>* names.
Keep only the later. If this is troublesome, b4_shared_declarations
can easily take the desired prefix as argument.
* data/yacc.c (b4_shared_declarations): New.
Use it to factor duplicated declarations.
Akim Demaille [Tue, 12 Jun 2012 08:55:18 +0000 (10:55 +0200)]
skeletons: factor yacc.c and glr.c.
yacc.c and glr.c share common declarations. Their YYLTYPE are exactly
equal, and their YYSTYPE are sufficiently alike to be fused (its
declaration was protected by YYSTYPE_IS_DECLARED in yacc.c, but not in
glr.c). Besides, yacc.c duplicated the definitions of YYLTYPE and
YYSTYPE (*.h/*.c).
* data/c.m4 (b4_declare_yylstype): New.
* data/yacc.c, data/glr.c: Use it.
Akim Demaille [Tue, 5 Jun 2012 15:46:58 +0000 (17:46 +0200)]
maint: don't use mbsr?chr.
Basically, revert ba60c39547a445dee3e07920931b4d7a81843868's move to
mbs* functions, which was prompted by -DGNULIB_POSIXCHECK. See
<http://lists.gnu.org/archive/html/bison-patches/2012-05/msg00052.html>
and following.
* bootstrap.conf: No longer ask for them.
* src/files.c, src/getargs.c, src/location.c,
* src/parse-gram.c, src/parse-gram.y, src/scan-gram.l,
* src/symtab.c: s/mbs(r?chr)/str$1/g.
Akim Demaille [Tue, 5 Jun 2012 15:26:55 +0000 (17:26 +0200)]
maint: use xconcat-filename.
* bootstrap.conf (gnulib_modules): Request it.
* src/output.h, src/output.c (compute_pkgdatadir): Rename as...
(pkgdatadir): this.
Adjust dependencies.
* src/output.c (output_skeleton): Reduce the scope of "in".
Use xconcatenated_filename to simplify the construction of the
qualified paths to m4sugar.m4, bison.m4, and the selected skeleton.
There are a few minor differences: the new code uses strchr instead of
mbschr (but this was not really justified), and the new code does not
garantee a single slash even if $BISON_PKGDATADIR ends with several
(which was considered more accurate). See the discussion at
<http://lists.gnu.org/archive/html/bison-patches/2012-05/msg00052.html>.
Jim Meyering [Tue, 5 Jun 2012 07:02:36 +0000 (09:02 +0200)]
maint: fix comment typos
Using http://github.com/lyda/misspell-check, massage its
output into sed commands to perform the suggested changes.
Initially, I filtered out the THRU->Through changes, because
that failed to retain capitalization in the grammar token.
Instead, do this manually, beforehand:
Akim Demaille [Thu, 24 May 2012 11:37:28 +0000 (13:37 +0200)]
Merge tag 'v2.5.1_rc2'
Bison 2.5.1_rc2.
* tag 'v2.5.1_rc2': (34 commits)
Bison 2.5.1_rc2.
doc: fixes.
build: fix ChangeLog generation.
c++: compute the header guards.
skeletons: remove support for unused directive.
lalr1.cc: improve Doxygen documentation.
lalr1.cc: extract stack.hh.
news: convert to double quotes.
space changes.
build: do not prototype flex-generated functions.
build: fix ChangeLog generation.
Bison 2.5.1_rc1.
tests: save/restore Autotest special files when checking XML support.
tests: AT_SAVE_SPECIAL_FILES / AT_RESTORE_SPECIAL_FILES.
tests: honor TESTSUITEFLAGS in all the check targets.
build: do not enable c++ warnings on 0 when nullptr is not supported.
maint: update gnulib.
build: config.in.h.
build: move silent rules.
glr.c: reduce variable scopes.
maint: maintainer-release-check.
maint: shush a syntax-check.
maint: prefer "commit message" to "log entry".
command line: fix minor leaks.
maint: we no longer maintain the ChangeLog.
maint: fix the generation of the synclines for bison's parser.
maint: regen.
maint: import the xmemdup0 gnulib module.
maint: remove left-over gnulib modules.
maint: ignore files imported by autopoint.
build: AC_PROG_LEX: use more readable variable names.
maint: regen src/parse-gram.[ch]
maint: simplify parse-gram.y
maint: s/strncpy/memcpy/, when equivalent
Akim Demaille [Tue, 15 May 2012 09:22:34 +0000 (11:22 +0200)]
build: do not prototype flex-generated functions.
Some versions of Flex, possibly modified by the distribution package
maintainers, have incompatible signatures. Since newer versions of
Flex prototype their functions, avoid the conflicts in that case.
Reported by Stefano Lattarini.
<http://lists.gnu.org/archive/html/bug-bison/2012-05/msg00012.html>.
* src/flex-scanner.h (FLEX_VERSION_GT): New.
Use it to issue prototypes for flex-generated functions only for
versions up to 2.5.31, in accordance with the comment.
See commit dc9701e848f27ae64b6ddcf809580998667d60f2.
Use it to define yylex_destroy when needed.
Akim Demaille [Fri, 11 May 2012 15:11:09 +0000 (17:11 +0200)]
tests: save/restore Autotest special files when checking XML support.
Currently the test 248, "parse-gram.y: LALR = IELR", fails
BISON_TEST_XML is set.
* tests/local.at (AT_BISON_CHECK_XML): Belt: Save/restore files.
* tests/regression.at (parse-gram.y: LALR = IELR): Suspenders: Don't
rely on expout.
Each one of these changes suffices.
Some of our macros play with expout and other Autotest special files,
which may break their callers (e.g., currently TESTSUITEFLAGS='248
BISON_TEST_XML=1' fails).
There is already some support for this. Expand it to be ready to use
it elsewhere.
* tests/local.at (AT_RESTORE_SPECIAL_FILES, AT_SAVE_SPECIAL_FILES)
(at_save_special_files, at_restore_special_files): New.
(AT_BISON_CHECK_NO_XML): Use them.
Akim Demaille [Wed, 9 May 2012 09:00:32 +0000 (11:00 +0200)]
build: config.in.h.
Historically we used config.hin (where everybody else used
config.h.in) to please DOS. Now that we use gnulib, there are already
tons of files with several dots, especially *.in.h.
Akim Demaille [Sun, 9 Jan 2011 10:06:23 +0000 (11:06 +0100)]
glr.c: reduce variable scopes.
* data/glr.c: Where appropriate, fuse variable declarations followed
by assignments by variable declarations with a value.
Where appropriate, introduce new scopes to limit variable spans.