bison-patches
[Top][All Lists]
Advanced

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

style: use b4_token_visible_if


From: Akim Demaille
Subject: style: use b4_token_visible_if
Date: Wed, 19 Dec 2018 07:37:12 +0100

commit 6e9f9fcafc6d4b3a27f1d970cd1a876d2ae24289
Author: Akim Demaille <address@hidden>
Date:   Wed Dec 19 06:52:13 2018 +0100

    style: use b4_token_visible_if
    
    And other formatting/comment changes.
    
    * data/variant.hh: Here.

diff --git a/data/README b/data/README
index 50d7735b..6b45ad6b 100644
--- a/data/README
+++ b/data/README
@@ -90,12 +90,15 @@ The various FIELDS are:
 - tag: string.
   A representation of the symbol.  Can be 'foo', 'foo.id', '"foo"' etc.
 - user_number: integer
-  The assigned (external) number as used by yylex.
+  The external number as used by yylex.  Can be ASCII code when a character,
+  some number chosen by bison, or some user number in the case of
+  %token FOO <NUM>.  Corresponds to yychar in yacc.c.
 - is_token: 0 or 1
   Whether this is a terminal symbol.
 - number: integer
-  The internalized number (used after yytranslate).  This is the same
-  number that serves as key b4_symbol(NUM, FIELD).
+  The internal number (computed from the external number by yytranslate).
+  Corresponds to yytoken in yacc.c.  This is the same number that serves as
+  key in b4_symbol(NUM, FIELD).
 - has_type: 0, 1
   Whether has a semantic value.
 - type_tag: string
diff --git a/data/bison.m4 b/data/bison.m4
index 484bc813..e3260691 100644
--- a/data/bison.m4
+++ b/data/bison.m4
@@ -263,8 +263,8 @@ m4_define([b4_subtract],
 # -------------------
 # Join with comma, skipping empty arguments.
 # b4_join calls itself recursively until it sees the first non-empty
-# argument, then calls _b4_join which prepends each non-empty argument
-# with a comma.
+# argument, then calls _b4_join (i.e., `_$0`) which prepends each
+# non-empty argument with a comma.
 m4_define([b4_join],
 [m4_if([$#$1],
        [1], [],
diff --git a/data/variant.hh b/data/variant.hh
index b26a7c83..6b6b9029 100644
--- a/data/variant.hh
+++ b/data/variant.hh
@@ -339,7 +339,7 @@ m4_define([b4_symbol_value_template],
 # ------------------------------------------
 # Declare make_SYMBOL for SYMBOL-NUM.  Use at class-level.
 m4_define([_b4_symbol_constructor_declare],
-[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
+[b4_token_visible_if([$1],
 [#if 201103L <= YY_CPLUSPLUS
     static
     symbol_type
@@ -355,7 +355,7 @@ b4_join(b4_symbol_if([$1], [has_type],
                      [const b4_symbol([$1], [type])& v]),
         b4_locations_if([const location_type& l])));
 #endif
-])])])
+])])
 
 
 # b4_symbol_constructor_declare
@@ -372,8 +372,8 @@ b4_symbol_foreach([_b4_symbol_constructor_declare])])
 # -----------------------------------------
 # Define make_SYMBOL for SYMBOL-NUM.
 m4_define([_b4_symbol_constructor_define],
-[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
-[# if 201103L <= YY_CPLUSPLUS
+[b4_token_visible_if([$1],
+[#if 201103L <= YY_CPLUSPLUS
   inline
   b4_parser_class_name::symbol_type
   b4_parser_class_name::make_[]_b4_symbol([$1], [id]) (dnl
@@ -398,14 +398,14 @@ b4_join(b4_symbol_if([$1], [has_type],
                                 b4_locations_if([l])));
   }
 #endif
-])])])
+])])
 
 
 # b4_basic_symbol_constructor_declare(SYMBOL-NUM)
 # -----------------------------------------------
 # Generate a constructor declaration for basic_symbol from given type.
 m4_define([b4_basic_symbol_constructor_declare],
-[[# if 201103L <= YY_CPLUSPLUS
+[[#if 201103L <= YY_CPLUSPLUS
       basic_symbol (]b4_join(
           [typename Base::kind_type t],
           b4_symbol_if([$1], [has_type], [b4_symbol([$1], [type])&& v]),
@@ -418,11 +418,12 @@ m4_define([b4_basic_symbol_constructor_declare],
 #endif
 ]])
 
+
 # b4_basic_symbol_constructor_define(SYMBOL-NUM)
 # ----------------------------------------------
 # Generate a constructor implementation for basic_symbol from given type.
 m4_define([b4_basic_symbol_constructor_define],
-[[# if 201103L <= YY_CPLUSPLUS
+[[#if 201103L <= YY_CPLUSPLUS
   template <typename Base>
   ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
           [typename Base::kind_type t],




reply via email to

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