[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 17/22] %merge: delegate the generation of calls to mergers to m4
From: |
Akim Demaille |
Subject: |
[PATCH 17/22] %merge: delegate the generation of calls to mergers to m4 |
Date: |
Sat, 23 Jan 2021 15:55:56 +0100 |
Don't generate C code from bison, leave that to the skeletons.
* src/output.c (merger_output): Emit invocations to b4_call_merger.
* data/skeletons/glr.c (b4_call_merger): New.
---
data/skeletons/glr.c | 11 ++++++++++-
src/output.c | 8 ++------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
index 5034b5efc..1ef948cd6 100644
--- a/data/skeletons/glr.c
+++ b/data/skeletons/glr.c
@@ -1,4 +1,4 @@
- -*- C -*-
+# -*- C -*-
# GLR skeleton for Bison
@@ -145,6 +145,15 @@ m4_define([b4_rhs_location],
[(b4_rhs_data([$1], [$2]).yyloc)])
+# b4_call_merger(MERGER-NUM, MERGER-NAME, SYMBOL-SUM)
+# ---------------------------------------------------
+m4_define([b4_call_merger],
+[b4_case([$1],
+ [ b4_symbol_if([$3], [has_type],
+ [yy0->b4_symbol($3, type) = $2 (*yy0, *yy1);],
+ [*yy0 = $2 (*yy0, *yy1);])])])
+
+
## -------------- ##
## Declarations. ##
## -------------- ##
diff --git a/src/output.c b/src/output.c
index 19c89cb45..5c87d5b48 100644
--- a/src/output.c
+++ b/src/output.c
@@ -533,12 +533,8 @@ merger_output (FILE *out)
int n;
merger_list* p;
for (n = 1, p = merge_functions; p != NULL; n += 1, p = p->next)
- if (p->sym && p->sym->content->type_name)
- fprintf (out, " case %d: yy0->%s = %s (*yy0, *yy1); break;\n",
- n, p->sym->content->type_name, p->name);
- else
- fprintf (out, " case %d: *yy0 = %s (*yy0, *yy1); break;\n",
- n, p->name);
+ fprintf (out, "]b4_call_merger""([%d], [%s], [%d])[\n",
+ n, p->name, p->sym->content->number);
fputs ("]])\n\n", out);
}
--
2.30.0
- [PATCH 07/22] c++: I'm tired of Flex's warnings, (continued)
- [PATCH 07/22] c++: I'm tired of Flex's warnings, Akim Demaille, 2021/01/23
- [PATCH 08/22] cex: send traces to stderr, not stdout, Akim Demaille, 2021/01/23
- [PATCH 09/22] cex: add support for $TIME_LIMIT, Akim Demaille, 2021/01/23
- [PATCH 10/22] cex: fix traces: add missing end-of-lines, Akim Demaille, 2021/01/23
- [PATCH 11/22] cex: fix traces: fix display of disabled items, Akim Demaille, 2021/01/23
- [PATCH 12/22] package: codespell, Akim Demaille, 2021/01/23
- [PATCH 13/22] style: YYUSE is private, make it YY_USE, Akim Demaille, 2021/01/23
- [PATCH 14/22] skeletons: introduce "slot"s for symbols, Akim Demaille, 2021/01/23
- [PATCH 15/22] %merge: clearer tests on diagnostics, Akim Demaille, 2021/01/23
- [PATCH 16/22] %merge: let mergers record a typing-symbol, rather than a type, Akim Demaille, 2021/01/23
- [PATCH 17/22] %merge: delegate the generation of calls to mergers to m4,
Akim Demaille <=
- [PATCH 18/22] %merge: fix compatibility with api.value.type=union, Akim Demaille, 2021/01/23
- [PATCH 19/22] %merge: associate it to its first definition, not the latest, Akim Demaille, 2021/01/23
- [PATCH 20/22] package: bump copyrights to 2021, Akim Demaille, 2021/01/23
- [PATCH 21/22] news: update, Akim Demaille, 2021/01/23
- [PATCH 22/22] package: pacify syntax-check, Akim Demaille, 2021/01/23