[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/8] skeletons: use consistently "kind" instead of "type" in the
From: |
Akim Demaille |
Subject: |
[PATCH 6/8] skeletons: use consistently "kind" instead of "type" in the code |
Date: |
Sun, 5 Apr 2020 16:30:01 +0200 |
* data/skeletons/bison.m4, data/skeletons/c++.m4, data/skeletons/c.m4,
* data/skeletons/glr.cc, data/skeletons/lalr1.cc,
* data/skeletons/lalr1.d, data/skeletons/lalr1.java:
Refer to the "kind" of a symbol, not its "type", where appropriate.
---
TODO | 1 +
data/skeletons/bison.m4 | 18 +++++++++---------
data/skeletons/c++.m4 | 10 +++++-----
data/skeletons/c.m4 | 18 +++++++++---------
data/skeletons/glr.c | 2 +-
data/skeletons/glr.cc | 22 +++++++++++-----------
data/skeletons/lalr1.cc | 12 ++++++------
data/skeletons/lalr1.d | 6 +++---
data/skeletons/lalr1.java | 6 +++---
data/skeletons/yacc.c | 2 +-
10 files changed, 49 insertions(+), 48 deletions(-)
diff --git a/TODO b/TODO
index ac61ac26..1e589ddc 100644
--- a/TODO
+++ b/TODO
@@ -3,6 +3,7 @@
- yyexpected_tokens in all the languages.
- YYNOMEM
- i18n in Java
+- symbol.type_get should be kind_get, and it's not documented.
** Naming conventions
There's no good reason to use the "yy" prefix in parser::context, is there?
diff --git a/data/skeletons/bison.m4 b/data/skeletons/bison.m4
index 480872fd..30168007 100644
--- a/data/skeletons/bison.m4
+++ b/data/skeletons/bison.m4
@@ -456,9 +456,9 @@ m4_define([b4_symbol_tag_comment],
])
-# b4_symbol_action(SYMBOL-NUM, KIND)
-# ----------------------------------
-# Run the action KIND (destructor or printer) for SYMBOL-NUM.
+# b4_symbol_action(SYMBOL-NUM, ACTION)
+# ------------------------------------
+# Run the action ACTION ("destructor" or "printer") for SYMBOL-NUM.
m4_define([b4_symbol_action],
[b4_symbol_if([$1], [has_$2],
[b4_dollar_pushdef([(*yyvaluep)],
@@ -482,21 +482,21 @@ m4_define([b4_symbol_destructor], [b4_symbol_action([$1],
[destructor])])
m4_define([b4_symbol_printer], [b4_symbol_action([$1], [printer])])
-# b4_symbol_actions(KIND, [TYPE = yytype])
-# ----------------------------------------
-# Emit the symbol actions for KIND ("printer" or "destructor").
-# Dispatch on TYPE.
+# b4_symbol_actions(ACTION, [KIND = yykind])
+# ------------------------------------------
+# Emit the symbol actions for ACTION ("destructor" or "printer").
+# Dispatch on KIND.
m4_define([b4_symbol_actions],
[m4_pushdef([b4_actions_], m4_expand([b4_symbol_foreach([b4_symbol_$1])]))dnl
m4_ifval(m4_defn([b4_actions_]),
-[switch (m4_default([$2], [yytype]))
+[switch (m4_default([$2], [yykind]))
{
m4_defn([b4_actions_])[]dnl
default:
break;
}dnl
],
-[YYUSE (m4_default([$2], [yytype]));])dnl
+[YYUSE (m4_default([$2], [yykind]));])dnl
m4_popdef([b4_actions_])dnl
])
diff --git a/data/skeletons/c++.m4 b/data/skeletons/c++.m4
index ac074f4b..f844ef66 100644
--- a/data/skeletons/c++.m4
+++ b/data/skeletons/c++.m4
@@ -262,10 +262,10 @@ m4_define([b4_public_types_declare],
]b4_token_enums[
};
- /// (External) token type, as returned by yylex.
+ /// (External) token kind, as returned by yylex.
typedef token::yytokentype token_type;
- /// (Internal) symbol codes.
+ /// (Internal) symbol kind.
]b4_declare_symbol_enum[
]])
@@ -322,10 +322,10 @@ m4_define([b4_symbol_type_define],
void clear ()
{]b4_variant_if([[
// User destructor.
- symbol_kind_type yytype = this->type_get ();
+ symbol_kind_type yykind = this->type_get ();
basic_symbol<Base>& yysym = *this;
(void) yysym;
- switch (yytype)
+ switch (yykind)
{
]b4_symbol_foreach([b4_symbol_destructor])dnl
[ default:
@@ -333,7 +333,7 @@ m4_define([b4_symbol_type_define],
}
// Type destructor.
-]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
+]b4_symbol_variant([[yykind]], [[value]], [[template destroy]])])[
Base::clear ();
}
diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4
index aeafea4e..259048c3 100644
--- a/data/skeletons/c.m4
+++ b/data/skeletons/c.m4
@@ -620,13 +620,13 @@ m4_define_default([b4_yydestruct_define],
static void
yydestruct (const char *yymsg,
- yysymbol_kind_t yytype, YYSTYPE *yyvaluep]b4_locations_if(dnl
+ yysymbol_kind_t yykind, YYSTYPE *yyvaluep]b4_locations_if(dnl
[[, YYLTYPE *yylocationp]])[]b4_user_formals[)
{
]b4_parse_param_use([yyvaluep], [yylocationp])dnl
[ if (!yymsg)
yymsg = "Deleting";
- YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+ YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
]b4_symbol_actions([destructor])[
@@ -646,7 +646,7 @@ m4_define_default([b4_yy_symbol_print_define],
static void
yy_symbol_value_print (FILE *yyo,
- yysymbol_kind_t yytype, YYSTYPE const * const
yyvaluep]b4_locations_if(dnl
+ yysymbol_kind_t yykind, YYSTYPE const * const
yyvaluep]b4_locations_if(dnl
[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[)
{
FILE *yyoutput = yyo;
@@ -656,8 +656,8 @@ yy_symbol_value_print (FILE *yyo,
dnl glr.c does not feature yytoknum.
m4_if(b4_skeleton, ["yacc.c"],
[[# ifdef YYPRINT
- if (yytype < YYNTOKENS)
- YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
+ if (yykind < YYNTOKENS)
+ YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
# endif
]])dnl
b4_percent_code_get([[pre-printer]])dnl
@@ -674,16 +674,16 @@ b4_percent_code_get([[post-printer]])dnl
static void
yy_symbol_print (FILE *yyo,
- yysymbol_kind_t yytype, YYSTYPE const * const
yyvaluep]b4_locations_if(dnl
+ yysymbol_kind_t yykind, YYSTYPE const * const
yyvaluep]b4_locations_if(dnl
[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[)
{
YYFPRINTF (yyo, "%s %s (",
- yytype < YYNTOKENS ? "token" : "nterm", yysymbol_name (yytype));
+ yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
]b4_locations_if([ YY_LOCATION_PRINT (yyo, *yylocationp);
YYFPRINTF (yyo, ": ");
])dnl
-[ yy_symbol_value_print (yyo, yytype, yyvaluep]dnl
+[ yy_symbol_value_print (yyo, yykind, yyvaluep]dnl
b4_locations_if([, yylocationp])[]b4_user_args[);
YYFPRINTF (yyo, ")");
}]dnl
@@ -709,7 +709,7 @@ m4_define([b4_symbol_type_register],
[m4_define([b4_symbol($1, type_tag)],
[b4_symbol_if([$1], [has_id],
[b4_symbol([$1], [id])],
- [yytype_[]b4_symbol([$1], [number])])])dnl
+ [yykind_[]b4_symbol([$1], [number])])])dnl
m4_append([b4_union_members],
m4_expand([
b4_symbol_tag_comment([$1])dnl
diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
index 8add28fb..f5d51bb1 100644
--- a/data/skeletons/glr.c
+++ b/data/skeletons/glr.c
@@ -2127,7 +2127,7 @@ typedef yyGLRStack yypcontext_t;
static int
yyreport_syntax_error (const yyGLRStack* yystackp]b4_user_formals[);
-/* The token type of the lookahead of this context. */
+/* The kind of the lookahead of this context. */
static yysymbol_kind_t
yypcontext_token (const yyGLRStack *yystackp) YY_ATTRIBUTE_UNUSED;
diff --git a/data/skeletons/glr.cc b/data/skeletons/glr.cc
index 88cbf702..b1bddef8 100644
--- a/data/skeletons/glr.cc
+++ b/data/skeletons/glr.cc
@@ -83,12 +83,12 @@ m4_define([b4_yy_symbol_print_define],
`--------------------*/
static void
-yy_symbol_print (FILE *, ]b4_namespace_ref::b4_parser_class[::symbol_kind_type
yytype,
+yy_symbol_print (FILE *, ]b4_namespace_ref::b4_parser_class[::symbol_kind_type
yytoken,
const ]b4_namespace_ref::b4_parser_class[::semantic_type
*yyvaluep]b4_locations_if([[,
const ]b4_namespace_ref::b4_parser_class[::location_type
*yylocationp]])[]b4_user_formals[)
{
]b4_parse_param_use[]dnl
-[ yyparser.yy_symbol_print_ (yytype, yyvaluep]b4_locations_if([,
yylocationp])[);
+[ yyparser.yy_symbol_print_ (yytoken, yyvaluep]b4_locations_if([,
yylocationp])[);
}
]])[
@@ -175,7 +175,7 @@ m4_pushdef([b4_parse_param],
m4_defn([b4_parse_param_orig]))dnl
`--------------------*/
void
- ]b4_parser_class[::yy_symbol_value_print_ (symbol_kind_type yytype,
+ ]b4_parser_class[::yy_symbol_value_print_ (symbol_kind_type yykind,
const semantic_type* yyvaluep]b4_locations_if([[,
const location_type* yylocationp]])[)
{]b4_locations_if([[
@@ -189,14 +189,14 @@ m4_pushdef([b4_parse_param],
m4_defn([b4_parse_param_orig]))dnl
void
- ]b4_parser_class[::yy_symbol_print_ (symbol_kind_type yytype,
+ ]b4_parser_class[::yy_symbol_print_ (symbol_kind_type yykind,
const semantic_type* yyvaluep]b4_locations_if([[,
const location_type* yylocationp]])[)
{
- *yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm")
- << ' ' << yytname[yytype] << " ("]b4_locations_if([[
+ *yycdebug_ << (yykind < YYNTOKENS ? "token" : "nterm")
+ << ' ' << yytname[yykind] << " ("]b4_locations_if([[
<< *yylocationp << ": "]])[;
- yy_symbol_value_print_ (yytype, yyvaluep]b4_locations_if([[,
yylocationp]])[);
+ yy_symbol_value_print_ (yykind, yyvaluep]b4_locations_if([[,
yylocationp]])[);
*yycdebug_ << ')';
}
@@ -322,17 +322,17 @@ b4_percent_code_get([[requires]])[
# if ]b4_api_PREFIX[DEBUG
public:
/// \brief Report a symbol value on the debug stream.
- /// \param yytype The token type.
+ /// \param yykind The symbol kind.
/// \param yyvaluep Its semantic value.]b4_locations_if([[
/// \param yylocationp Its location.]])[
- virtual void yy_symbol_value_print_ (symbol_kind_type yytype,
+ virtual void yy_symbol_value_print_ (symbol_kind_type yykind,
const semantic_type*
yyvaluep]b4_locations_if([[,
const location_type* yylocationp]])[);
/// \brief Report a symbol on the debug stream.
- /// \param yytype The token type.
+ /// \param yykind The symbol kind.
/// \param yyvaluep Its semantic value.]b4_locations_if([[
/// \param yylocationp Its location.]])[
- virtual void yy_symbol_print_ (symbol_kind_type yytype,
+ virtual void yy_symbol_print_ (symbol_kind_type yykind,
const semantic_type*
yyvaluep]b4_locations_if([[,
const location_type* yylocationp]])[);
private:
diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index 926db09d..104009c9 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -301,7 +301,7 @@ m4_define([b4_shared_declarations],
static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
- /// Convert a scanner token number \a t to a symbol number.
+ /// Convert a scanner token kind \a t to a symbol kind.
/// In theory \a t should be a token_type, but character literals
/// are valid, yet not members of the token_type enum.
static symbol_kind_type yytranslate_ (int t);
@@ -361,7 +361,7 @@ m4_define([b4_shared_declarations],
/// Default constructor.
by_state () YY_NOEXCEPT;
- /// The symbol type as needed by the constructor.
+ /// The symbol kind as needed by the constructor.
typedef state_type kind_type;
/// Constructor.
@@ -376,7 +376,7 @@ m4_define([b4_shared_declarations],
/// Steal the symbol type from \a that.
void move (by_state& that);
- /// The (internal) type number (corresponding to \a state).
+ /// The symbol kind (corresponding to \a state).
/// \a YYSYMBOL_YYEMPTY when empty.
symbol_kind_type type_get () const YY_NOEXCEPT;
@@ -773,15 +773,15 @@ b4_parse_error_case([verbose], [[
{
std::ostream& yyoutput = yyo;
YYUSE (yyoutput);
- symbol_kind_type yytype = yysym.type_get ();
+ symbol_kind_type yykind = yysym.type_get ();
#if defined __GNUC__ && ! defined __clang__ && ! defined __ICC && __GNUC__ *
100 + __GNUC_MINOR__ <= 408
// Avoid a (spurious) G++ 4.8 warning about "array subscript is
// below array bounds".
if (yysym.empty ())
std::abort ();
#endif
- yyo << (yytype < YYNTOKENS ? "token" : "nterm")
- << ' ' << yytname_[yytype] << " ("]b4_locations_if([
+ yyo << (yykind < YYNTOKENS ? "token" : "nterm")
+ << ' ' << yytname_[yykind] << " ("]b4_locations_if([
<< yysym.location << ": "])[;
]b4_symbol_actions([printer])[
yyo << ')';
diff --git a/data/skeletons/lalr1.d b/data/skeletons/lalr1.d
index b3ed8437..cec130c5 100644
--- a/data/skeletons/lalr1.d
+++ b/data/skeletons/lalr1.d
@@ -401,14 +401,14 @@ b4_user_union_members
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
- private final void yy_symbol_print (string s, SymbolKind yytype,
+ private final void yy_symbol_print (string s, SymbolKind yykind,
ref ]b4_yystype[ yyvaluep]dnl
b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
{
if (0 < yydebug)
{
- string message = s ~ (yytype < yyntokens_ ? " token " : " nterm ")
- ~ yytname_[yytype] ~ " ("]b4_locations_if([
+ string message = s ~ (yykind < yyntokens_ ? " token " : " nterm ")
+ ~ yytname_[yykind] ~ " ("]b4_locations_if([
~ yylocationp.toString() ~ ": "])[;
static if (__traits(compiles, message ~= yyvaluep.toString ()))
message ~= yyvaluep.toString ();
diff --git a/data/skeletons/lalr1.java b/data/skeletons/lalr1.java
index aeaedded..af47dc14 100644
--- a/data/skeletons/lalr1.java
+++ b/data/skeletons/lalr1.java
@@ -499,12 +499,12 @@ import java.text.MessageFormat;
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
- private void yySymbolPrint (String s, SymbolKind yytype,
+ private void yySymbolPrint (String s, SymbolKind yykind,
]b4_yystype[ yyvaluep]dnl
b4_locations_if([, Object yylocationp])[)
{
- yycdebug (s + (yytype.getCode () < yyntokens_ ? " token " : " nterm ")
- + yysymbolName (yytype) + " ("]b4_locations_if([
+ yycdebug (s + (yykind.getCode () < yyntokens_ ? " token " : " nterm ")
+ + yysymbolName (yykind) + " ("]b4_locations_if([
+ yylocationp + ": "])[
+ (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")");
}]])[
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index 52383d29..99d99ff4 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -1209,7 +1209,7 @@ yyexpected_tokens (const yypcontext_t *yyctx,
]b4_parse_error_bmatch(
[custom],
-[[/* The token type of the lookahead of this context. */
+[[/* The kind of the lookahead of this context. */
static yysymbol_kind_t
yypcontext_token (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
--
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, 2020/04/05
- [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 <=
- [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