mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
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:
@@ -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
|
||||
|
||||
@@ -756,7 +756,7 @@ void
|
||||
std::cerr << "syntax error";
|
||||
{
|
||||
symbol_kind_type la = ctx.token ();
|
||||
if (la != YYSYMBOL_YYEMPTY)
|
||||
if (la != symbol_kind::S_YYEMPTY)
|
||||
fprintf (stderr, " on token [%s]", yysymbol_name (la));
|
||||
}
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user