bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 01/10] c: make the generated YYSTYPE nicer to read


From: Akim Demaille
Subject: [PATCH 01/10] c: make the generated YYSTYPE nicer to read
Date: Tue, 7 Apr 2020 07:13:48 +0200

From

    union GRAM_STYPE
    {
      /* precedence_declarator  */
      assoc precedence_declarator;
      /* "string"  */
      char* STRING;
      /* "translatable string"  */
      char* TSTRING;
      /* "{...}"  */
      char* BRACED_CODE;
      /* "%?{...}"  */

to

    union GRAM_STYPE
    {
      assoc precedence_declarator;             /* precedence_declarator  */
      char* STRING;                            /* "string"  */
      char* TSTRING;                           /* "translatable string"  */
      char* BRACED_CODE;                       /* "{...}"  */

* data/skeletons/c.m4 (b4_symbol_type_register): Use m4_format to
align the comments.
* src/parse-gram.h: Regen.
---
 data/skeletons/c.m4 |   6 +--
 src/parse-gram.h    | 126 +++++++++++++++-----------------------------
 2 files changed, 45 insertions(+), 87 deletions(-)

diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4
index 259048c3..22b02444 100644
--- a/data/skeletons/c.m4
+++ b/data/skeletons/c.m4
@@ -711,9 +711,9 @@ m4_define([b4_symbol_type_register],
                          [b4_symbol([$1], [id])],
                          [yykind_[]b4_symbol([$1], [number])])])dnl
 m4_append([b4_union_members],
-m4_expand([
-  b4_symbol_tag_comment([$1])dnl
-  b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]))
+m4_expand([m4_format([  %-40s %s],
+                     m4_expand([b4_symbol([$1], [type]) b4_symbol([$1], 
[type_tag]);]),
+                     [b4_symbol_tag_comment([$1])])]))
 ])
 
 
diff --git a/src/parse-gram.h b/src/parse-gram.h
index acf1ec21..473dc30e 100644
--- a/src/parse-gram.h
+++ b/src/parse-gram.h
@@ -143,91 +143,49 @@ extern int gram_debug;
 #if ! defined GRAM_STYPE && ! defined GRAM_STYPE_IS_DECLARED
 union GRAM_STYPE
 {
+  assoc precedence_declarator;             /* precedence_declarator  */
+  char* STRING;                            /* "string"  */
+  char* TSTRING;                           /* "translatable string"  */
+  char* BRACED_CODE;                       /* "{...}"  */
+  char* BRACED_PREDICATE;                  /* "%?{...}"  */
+  char* EPILOGUE;                          /* "epilogue"  */
+  char* PROLOGUE;                          /* "%{...%}"  */
+  code_props_type code_props_type;         /* code_props_type  */
+  int INT;                                 /* "integer literal"  */
+  int yykind_82;                           /* int.opt  */
+  named_ref* yykind_95;                    /* named_ref.opt  */
+  param_type PERCENT_PARAM;                /* "%param"  */
+  symbol* token_decl;                      /* token_decl  */
+  symbol* alias;                           /* alias  */
+  symbol* token_decl_for_prec;             /* token_decl_for_prec  */
+  symbol* id;                              /* id  */
+  symbol* id_colon;                        /* id_colon  */
+  symbol* symbol;                          /* symbol  */
+  symbol* string_as_id;                    /* string_as_id  */
+  symbol_list* generic_symlist;            /* generic_symlist  */
+  symbol_list* generic_symlist_item;       /* generic_symlist_item  */
+  symbol_list* nterm_decls;                /* nterm_decls  */
+  symbol_list* token_decls;                /* token_decls  */
+  symbol_list* yykind_80;                  /* token_decl.1  */
+  symbol_list* token_decls_for_prec;       /* token_decls_for_prec  */
+  symbol_list* yykind_85;                  /* token_decl_for_prec.1  */
+  symbol_list* symbol_decls;               /* symbol_decls  */
+  symbol_list* yykind_88;                  /* symbol_decl.1  */
+  uniqstr PERCENT_ERROR_VERBOSE;           /* "%error-verbose"  */
+  uniqstr PERCENT_FLAG;                    /* "%<flag>"  */
+  uniqstr PERCENT_FILE_PREFIX;             /* "%file-prefix"  */
+  uniqstr PERCENT_NAME_PREFIX;             /* "%name-prefix"  */
+  uniqstr PERCENT_PURE_PARSER;             /* "%pure-parser"  */
+  uniqstr BRACKETED_ID;                    /* "[identifier]"  */
+  uniqstr ID;                              /* "identifier"  */
+  uniqstr ID_COLON;                        /* "identifier:"  */
+  uniqstr TAG;                             /* "<tag>"  */
+  uniqstr yykind_74;                       /* tag.opt  */
+  uniqstr tag;                             /* tag  */
+  uniqstr variable;                        /* variable  */
+  unsigned char CHAR;                      /* "character literal"  */
+  value_type value;                        /* value  */
 
-  /* precedence_declarator  */
-  assoc precedence_declarator;
-  /* "string"  */
-  char* STRING;
-  /* "translatable string"  */
-  char* TSTRING;
-  /* "{...}"  */
-  char* BRACED_CODE;
-  /* "%?{...}"  */
-  char* BRACED_PREDICATE;
-  /* "epilogue"  */
-  char* EPILOGUE;
-  /* "%{...%}"  */
-  char* PROLOGUE;
-  /* code_props_type  */
-  code_props_type code_props_type;
-  /* "integer literal"  */
-  int INT;
-  /* int.opt  */
-  int yykind_82;
-  /* named_ref.opt  */
-  named_ref* yykind_95;
-  /* "%param"  */
-  param_type PERCENT_PARAM;
-  /* token_decl  */
-  symbol* token_decl;
-  /* alias  */
-  symbol* alias;
-  /* token_decl_for_prec  */
-  symbol* token_decl_for_prec;
-  /* id  */
-  symbol* id;
-  /* id_colon  */
-  symbol* id_colon;
-  /* symbol  */
-  symbol* symbol;
-  /* string_as_id  */
-  symbol* string_as_id;
-  /* generic_symlist  */
-  symbol_list* generic_symlist;
-  /* generic_symlist_item  */
-  symbol_list* generic_symlist_item;
-  /* nterm_decls  */
-  symbol_list* nterm_decls;
-  /* token_decls  */
-  symbol_list* token_decls;
-  /* token_decl.1  */
-  symbol_list* yykind_80;
-  /* token_decls_for_prec  */
-  symbol_list* token_decls_for_prec;
-  /* token_decl_for_prec.1  */
-  symbol_list* yykind_85;
-  /* symbol_decls  */
-  symbol_list* symbol_decls;
-  /* symbol_decl.1  */
-  symbol_list* yykind_88;
-  /* "%error-verbose"  */
-  uniqstr PERCENT_ERROR_VERBOSE;
-  /* "%<flag>"  */
-  uniqstr PERCENT_FLAG;
-  /* "%file-prefix"  */
-  uniqstr PERCENT_FILE_PREFIX;
-  /* "%name-prefix"  */
-  uniqstr PERCENT_NAME_PREFIX;
-  /* "%pure-parser"  */
-  uniqstr PERCENT_PURE_PARSER;
-  /* "[identifier]"  */
-  uniqstr BRACKETED_ID;
-  /* "identifier"  */
-  uniqstr ID;
-  /* "identifier:"  */
-  uniqstr ID_COLON;
-  /* "<tag>"  */
-  uniqstr TAG;
-  /* tag.opt  */
-  uniqstr yykind_74;
-  /* tag  */
-  uniqstr tag;
-  /* variable  */
-  uniqstr variable;
-  /* "character literal"  */
-  unsigned char CHAR;
-  /* value  */
-  value_type value;
 
 };
 typedef union GRAM_STYPE GRAM_STYPE;
-- 
2.26.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]