YYLLOC_DEFAULT: factor, and don't export it in headers.
* data/c++.m4, data/c.m4 (b4_yylloc_default_define): New.
* data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: Use it.
* data/glr.cc: Do not define YYLLOC_DEFAULT in the header file,
but in the implementation one.
since, of course YYSTYPE_IS_TRIVIAL is defined. Instead we could
define YYSTYPE_IS_TRIVIAL as PREFIX_STYPE_IS_TRIVIAL only when the
later is defined, but let's avoid stacking CPP on top of M4: rather, use
* data/glr.c, data/yacc.c: Use YYSTYPE_IS_TRIVIAL, YYSTYPE_IS_DECLARED,
YYLTYPE_IS_TRIVIAL and YYLTYPE_IS_DECLARED under their api.prefix-renamed
name.
The testsuite in master has shown weird errors for the "Mulitple
Parsers" tests: the caller of p5.parse() received some apparently
random value, while tracing p5.parse() showed that the function was
consistently returning 0.
It happens when mixing several parser headers, some generated without
%debug, others with. In particular the C++ parser was generated with
%debug, i.e., with:
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
and compiled separatedly. Yet, its header was included after the one
of another parser, this time without %debug, i.e., with
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
in its header. As a result, the parser was compiled with YYDEBUG set,
but its header was used without. Since the layout of the objects are
then completely different, boom.
Therefore, do not change the value of YYDEBUG. Rather, use it as a
default value for <API.PREFIX>DEBUG.
* data/c.m4 (b4_YYDEBUG_define): New.
(b4_declare_yydebug): Rename as...
(b4_yydebug_declare): this, for consistency.
* data/glr.c, data/glr.cc, data/lalr1.cc, data/yacc.c: Use it.
* NEWS: Document it.
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.
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 [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 [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.
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 [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.