[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
c++: check several parsers in the same program
From: |
Akim Demaille |
Subject: |
c++: check several parsers in the same program |
Date: |
Fri, 28 Dec 2018 18:46:14 +0100 |
commit 7938ab53ff6f0fe46984e696db2e1aa302a1cb1d
Author: Akim Demaille <address@hidden>
Date: Wed Dec 26 18:36:30 2018 +0100
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.
diff --git a/tests/calc.at b/tests/calc.at
index d602797b..f5628c66 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -210,7 +210,7 @@ AT_CXX_IF(
[%define global_tokens_and_yystype])[
%code requires
{
-]AT_LOCATION_TYPE_IF([[
+]AT_LOCATION_TYPE_SPAN_IF([[
# include <iostream>
struct Point
{
@@ -272,7 +272,7 @@ static int power (int base, int exponent);
]AT_YYLEX_DECLARE_EXTERN[
}
-]AT_CXX_IF([AT_LOCATION_TYPE_IF([[
+]AT_CXX_IF([AT_LOCATION_TYPE_SPAN_IF([[
%initial-action
{
@$.first.l = @$.first.c = 1;
@@ -334,7 +334,7 @@ power (int base, int exponent)
}
]AT_CXX_IF(
-[AT_LOCATION_TYPE_IF([[
+[AT_LOCATION_TYPE_SPAN_IF([[
namespace
{
std::ostream&
diff --git a/tests/headers.at b/tests/headers.at
index 50fab0cc..31d45a8c 100644
--- a/tests/headers.at
+++ b/tests/headers.at
@@ -228,6 +228,7 @@ exp:
| 'x' '6' { printf ("x6\n"); }
| 'x' '7' { printf ("x7\n"); }
| 'x' '8' { printf ("x8\n"); }
+| 'x' '9' { printf ("x9\n"); }
;
%%
@@ -262,7 +263,7 @@ extern "C"
}
#endif
#include "x5.hh"
-//#include "x6.hh"
+#include "x9.hh"
#define RUN(S) \
do { \
@@ -283,8 +284,8 @@ main (void)
RUN(x6_parse());
RUN(x7_parse());
RUN(x8_parse());
-// x6_::parser p6;
-// RUN(p6.parse());
+ x9_::parser p9;
+ RUN(p9.parse());
return 0;
}
]])# main.cc
@@ -297,6 +298,7 @@ AT_TEST([x5], [%locations %debug %language "c++"])
AT_TEST([x6], [%define api.pure])
AT_TEST([x7], [%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])
# 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.
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]])
m4_popdef([AT_TEST])
diff --git a/tests/local.at b/tests/local.at
index 146ed47b..4ce9f825 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -167,8 +167,11 @@ m4_pushdef([AT_LEXPARAM_IF],
[m4_bmatch([$3], [%lex-param], [$1], [$2])])
m4_pushdef([AT_LOCATION_IF],
[m4_bmatch([$3], [%locations], [$1], [$2])])
-m4_pushdef([AT_LOCATION_TYPE_IF],
-[m4_bmatch([$3], [%define \(api\.location\.type\|location_type\)], [$1],
[$2])])
+# Whether we use the Span location type (see calc.at), whose members are
+# 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_bmatch([$3], [%parse-param], [$1], [$2])])
# Comma-terminated list of formals parse-parameters.
@@ -285,7 +288,7 @@ AT_TOKEN_CTOR_IF(
# Handle the different types of location components.
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([begin.line], [begin.column], [end.line], [end.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_NAMESPACE])
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_PARSE_PARAMS])
m4_popdef([AT_PUSH_IF])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- c++: check several parsers in the same program,
Akim Demaille <=