c++: improvements on symbol kinds

Instead of

    /// (Internal) symbol kind.
    enum symbol_kind_type
    {
      YYNTOKENS = 5, ///< Number of tokens.
      YYSYMBOL_YYEMPTY = -2,
      YYSYMBOL_YYEOF = 0,                      // END_OF_FILE
      YYSYMBOL_YYERROR = 1,                    // error
      YYSYMBOL_YYUNDEF = 2,                    // $undefined
      YYSYMBOL_TEXT = 3,                       // TEXT
      YYSYMBOL_NUMBER = 4,                     // NUMBER
      YYSYMBOL_YYACCEPT = 5,                   // $accept
      YYSYMBOL_result = 6,                     // result
      YYSYMBOL_list = 7,                       // list
      YYSYMBOL_item = 8                        // item
    };

generate

    /// Symbol kinds.
    struct symbol_kind
    {
      enum symbol_kind_type
      {
        YYNTOKENS = 5, ///< Number of tokens.
        S_YYEMPTY = -2,
        S_YYEOF = 0,                             // END_OF_FILE
        S_YYERROR = 1,                           // error
        S_YYUNDEF = 2,                           // $undefined
        S_TEXT = 3,                              // TEXT
        S_NUMBER = 4,                            // NUMBER
        S_YYACCEPT = 5,                          // $accept
        S_result = 6,                            // result
        S_list = 7,                              // list
        S_item = 8                               // item
      };
    };

* data/skeletons/c++.m4 (api.symbol.prefix): Define to S_.
Adjust all the uses.
(b4_public_types_declare): Nest the enum inside 'struct symbol_kind'.
* data/skeletons/glr.cc, data/skeletons/lalr1.cc,
* tests/headers.at, tests/local.at: Adjust.
This commit is contained in:
Akim Demaille
2020-04-09 08:19:40 +02:00
parent 6c5f690da4
commit 00a654c8ad
5 changed files with 38 additions and 26 deletions

View File

@@ -321,7 +321,7 @@ AT_PERL_CHECK([[-n -0777 -e '
|YYChar
|YYNTOKENS # This is actual scoped in a C++ class.
|YYPUSH_MORE(?:_DEFINED)?
|YYSYMBOL_(\w+) # These guys are scoped.
|S_(YY(ACCEPT|EMPTY|EOF|ERROR|UNDEF)) # These guys are scoped.
|YYUSE
|YY_ATTRIBUTE(?:_PURE|_UNUSED)
|YY(?:_REINTERPRET)?_CAST