yacc.c: use yysymbol_type_t instead of int for yytoken

Now that we have a proper type for internal symbol numbers, let's use
it.  More code needs conversion, e.g., printers and destructors, but
they are shared with glr.c, which is not ready yet for this change.

It will also help us deal with warnings such as (GCC9 on GNU/Linux):

    input.c: In function 'int yyparse()':
    input.c:475:37: error: enumeral and non-enumeral type in conditional expression [-Werror=extra]
      475 |   (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYSYMBOL_YYUNDEF)
          |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    input.c:1024:17: note: in expansion of macro 'YYTRANSLATE'
     1024 |       yytoken = YYTRANSLATE (yychar);
          |                 ^~~~~~~~~~~

* data/skeletons/yacc.c (yytranslate, yysymbol_name)
(yyparse_context_t, yyexpected_tokens, yypstate_expected_tokens)
(yysyntax_error_arguments):
Use yysymbol_type_t instead of int.
This commit is contained in:
Akim Demaille
2020-03-28 15:15:19 +01:00
parent f62f1db298
commit 00c80bc96c
3 changed files with 18 additions and 18 deletions

View File

@@ -289,7 +289,7 @@ yyreport_syntax_error (const yyparse_context_t *ctx)
fprintf (stderr, ": syntax error");
{
enum { TOKENMAX = 10 };
int expected[TOKENMAX];
yysymbol_type_t expected[TOKENMAX];
int n = yyexpected_tokens (ctx, expected, TOKENMAX);
if (n < 0)
// Forward errors to yyparse.
@@ -300,7 +300,7 @@ yyreport_syntax_error (const yyparse_context_t *ctx)
i == 0 ? ": expected" : " or", yysymbol_name (expected[i]));
}
{
int lookahead = yyparse_context_token (ctx);
yysymbol_type_t lookahead = yyparse_context_token (ctx);
if (lookahead != YYEMPTY)
fprintf (stderr, " before %s", yysymbol_name (lookahead));
}