summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2021-01-21 21:45:45 +0100
committerAkim Demaille <akim.demaille@gmail.com>2021-03-26 07:01:48 +0100
commitae0889d805b0965568c9f95f5640d54058288246 (patch)
treef2a03a98249a849ad9d478dcf5c6467eda42afda /tests
parenta9c2549c2758b93b3a018dd3033d34ad0ce9eb64 (diff)
downloadbison-ae0889d805b0965568c9f95f5640d54058288246.tar.gz
d: add api.value.type union support
The union of the values is handled by the backend. In D, unions can hold classes, structs, etc., so this is more similar to the C++ api.value.type variant. * data/skeletons/d.m4, data/skeletons/lalr1.d: Here. * tests/calc.at, tests/local.at: Test it.
Diffstat (limited to 'tests')
-rw-r--r--tests/calc.at11
-rw-r--r--tests/local.at2
2 files changed, 8 insertions, 5 deletions
diff --git a/tests/calc.at b/tests/calc.at
index 0e76c282..042cac7b 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -645,11 +645,11 @@ m4_define([_AT_DATA_CALC_Y(d)],
alias semantic_value = int;
}
/* Exercise %union. */
-%union
+]AT_UNION_IF([[]], [[%union
{
semantic_value ival;
-};
-%printer { yyo.write($$); } <ival>;
+};]])[
+%printer { yyo.write($$); } <]AT_UNION_IF([[int]], [[ival]])[>;
%code {
]AT_TOKEN_TRANSLATE_IF([[
@@ -670,8 +670,8 @@ m4_define([_AT_DATA_CALC_Y(d)],
/* Bison Declarations */
%token EOF 0 ]AT_TOKEN_TRANSLATE_IF([_("end of file")], ["end of input"])[
-%token <ival> NUM "number"
-%type <ival> exp
+%token <]AT_UNION_IF([[int]], [[ival]])[> NUM "number"
+%type <]AT_UNION_IF([[int]], [[ival]])[> exp
%token EQUAL "="
MINUS "-"
@@ -1499,6 +1499,7 @@ AT_CHECK_CALC_LALR1_D([%locations %define parse.lac full %define parse.error det
#AT_CHECK_CALC_LALR1_D([%locations %define parse.error detailed %debug %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
#AT_CHECK_CALC_LALR1_D([%locations %define parse.error detailed %debug %define api.prefix {calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}])
+AT_CHECK_CALC_LALR1_D([%define parse.error custom %define api.value.type union])
# ----------------------- #
# LALR1 Java Calculator. #
diff --git a/tests/local.at b/tests/local.at
index 8411bfa3..f8836282 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -319,6 +319,8 @@ m4_pushdef([AT_UNION_IF],
[m4_bmatch([$3], [%define api\.value\.type union], [$1], [$2])])
m4_pushdef([AT_VARIANT_IF],
[m4_bmatch([$3], [%define api\.value\.type variant], [$1], [$2])])
+m4_pushdef([AT_UNION_IF],
+[m4_bmatch([$3], [%define api\.value\.type union], [$1], [$2])])
m4_pushdef([AT_API_prefix],
[m4_bmatch([$3], [%define api\.prefix {.*}],
[m4_bregexp([$3], [%define api\.prefix {\([^\}]*\)}], [\1])],