[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 14/22] skeletons: introduce "slot"s for symbols
From: |
Akim Demaille |
Subject: |
[PATCH 14/22] skeletons: introduce "slot"s for symbols |
Date: |
Sat, 23 Jan 2021 15:55:53 +0100 |
Extracted from d9cf99b6a5cb0345e91dfb90fe6d6473024ea97a, in the master
branch.
* data/skeletons/bison.m4 (b4_symbol_slot): New, with safer semantics
than type and type_tag.
---
data/README.md | 8 +++++++-
data/skeletons/bison.m4 | 14 ++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/data/README.md b/data/README.md
index 50fbe5253..59b220b0d 100644
--- a/data/README.md
+++ b/data/README.md
@@ -142,11 +142,17 @@ The macro `b4_symbol(NUM, FIELD)` gives access to the
following FIELDS:
When api.value.type=union, the generated name for the union member.
yytype_INT etc. for symbols that has_id, otherwise yytype_1 etc.
-- `type`
+- `type`: string
If it has a semantic value, its type tag, or, if variant are used,
its type.
In the case of api.value.type=union, type is the real type (e.g. int).
+- `slot`: string
+ If it has a semantic value, the name of the union member (i.e., bounces to
+ either `type_tag` or `type`). It would be better to fix our mess and
+ always use `type` for the true type of the member, and `type_tag` for the
+ name of the union member.
+
- `has_printer`: 0, 1
- `printer`: string
- `printer_file`: string
diff --git a/data/skeletons/bison.m4 b/data/skeletons/bison.m4
index 121551232..156b0689d 100644
--- a/data/skeletons/bison.m4
+++ b/data/skeletons/bison.m4
@@ -465,6 +465,19 @@ m4_case([$1],
# but are S_YYEMPTY and symbol_kind::S_YYEMPTY in C++.
m4_copy([b4_symbol_kind_base], [b4_symbol_kind])
+
+# b4_symbol_slot(NUM)
+# -------------------
+# The name of union member that contains the value of these symbols.
+# Currently, we are messy, this should actually be type_tag, but type_tag
+# has several meanings.
+m4_define([b4_symbol_slot],
+[m4_case(b4_percent_define_get([[api.value.type]]),
+ [union], [b4_symbol([$1], [type_tag])],
+ [variant], [b4_symbol([$1], [type_tag])],
+ [b4_symbol([$1], [type])])])
+
+
# b4_symbol(NUM, FIELD)
# ---------------------
# Fetch FIELD of symbol #NUM (or "orig NUM"). Fail if undefined.
@@ -475,6 +488,7 @@ m4_define([b4_symbol],
[id], [b4_symbol_token_kind([$1])],
[kind_base], [b4_symbol_kind_base([$1])],
[kind], [b4_symbol_kind([$1])],
+ [slot], [b4_symbol_slot([$1])],
[_b4_symbol($@)])])
--
2.30.0
- [PATCH 04/22] c++: use noexcept where appropriate, (continued)
- [PATCH 04/22] c++: use noexcept where appropriate, Akim Demaille, 2021/01/23
- [PATCH 05/22] tables: avoid warnings and save bits, Akim Demaille, 2021/01/23
- [PATCH 06/22] glr.cc: don't "leak" yyparse, Akim Demaille, 2021/01/23
- [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 <=
- [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, 2021/01/23
- [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