mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 08:43:03 +00:00
c++: check several parsers in the same program
* tests/local.at (AT_LOCATION_TYPE_IF): Turn into... (AT_LOCATION_TYPE_SPAN_IF): this. Adjust dependencies. * tests/headers.at (Several parsers): Add another C++ parser, which uses the first C++ parser's locations.
This commit is contained in:
@@ -210,7 +210,7 @@ AT_CXX_IF(
|
|||||||
[%define global_tokens_and_yystype])[
|
[%define global_tokens_and_yystype])[
|
||||||
%code requires
|
%code requires
|
||||||
{
|
{
|
||||||
]AT_LOCATION_TYPE_IF([[
|
]AT_LOCATION_TYPE_SPAN_IF([[
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
struct Point
|
struct Point
|
||||||
{
|
{
|
||||||
@@ -272,7 +272,7 @@ static int power (int base, int exponent);
|
|||||||
]AT_YYLEX_DECLARE_EXTERN[
|
]AT_YYLEX_DECLARE_EXTERN[
|
||||||
}
|
}
|
||||||
|
|
||||||
]AT_CXX_IF([AT_LOCATION_TYPE_IF([[
|
]AT_CXX_IF([AT_LOCATION_TYPE_SPAN_IF([[
|
||||||
%initial-action
|
%initial-action
|
||||||
{
|
{
|
||||||
@$.first.l = @$.first.c = 1;
|
@$.first.l = @$.first.c = 1;
|
||||||
@@ -334,7 +334,7 @@ power (int base, int exponent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
]AT_CXX_IF(
|
]AT_CXX_IF(
|
||||||
[AT_LOCATION_TYPE_IF([[
|
[AT_LOCATION_TYPE_SPAN_IF([[
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
std::ostream&
|
std::ostream&
|
||||||
|
|||||||
@@ -228,6 +228,7 @@ exp:
|
|||||||
| 'x' '6' { printf ("x6\n"); }
|
| 'x' '6' { printf ("x6\n"); }
|
||||||
| 'x' '7' { printf ("x7\n"); }
|
| 'x' '7' { printf ("x7\n"); }
|
||||||
| 'x' '8' { printf ("x8\n"); }
|
| 'x' '8' { printf ("x8\n"); }
|
||||||
|
| 'x' '9' { printf ("x9\n"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@@ -262,7 +263,7 @@ extern "C"
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#include "x5.hh"
|
#include "x5.hh"
|
||||||
//#include "x6.hh"
|
#include "x9.hh"
|
||||||
|
|
||||||
#define RUN(S) \
|
#define RUN(S) \
|
||||||
do { \
|
do { \
|
||||||
@@ -283,8 +284,8 @@ main (void)
|
|||||||
RUN(x6_parse());
|
RUN(x6_parse());
|
||||||
RUN(x7_parse());
|
RUN(x7_parse());
|
||||||
RUN(x8_parse());
|
RUN(x8_parse());
|
||||||
// x6_::parser p6;
|
x9_::parser p9;
|
||||||
// RUN(p6.parse());
|
RUN(p9.parse());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
]])# main.cc
|
]])# main.cc
|
||||||
@@ -297,6 +298,7 @@ AT_TEST([x5], [%locations %debug %language "c++"])
|
|||||||
AT_TEST([x6], [%define api.pure])
|
AT_TEST([x6], [%define api.pure])
|
||||||
AT_TEST([x7], [%define api.push-pull both])
|
AT_TEST([x7], [%define api.push-pull both])
|
||||||
AT_TEST([x8], [%define api.pure %define api.push-pull both])
|
AT_TEST([x8], [%define api.pure %define api.push-pull both])
|
||||||
|
AT_TEST([x9], [%locations %code requires {#include "location.hh"} %define api.location.type {x5_::location} %debug %language "c++"])
|
||||||
#AT_TEST([x5], [%locations %language "c++" %glr-parser])
|
#AT_TEST([x5], [%locations %language "c++" %glr-parser])
|
||||||
|
|
||||||
# Check that api.prefix works properly:
|
# Check that api.prefix works properly:
|
||||||
@@ -345,7 +347,7 @@ AT_CHECK([[$PERL -n -0777 -e '
|
|||||||
# Do this late, so that other checks have been performed.
|
# Do this late, so that other checks have been performed.
|
||||||
AT_SKIP_IF_CANNOT_LINK_C_AND_CXX
|
AT_SKIP_IF_CANNOT_LINK_C_AND_CXX
|
||||||
|
|
||||||
AT_COMPILE_CXX([parser], [[x[1-8].o -DCC_IS_CXX=$CC_IS_CXX main.cc]])
|
AT_COMPILE_CXX([parser], [[x[1-9].o -DCC_IS_CXX=$CC_IS_CXX main.cc]])
|
||||||
AT_PARSER_CHECK([./parser], [0], [[expout]])
|
AT_PARSER_CHECK([./parser], [0], [[expout]])
|
||||||
|
|
||||||
m4_popdef([AT_TEST])
|
m4_popdef([AT_TEST])
|
||||||
|
|||||||
@@ -167,8 +167,11 @@ m4_pushdef([AT_LEXPARAM_IF],
|
|||||||
[m4_bmatch([$3], [%lex-param], [$1], [$2])])
|
[m4_bmatch([$3], [%lex-param], [$1], [$2])])
|
||||||
m4_pushdef([AT_LOCATION_IF],
|
m4_pushdef([AT_LOCATION_IF],
|
||||||
[m4_bmatch([$3], [%locations], [$1], [$2])])
|
[m4_bmatch([$3], [%locations], [$1], [$2])])
|
||||||
m4_pushdef([AT_LOCATION_TYPE_IF],
|
# Whether we use the Span location type (see calc.at), whose members are
|
||||||
[m4_bmatch([$3], [%define \(api\.location\.type\|location_type\)], [$1], [$2])])
|
# not named like those of the default location type (on purpose, to make
|
||||||
|
# sure we can use a user type).
|
||||||
|
m4_pushdef([AT_LOCATION_TYPE_SPAN_IF],
|
||||||
|
[m4_bmatch([$3], [%define \(api\.location\.type\|location_type\) \{Span\}], [$1], [$2])])
|
||||||
m4_pushdef([AT_PARAM_IF],
|
m4_pushdef([AT_PARAM_IF],
|
||||||
[m4_bmatch([$3], [%parse-param], [$1], [$2])])
|
[m4_bmatch([$3], [%parse-param], [$1], [$2])])
|
||||||
# Comma-terminated list of formals parse-parameters.
|
# Comma-terminated list of formals parse-parameters.
|
||||||
@@ -285,7 +288,7 @@ AT_TOKEN_CTOR_IF(
|
|||||||
# Handle the different types of location components.
|
# Handle the different types of location components.
|
||||||
|
|
||||||
AT_CXX_IF(
|
AT_CXX_IF(
|
||||||
[AT_LOCATION_TYPE_IF(
|
[AT_LOCATION_TYPE_SPAN_IF(
|
||||||
[AT_LOC_PUSHDEF([first.l], [first.c], [last.l], [last.c])],
|
[AT_LOC_PUSHDEF([first.l], [first.c], [last.l], [last.c])],
|
||||||
[AT_LOC_PUSHDEF([begin.line], [begin.column], [end.line], [end.column])])],
|
[AT_LOC_PUSHDEF([begin.line], [begin.column], [end.line], [end.column])])],
|
||||||
[AT_LOC_PUSHDEF([first_line], [first_column], [last_line], [last_column])])
|
[AT_LOC_PUSHDEF([first_line], [first_column], [last_line], [last_column])])
|
||||||
@@ -318,7 +321,7 @@ m4_popdef([AT_TOKEN_PREFIX])
|
|||||||
m4_popdef([AT_TOKEN_CTOR_IF])
|
m4_popdef([AT_TOKEN_CTOR_IF])
|
||||||
m4_popdef([AT_NAMESPACE])
|
m4_popdef([AT_NAMESPACE])
|
||||||
m4_popdef([AT_NAME_PREFIX])
|
m4_popdef([AT_NAME_PREFIX])
|
||||||
m4_popdef([AT_LOCATION_TYPE_IF])
|
m4_popdef([AT_LOCATION_TYPE_SPAN_IF])
|
||||||
m4_popdef([AT_LOCATION_IF])
|
m4_popdef([AT_LOCATION_IF])
|
||||||
m4_popdef([AT_PARSE_PARAMS])
|
m4_popdef([AT_PARSE_PARAMS])
|
||||||
m4_popdef([AT_PUSH_IF])
|
m4_popdef([AT_PUSH_IF])
|
||||||
|
|||||||
Reference in New Issue
Block a user