symbols: minor fixes

* data/skeletons/bison.m4 (b4_symbol_kind): Series of _ are useless,
one is enough.
* data/skeletons/c.m4 (b4_token_enum): Fix overquoting.
This commit is contained in:
Akim Demaille
2020-04-08 08:13:00 +02:00
parent bbb9750b3e
commit 007e1b5f0a
5 changed files with 18 additions and 20 deletions

View File

@@ -417,12 +417,12 @@ m4_define([b4_symbol_kind],
m4_case([$1], m4_case([$1],
[-2], [[YYEMPTY]], [-2], [[YYEMPTY]],
[0], [[YYEOF]], [0], [[YYEOF]],
[m4_case(m4_quote(b4_symbol([$1], [tag])), [1], [[YYERROR]],
[m4_case(b4_symbol([$1], [tag]),
[$accept], [[YYACCEPT]], [$accept], [[YYACCEPT]],
[error], [[YYERROR]],
[$undefined], [[YYUNDEF]], [$undefined], [[YYUNDEF]],
[b4_symbol_if([$1], [has_id], m4_expand(_b4_symbol([$1], [id])), [b4_symbol_if([$1], [has_id], _b4_symbol([$1], [id]),
[[$1_][]m4_bpatsubst(m4_quote(_b4_symbol([$1], [tag])), [[^a-zA-Z_0-9]], [_])])])])]) [m4_bpatsubst([$1-][]_b4_symbol([$1], [tag]), [[^a-zA-Z_0-9]+], [_])])])])])
# b4_symbol(NUM, FIELD) # b4_symbol(NUM, FIELD)

View File

@@ -453,8 +453,8 @@ m4_define([b4_token_enum],
[b4_token_visible_if([$1], [b4_token_visible_if([$1],
[m4_format([ %-30s %s], [m4_format([ %-30s %s],
m4_format([[%s = %s%s%s]], m4_format([[%s = %s%s%s]],
[b4_symbol([$1], [id])], b4_symbol([$1], [id]),
[b4_symbol([$1], b4_api_token_raw_if([[number]], [[user_number]]))], b4_symbol([$1], b4_api_token_raw_if([[number]], [[user_number]])),
m4_if([$1], b4_last_enum_token, [], [[,]])), m4_if([$1], b4_last_enum_token, [], [[,]])),
[b4_symbol_tag_comment([$1])])])]) [b4_symbol_tag_comment([$1])])])])
@@ -468,8 +468,8 @@ m4_define([b4_token_enums],
# define ]b4_api_PREFIX[TOKENTYPE # define ]b4_api_PREFIX[TOKENTYPE
enum ]b4_api_prefix[tokentype enum ]b4_api_prefix[tokentype
{ {
]b4_symbol_foreach([b4_token_enum])[ ]b4_symbol_foreach([b4_token_enum])dnl
}; [ };
#endif #endif
]])]) ]])])
@@ -513,12 +513,12 @@ m4_define([b4_symbol_enum],
# Defining YYEMPTY here is important: it forces the compiler # Defining YYEMPTY here is important: it forces the compiler
# to use a signed type, which matters for yytoken. # to use a signed type, which matters for yytoken.
m4_define([b4_declare_symbol_enum], m4_define([b4_declare_symbol_enum],
[[/* Symbol type. */ [[/* Symbol kind. */
enum yysymbol_kind_t enum yysymbol_kind_t
{ {
]b4_symbol_kind([-2])[ = -2, ]b4_symbol_kind([-2])[ = -2,
]b4_symbol_foreach([b4_symbol_enum])[ ]b4_symbol_foreach([b4_symbol_enum])dnl
}; [};
typedef enum yysymbol_kind_t yysymbol_kind_t; typedef enum yysymbol_kind_t yysymbol_kind_t;
]])]) ]])])

View File

@@ -144,7 +144,7 @@ m4_define([b4_token_enum],
# -------------- # --------------
# Output the definition of the tokens (if there are) as enums. # Output the definition of the tokens (if there are) as enums.
m4_define([b4_token_enums], m4_define([b4_token_enums],
[b4_any_token_visible_if([/* Tokens. */ [b4_any_token_visible_if([/* Token kinds. */
b4_symbol_foreach([b4_token_enum])])]) b4_symbol_foreach([b4_token_enum])])])

View File

@@ -100,7 +100,7 @@
# endif # endif
#include "src/parse-gram.h" #include "src/parse-gram.h"
/* Symbol type. */ /* Symbol kind. */
enum yysymbol_kind_t enum yysymbol_kind_t
{ {
YYSYMBOL_YYEMPTY = -2, YYSYMBOL_YYEMPTY = -2,
@@ -169,14 +169,14 @@ enum yysymbol_kind_t
YYSYMBOL_input = 62, /* input */ YYSYMBOL_input = 62, /* input */
YYSYMBOL_prologue_declarations = 63, /* prologue_declarations */ YYSYMBOL_prologue_declarations = 63, /* prologue_declarations */
YYSYMBOL_prologue_declaration = 64, /* prologue_declaration */ YYSYMBOL_prologue_declaration = 64, /* prologue_declaration */
YYSYMBOL_65____1 = 65, /* $@1 */ YYSYMBOL_65_1 = 65, /* $@1 */
YYSYMBOL_params = 66, /* params */ YYSYMBOL_params = 66, /* params */
YYSYMBOL_grammar_declaration = 67, /* grammar_declaration */ YYSYMBOL_grammar_declaration = 67, /* grammar_declaration */
YYSYMBOL_code_props_type = 68, /* code_props_type */ YYSYMBOL_code_props_type = 68, /* code_props_type */
YYSYMBOL_union_name = 69, /* union_name */ YYSYMBOL_union_name = 69, /* union_name */
YYSYMBOL_symbol_declaration = 70, /* symbol_declaration */ YYSYMBOL_symbol_declaration = 70, /* symbol_declaration */
YYSYMBOL_71____2 = 71, /* $@2 */ YYSYMBOL_71_2 = 71, /* $@2 */
YYSYMBOL_72____3 = 72, /* $@3 */ YYSYMBOL_72_3 = 72, /* $@3 */
YYSYMBOL_precedence_declarator = 73, /* precedence_declarator */ YYSYMBOL_precedence_declarator = 73, /* precedence_declarator */
YYSYMBOL_74_tag_opt = 74, /* tag.opt */ YYSYMBOL_74_tag_opt = 74, /* tag.opt */
YYSYMBOL_generic_symlist = 75, /* generic_symlist */ YYSYMBOL_generic_symlist = 75, /* generic_symlist */
@@ -196,7 +196,7 @@ enum yysymbol_kind_t
YYSYMBOL_grammar = 89, /* grammar */ YYSYMBOL_grammar = 89, /* grammar */
YYSYMBOL_rules_or_grammar_declaration = 90, /* rules_or_grammar_declaration */ YYSYMBOL_rules_or_grammar_declaration = 90, /* rules_or_grammar_declaration */
YYSYMBOL_rules = 91, /* rules */ YYSYMBOL_rules = 91, /* rules */
YYSYMBOL_92____4 = 92, /* $@4 */ YYSYMBOL_92_4 = 92, /* $@4 */
YYSYMBOL_93_rhses_1 = 93, /* rhses.1 */ YYSYMBOL_93_rhses_1 = 93, /* rhses.1 */
YYSYMBOL_rhs = 94, /* rhs */ YYSYMBOL_rhs = 94, /* rhs */
YYSYMBOL_95_named_ref_opt = 95, /* named_ref.opt */ YYSYMBOL_95_named_ref_opt = 95, /* named_ref.opt */
@@ -206,8 +206,7 @@ enum yysymbol_kind_t
YYSYMBOL_id_colon = 99, /* id_colon */ YYSYMBOL_id_colon = 99, /* id_colon */
YYSYMBOL_symbol = 100, /* symbol */ YYSYMBOL_symbol = 100, /* symbol */
YYSYMBOL_string_as_id = 101, /* string_as_id */ YYSYMBOL_string_as_id = 101, /* string_as_id */
YYSYMBOL_102_epilogue_opt = 102, /* epilogue.opt */ YYSYMBOL_102_epilogue_opt = 102 /* epilogue.opt */
}; };
typedef enum yysymbol_kind_t yysymbol_kind_t; typedef enum yysymbol_kind_t yysymbol_kind_t;

View File

@@ -136,7 +136,6 @@ extern int gram_debug;
PERCENT_PARAM = 58, /* "%param" */ PERCENT_PARAM = 58, /* "%param" */
PERCENT_UNION = 59, /* "%union" */ PERCENT_UNION = 59, /* "%union" */
PERCENT_EMPTY = 60 /* "%empty" */ PERCENT_EMPTY = 60 /* "%empty" */
}; };
#endif #endif