mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
c: make the token kind definition nicer to read
From
enum gram_tokentype
{
GRAM_EOF = 0,
STRING = 3,
TSTRING = 4,
PERCENT_TOKEN = 5,
To
enum gram_tokentype
{
GRAM_EOF = 0, /* "end of file" */
STRING = 3, /* "string" */
TSTRING = 4, /* "translatable string" */
PERCENT_TOKEN = 5, /* "%token" */
* data/skeletons/bison.m4 (b4_last_enum_token): New.
* data/skeletons/c.m4 (b4_token_enum, b4_token_enums): Show the
corresponding symbol.
This commit is contained in:
@@ -553,8 +553,18 @@ m4_define([b4_any_token_visible_if],
|
||||
m4_define([b4_token_format],
|
||||
[b4_token_visible_if([$2],
|
||||
[m4_format([[$1]],
|
||||
m4_quote(b4_symbol([$2], [id])),
|
||||
m4_quote(b4_symbol([$2], b4_api_token_raw_if([[number]], [[user_number]]))))])])
|
||||
m4_expand(b4_symbol([$2], [id])),
|
||||
m4_expand(b4_symbol([$2], b4_api_token_raw_if([[number]], [[user_number]]))))])])
|
||||
|
||||
|
||||
# b4_last_enum_token
|
||||
# ------------------
|
||||
# The code of the last token visible token.
|
||||
m4_define([_b4_last_enum_token],
|
||||
[b4_token_visible_if([$1],
|
||||
[m4_define([b4_last_enum_token], [$1])])])
|
||||
b4_symbol_foreach([_b4_last_enum_token])
|
||||
|
||||
|
||||
|
||||
## ------- ##
|
||||
|
||||
@@ -170,9 +170,7 @@ m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
||||
m4_define([b4_token_enums],
|
||||
[[enum yytokentype
|
||||
{
|
||||
]m4_join([,
|
||||
],
|
||||
b4_symbol_map([b4_token_enum]))[
|
||||
]b4_symbol_foreach([b4_token_enum])[
|
||||
};]dnl
|
||||
])
|
||||
|
||||
|
||||
@@ -449,7 +449,13 @@ m4_join([
|
||||
# ------------------------
|
||||
# Output the definition of this token as an enum.
|
||||
m4_define([b4_token_enum],
|
||||
[b4_token_format([%s = %s], [$1])])
|
||||
[b4_token_visible_if([$1],
|
||||
[m4_format([ %-30s %s],
|
||||
m4_format([[%s = %s%s%s]],
|
||||
[b4_symbol([$1], [id])],
|
||||
[b4_symbol([$1], b4_api_token_raw_if([[number]], [[user_number]]))],
|
||||
m4_if([$1], b4_last_enum_token, [], [[,]])),
|
||||
[b4_symbol_tag_comment([$1])])])])
|
||||
|
||||
|
||||
# b4_token_enums
|
||||
@@ -461,9 +467,7 @@ m4_define([b4_token_enums],
|
||||
# define ]b4_api_PREFIX[TOKENTYPE
|
||||
enum ]b4_api_prefix[tokentype
|
||||
{
|
||||
]m4_join([,
|
||||
],
|
||||
b4_symbol_map([b4_token_enum]))[
|
||||
]b4_symbol_foreach([b4_token_enum])[
|
||||
};
|
||||
#endif
|
||||
]])])
|
||||
|
||||
Reference in New Issue
Block a user