doc: promote yytoken_kind_t, not yytokentype

* data/skeletons/c.m4 (yytoken_kind_t): New.
* data/skeletons/c++.m4, data/skeletons/lalr1.cc (yysymbol_kind_type):
New.
* examples/c/lexcalc/parse.y, examples/c/reccalc/parse.y,
* tests/regression.at:
Use them.
* doc/bison.texi: Replace "enum yytokentype" by "yytoken_kind_t".
(api.token.raw): Explain that it forces "yytoken_kind_t" to coincide
with "yysymbol_kind_t".
(Calling Convention): Mention YYEOF.
(Table of Symbols): Add entries for "yytoken_kind_t" and
"yysymbol_kind_t".
(Glossary): Add entries for "Kind", "Token kind" and "Symbol kind".
This commit is contained in:
Akim Demaille
2020-04-12 18:03:37 +02:00
parent c973361138
commit 7a226860ef
10 changed files with 110 additions and 76 deletions

View File

@@ -534,8 +534,8 @@ m4_define([b4_symbol_map],
# b4_token_visible_if(NUM, IF-TRUE, IF-FALSE)
# -------------------------------------------
# Whether NUM denotes a token that has an exported definition (i.e.,
# shows in enum yytokentype).
# Whether NUM denotes a token kind that has an exported definition
# (i.e., shows in enum yytokentype).
m4_define([b4_token_visible_if],
[b4_symbol_if([$1], [is_token],
[b4_symbol_if([$1], [has_id], [$2], [$3])],

View File

@@ -169,7 +169,7 @@ m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
# b4_token_enums
# --------------
# Output the definition of the tokens as enums.
# Output the definition of the token kinds.
m4_define([b4_token_enums],
[[enum yytokentype
{
@@ -260,8 +260,11 @@ m4_define([b4_public_types_declare],
]b4_token_enums[
};
/// (External) token kind, as returned by yylex.
typedef token::yytokentype token_type;
/// Token kind, as returned by yylex.
typedef token::yytokentype token_kind_type;
/// Backward compatibility alias.
typedef token_kind_type token_type;
/// Symbol kinds.
struct symbol_kind
@@ -385,7 +388,7 @@ m4_define([b4_symbol_type_define],
by_type (const by_type& that);
/// The symbol type as needed by the constructor.
typedef token_type kind_type;
typedef token_kind_type kind_type;
/// Constructor from (external) token numbers.
by_type (kind_type t);
@@ -493,7 +496,7 @@ m4_define([b4_public_types_define],
: type (that.type)
{}
]b4_inline([$1])b4_parser_class[::by_type::by_type (token_type t)
]b4_inline([$1])b4_parser_class[::by_type::by_type (token_kind_type t)
: type (yytranslate_ (t))
{}

View File

@@ -449,7 +449,7 @@ m4_define([b4_token_define],
# ----------------
# Output the definition of the tokens.
m4_define([b4_token_defines],
[b4_any_token_visible_if([/* Tokens. */
[b4_any_token_visible_if([/* Token kinds. */
m4_join([
], b4_symbol_map([b4_token_define]))
])])
@@ -470,15 +470,16 @@ m4_define([b4_token_enum],
# b4_token_enums
# --------------
# The definition of the tokens (if there are) as enums.
# The definition of the token kinds.
m4_define([b4_token_enums],
[b4_any_token_visible_if([[/* Token type. */
[b4_any_token_visible_if([[/* Token kinds. */
#ifndef ]b4_api_PREFIX[TOKENTYPE
# define ]b4_api_PREFIX[TOKENTYPE
enum ]b4_api_prefix[tokentype
{
]b4_symbol_foreach([b4_token_enum])dnl
[ };
typedef enum ]b4_api_prefix[tokentype ]b4_api_prefix[token_kind_t;
#endif
]])])

View File

@@ -302,7 +302,7 @@ m4_define([b4_shared_declarations],
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
/// Convert a scanner token kind \a t to a symbol kind.
/// In theory \a t should be a token_type, but character literals
/// In theory \a t should be a token_kind_type, but character literals
/// are valid, yet not members of the token_type enum.
static symbol_kind_type yytranslate_ (int t);
]b4_parse_error_bmatch([custom\|detailed], [[