[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/5] d: improvements on symbol kinds
From: |
Akim Demaille |
Subject: |
[PATCH 2/5] d: improvements on symbol kinds |
Date: |
Sat, 11 Apr 2020 08:47:40 +0200 |
public enum SymbolKind
{
S_YYEMPTY = -2, /* No symbol. */
S_YYEOF = 0, /* $end */
S_YYERROR = 1, /* error */
S_YYUNDEF = 2, /* $undefined */
S_EQ = 3, /* "=" */
* data/skeletons/d.m4 (api.symbol.prefix): Default to S_.
Output the symbol kind definitions with a comment.
---
data/skeletons/d.m4 | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/data/skeletons/d.m4 b/data/skeletons/d.m4
index 7d1672d5..4c3a5ce7 100644
--- a/data/skeletons/d.m4
+++ b/data/skeletons/d.m4
@@ -148,11 +148,9 @@ private static immutable b4_int_type_for([$2])[[]] yy$1_ =
])
-## -------------------------- ##
-## (External) token numbers. ##
-## -------------------------- ##
-
-b4_percent_define_default([[api.symbol.prefix]], [[YYSYMBOL_]])
+## ------------- ##
+## Token kinds. ##
+## ------------- ##
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
# ---------------------------------------
@@ -165,7 +163,7 @@ m4_define([b4_token_enum],
# --------------
# Output the definition of the tokens as enums.
m4_define([b4_token_enums],
-[/* Tokens. */
+[/* Token kinds. */
public enum YYTokenType {
/** Token returned by the scanner to signal the end of its input. */
@@ -174,19 +172,24 @@ b4_symbol_foreach([b4_token_enum])
}
])
-## --------------------------- ##
-## (Internal) symbol numbers. ##
-## --------------------------- ##
+
+
+## -------------- ##
+## Symbol kinds. ##
+## -------------- ##
+
+b4_percent_define_default([[api.symbol.prefix]], [[S_]])
# b4_symbol_enum(SYMBOL-NUM)
# --------------------------
# Output the definition of this symbol as an enum.
m4_define([b4_symbol_enum],
-[m4_ifval(b4_symbol([$1], [kind]),
- [m4_format([[%s = %s]],
- b4_symbol([$1], [kind]),
- b4_symbol([$1], [number]))])])
+[m4_format([ %-30s %s],
+ m4_format([[%s = %s,]],
+ b4_symbol([$1], [kind]),
+ [$1]),
+ [b4_symbol_tag_comment([$1])])])
# b4_declare_symbol_enum
@@ -195,14 +198,12 @@ m4_define([b4_symbol_enum],
# Defining YYEMPTY here is important: it forces the compiler
# to use a signed type, which matters for yytoken.
m4_define([b4_declare_symbol_enum],
-[[ /* Symbol type. */
+[[ /* Symbol kinds. */
public enum SymbolKind
{
- ]m4_join([,
- ],
- ]b4_symbol_kind([-2])[ = -2,
- b4_symbol_map([b4_symbol_enum]))[
- };
+ ]b4_symbol_kind([-2])[ = -2, /* No symbol. */
+]b4_symbol_foreach([b4_symbol_enum])dnl
+[ };
]])])
--
2.26.0
- [PATCH 0/5] Clean up, Akim Demaille, 2020/04/11
- [PATCH 2/5] d: improvements on symbol kinds,
Akim Demaille <=
- [PATCH 1/5] symbols: minor fixes, Akim Demaille, 2020/04/11
- [PATCH 4/5] todo: update, Akim Demaille, 2020/04/11
- [PATCH 3/5] c++: improvements on symbol kinds, Akim Demaille, 2020/04/11
- Re: [PATCH 3/5] c++: improvements on symbol kinds, Hans Åberg, 2020/04/14
- Re: [PATCH 3/5] c++: improvements on symbol kinds, Akim Demaille, 2020/04/15
- Re: [PATCH 3/5] c++: improvements on symbol kinds, Hans Åberg, 2020/04/15
- Re: [PATCH 3/5] c++: improvements on symbol kinds, Akim Demaille, 2020/04/15
- Re: [PATCH 3/5] c++: improvements on symbol kinds, Hans Åberg, 2020/04/15
- Re: [PATCH 3/5] c++: improvements on symbol kinds, Akim Demaille, 2020/04/15
- Re: [PATCH 3/5] c++: improvements on symbol kinds, Hans Åberg, 2020/04/15