[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/8] m4: rename b4_symbol_sid as b4_symbol_kind
From: |
Akim Demaille |
Subject: |
[PATCH 3/8] m4: rename b4_symbol_sid as b4_symbol_kind |
Date: |
Sun, 5 Apr 2020 16:29:58 +0200 |
* data/skeletons/bison.m4, data/skeletons/c++.m4, data/skeletons/c.m4,
* data/skeletons/d.m4, data/skeletons/java.m4
(b4_symbol_sid): Rename as...
(b4_symbol_kind): this.
Adjust dependencies.
* data/README.md: Document the kind.
---
data/README.md | 17 ++++++++++++-----
data/skeletons/bison.m4 | 10 +++++-----
data/skeletons/c++.m4 | 2 +-
data/skeletons/c.m4 | 6 +++---
data/skeletons/d.m4 | 6 +++---
data/skeletons/java.m4 | 8 ++++----
6 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/data/README.md b/data/README.md
index c91fe1c5..5d32b75f 100644
--- a/data/README.md
+++ b/data/README.md
@@ -83,18 +83,20 @@ field), where field can `has_id`, `id`, etc.: see
The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS:
-- `has_id`: 0 or 1.
-
+- `has_id`: 0 or 1
Whether the symbol has an id.
- `id`: string
If has_id, the id (prefixed by api.token.prefix if defined), otherwise
- defined as empty. Guaranteed to be usable as a C identifier.
+ defined as empty. Guaranteed to be usable as a C identifier. This is
+ used to define the token kind (i.e., the enum used by the return value of
+ yylex).
-- `tag`: string.
- A representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
+- `tag`: string
+ A human representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
- `user_number`: integer
+ The code associated to the `id`.
The external number as used by yylex. Can be ASCII code when a character,
some number chosen by bison, or some user number in the case of
%token FOO <NUM>. Corresponds to yychar in yacc.c.
@@ -102,7 +104,12 @@ The macro `b4_symbol(NUM, FIELD)` gives access to the
following FIELDS:
- `is_token`: 0 or 1
Whether this is a terminal symbol.
+- `kind`: string
+ The symbol kind, i.e., the enumerator of this symbol (token or nonterminal)
+ which is mapping to its `number`.
+
- `number`: integer
+ The code associated to the `kind`.
The internal number (computed from the external number by yytranslate).
Corresponds to yytoken in yacc.c. This is the same number that serves as
key in b4_symbol(NUM, FIELD).
diff --git a/data/skeletons/bison.m4 b/data/skeletons/bison.m4
index 1bd30dd1..480872fd 100644
--- a/data/skeletons/bison.m4
+++ b/data/skeletons/bison.m4
@@ -405,13 +405,13 @@ m4_define([_b4_symbol],
[__b4_symbol([$1], [$2])])])
-# b4_symbol_sid(NUM)
-# ------------------
-# Build the symbol ID based for this symbol. It must always exist,
+# b4_symbol_kind(NUM)
+# -------------------
+# Build the name of the kind of this symbol. It must always exist,
# otherwise some symbols might not be represented in the enum, which
# might be compiled into too small a type to contain all the symbol
# numbers.
-m4_define([b4_symbol_sid],
+m4_define([b4_symbol_kind],
[m4_case([$1],
[-2], [[YYSYMBOL_YYEMPTY]],
[0], [[YYSYMBOL_YYEOF]],
@@ -433,7 +433,7 @@ m4_define([b4_symbol],
[m4_case([$2],
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
[_b4_symbol([$1], [id])])],
- [sid], [b4_symbol_sid([$1])],
+ [kind], [b4_symbol_kind([$1])],
[_b4_symbol($@)])])
diff --git a/data/skeletons/c++.m4 b/data/skeletons/c++.m4
index 720977b0..ac074f4b 100644
--- a/data/skeletons/c++.m4
+++ b/data/skeletons/c++.m4
@@ -192,7 +192,7 @@ m4_define([b4_declare_symbol_enum],
{
]m4_join([,
],
- ]b4_symbol_sid([-2])[ = -2,
+ ]b4_symbol_kind([-2])[ = -2,
b4_symbol_map([b4_symbol_enum]),
[YYNTOKENS = ]b4_tokens_number[ ///< Number of tokens.])[
};
diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4
index 2c134365..aeafea4e 100644
--- a/data/skeletons/c.m4
+++ b/data/skeletons/c.m4
@@ -495,9 +495,9 @@ m4_define([b4_symbol_translate],
# --------------------------
# Output the definition of this symbol as an enum.
m4_define([b4_symbol_enum],
-[m4_ifval(b4_symbol([$1], [sid]),
+[m4_ifval(b4_symbol([$1], [kind]),
[m4_format([[%s = %s]],
- b4_symbol([$1], [sid]),
+ b4_symbol([$1], [kind]),
b4_symbol([$1], [number]))])])
@@ -512,7 +512,7 @@ enum yysymbol_kind_t
{
]m4_join([,
],
- ]b4_symbol_sid([-2])[ = -2,
+ ]b4_symbol_kind([-2])[ = -2,
b4_symbol_map([b4_symbol_enum]))[
};
typedef enum yysymbol_kind_t yysymbol_kind_t;
diff --git a/data/skeletons/d.m4 b/data/skeletons/d.m4
index b8862cf7..fefe74a1 100644
--- a/data/skeletons/d.m4
+++ b/data/skeletons/d.m4
@@ -181,9 +181,9 @@ b4_symbol_foreach([b4_token_enum])
# --------------------------
# Output the definition of this symbol as an enum.
m4_define([b4_symbol_enum],
-[m4_ifval(b4_symbol([$1], [sid]),
+[m4_ifval(b4_symbol([$1], [kind]),
[m4_format([[%s = %s]],
- b4_symbol([$1], [sid]),
+ b4_symbol([$1], [kind]),
b4_symbol([$1], [number]))])])
@@ -198,7 +198,7 @@ m4_define([b4_declare_symbol_enum],
{
]m4_join([,
],
- ]b4_symbol_sid([-2])[ = -2,
+ ]b4_symbol_kind([-2])[ = -2,
b4_symbol_map([b4_symbol_enum]))[
};
]])])
diff --git a/data/skeletons/java.m4 b/data/skeletons/java.m4
index 47e745ae..3733f261 100644
--- a/data/skeletons/java.m4
+++ b/data/skeletons/java.m4
@@ -157,9 +157,9 @@ b4_symbol_foreach([b4_token_enum])])])
# --------------------------
# Output the definition of this symbol as an enum.
m4_define([b4_symbol_enum],
-[m4_ifval(b4_symbol([$1], [sid]),
+[m4_ifval(b4_symbol([$1], [kind]),
[m4_format([[%s(%s)]],
- b4_symbol([$1], [sid]),
+ b4_symbol([$1], [kind]),
b4_symbol([$1], [number]))])])
@@ -171,7 +171,7 @@ m4_define([b4_declare_symbol_enum],
{
]m4_join([,
],
- ]b4_symbol_sid([-2])[(-2),
+ ]b4_symbol_kind([-2])[(-2),
b4_symbol_map([b4_symbol_enum]))[;
private final int code_;
@@ -181,7 +181,7 @@ m4_define([b4_declare_symbol_enum],
}
private static final SymbolKind[] values_ = {
- ]m4_map_args_sep([b4_symbol_sid(], [)], [,
+ ]m4_map_args_sep([b4_symbol_kind(], [)], [,
], b4_symbol_numbers)[
};
--
2.26.0
- RFC: renaming the symbol "types" as "kinds", Akim Demaille, 2020/04/04
- Re: RFC: renaming the symbol "types" as "kinds", Paul Eggert, 2020/04/04
- Re: RFC: renaming the symbol "types" as "kinds", Akim Demaille, 2020/04/05
- Re: RFC: renaming the symbol "types" as "kinds", Paul Eggert, 2020/04/05
- [PATCH 0/8] Rename token/symbol type as token/symbol kind, Akim Demaille, 2020/04/05
- [PATCH 4/8] m4: we don't need undef_token_number, Akim Demaille, 2020/04/05
- [PATCH 3/8] m4: rename b4_symbol_sid as b4_symbol_kind,
Akim Demaille <=
- [PATCH 7/8] bison: use consistently "token kind", not "token type", Akim Demaille, 2020/04/05
- [PATCH 2/8] d, java: rename SymbolType as SymbolKind, Akim Demaille, 2020/04/05
- [PATCH 6/8] skeletons: use consistently "kind" instead of "type" in the code, Akim Demaille, 2020/04/05
- [PATCH 1/8] c, c++: rename yysymbol_type_t as yysymbol_kind_t, Akim Demaille, 2020/04/05
- [PATCH 8/8] regen, Akim Demaille, 2020/04/05
- [PATCH 5/8] doc: refer to the token kind rather than the token type, Akim Demaille, 2020/04/05