mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 00:33:03 +00:00
tests: improve factoring of the main function
* tests/local.at (AT_MAIN_DEFINE): If %debug is used, check if -d/--debug is passed to the generated parser, and enable the traces. Return exactly the result of yyparse, so that we can check exit code 2 too. * tests/actions.at, tests/glr-regression.at, tests/regression.at: Use AT_MAIN_DEFINE, helping AT_BISON_OPTION_PUSHDEFS where needed, preferably to option -t.
This commit is contained in:
@@ -452,20 +452,32 @@ m4_define([AT_MAIN_DEFINE],
|
||||
[m4_case(AT_LANG,
|
||||
[c],
|
||||
[[#include <stdlib.h> /* getenv. */
|
||||
#include <string.h> /* strcmp. */
|
||||
int
|
||||
main (void)
|
||||
{]AT_DEBUG_IF([
|
||||
yydebug = !!getenv("YYDEBUG");])[
|
||||
return !!yyparse ();
|
||||
main (int argc, char const* argv[])
|
||||
{]AT_DEBUG_IF([[
|
||||
if (getenv("YYDEBUG")
|
||||
|| (argc == 2
|
||||
&& (!strcmp (argv[1], "-d") || !strcmp (argv[1], "--debug"))))
|
||||
yydebug |= 1;]], [[
|
||||
(void) argc;
|
||||
(void) argv;]])[
|
||||
return yyparse ();
|
||||
}]],
|
||||
[c++],
|
||||
[[#include <cstdlib> // getenv.
|
||||
#include <cstring> // strcmp.
|
||||
int
|
||||
main (void)
|
||||
main (int argc, char const* argv[])
|
||||
{
|
||||
yy::parser p;]AT_DEBUG_IF([
|
||||
p.set_debug_level (!!getenv("YYDEBUG"));])[
|
||||
return !!p.parse ();
|
||||
yy::parser p;]AT_DEBUG_IF([[
|
||||
if (getenv("YYDEBUG")
|
||||
|| (argc == 2
|
||||
&& (!strcmp (argv[1], "-d") || !strcmp (argv[1], "--debug"))))
|
||||
p.set_debug_level (true);]], [[
|
||||
(void) argc;
|
||||
(void) argv;]])[
|
||||
return p.parse ();
|
||||
}]],
|
||||
[java],
|
||||
[[class input
|
||||
|
||||
Reference in New Issue
Block a user