From: Paul Eggert Date: Fri, 22 Jul 2005 17:07:31 +0000 (+0000) Subject: * data/glr.c (YYTOKEN_TABLE): New macro. X-Git-Tag: BISON-2_1~60 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/141f57937b5fe3f5c49d635fffbd4bddbfa03d69 * data/glr.c (YYTOKEN_TABLE): New macro. (yytname): Define if YYTOKEN_TABLE. * data/yacc.c (YYTOKEN_TABLE, yytname): Likewise. * data/lalr1.cc (YYTOKEN_TABLE, yytname_): Likewise. (YYERROR_VERBOSE): Define the same way the other skeletons do. * src/output.c (prepare_symbols): Output token_table_flag. --- diff --git a/data/glr.c b/data/glr.c index f23f9049..080d263c 100644 --- a/data/glr.c +++ b/data/glr.c @@ -172,6 +172,11 @@ b4_pre_prologue[ # define YYERROR_VERBOSE ]b4_error_verbose[ #endif +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE ]b4_token_table[ +#endif + #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) ]m4_ifdef([b4_stype], [b4_syncline([b4_stype_line], [b4_filename]) @@ -331,7 +336,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] = }; #endif -#if (YYDEBUG) || YYERROR_VERBOSE +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = diff --git a/data/lalr1.cc b/data/lalr1.cc index e492173a..e6190c8b 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -149,11 +149,19 @@ b4_syncline([@oline@], [@ofile@])[ # define YYDEBUG ]b4_debug[ #endif -/* Enabling verbose error message. */ -#ifndef YYERROR_VERBOSE +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else # define YYERROR_VERBOSE ]b4_error_verbose[ #endif +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE ]b4_token_table[ +#endif + #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) ]m4_ifdef([b4_stype], [b4_syncline([b4_stype_line], [b4_filename]) @@ -321,7 +329,7 @@ namespace yy /// For a rule, its RHS length. static const ]b4_int_type_for([b4_r2])[ yyr2_[]; -#if YYDEBUG || YYERROR_VERBOSE +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /// For a symbol, its name in clear. static const char* const yytname_[]; #endif @@ -1030,7 +1038,7 @@ yy::]b4_parser_class_name[::yyr2_[] = ]b4_r2[ }; -#if YYDEBUG || YYERROR_VERBOSE +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at \a yyntokens_, nonterminals. */ const char* diff --git a/data/yacc.c b/data/yacc.c index 3dc30898..f4b1b1b9 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -182,6 +182,11 @@ b4_location_if([#define yylloc b4_prefix[]lloc])])[ # define YYERROR_VERBOSE ]b4_error_verbose[ #endif +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE ]b4_token_table[ +#endif + #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) ]m4_ifdef([b4_stype], [b4_syncline([b4_stype_line], [b4_filename]) @@ -415,7 +420,7 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = diff --git a/src/output.c b/src/output.c index 51541822..cd5846bc 100644 --- a/src/output.c +++ b/src/output.c @@ -145,6 +145,7 @@ escaped_output (FILE *out, char const *string) static void prepare_symbols (void) { + MUSCLE_INSERT_BOOL ("token_table", token_table_flag); MUSCLE_INSERT_INT ("tokens_number", ntokens); MUSCLE_INSERT_INT ("nterms_number", nvars); MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);