help-bison
[Top][All Lists]
Advanced

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

Re: yyerror strlen question


From: Joel E. Denny
Subject: Re: yyerror strlen question
Date: Sun, 17 Jan 2010 16:37:49 -0500 (EST)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

On Sun, 17 Jan 2010, tys lefering wrote:

> using YYERROR_VERBOSE in a bison grammar to get a verbose
> error message at yyerror() it is not mentioned how large
> the error message string may be in the manual or source
> http://www.gnu.org/software/bison/manual/bison.html#Error-Reporting

As far as I know, we've never offered any guarantee on the length.

> reading in the generated yacc y.tab.c the string looks to be
> generated with:
> static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, int
> yystate, int yytoken)
> which has a limit om max. 5 args with enum { YYERROR_VERBOSE_ARGS_MAXIMUM
> = 5 };
> and resulting longest string is like this:
> YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or
> %s"));
> is this correct ?

For now, but 5 is an arbitrary limit, and I know of no guarantee that 
Bison won't evolve beyond it.

> then the longest yyerror string depends on the token names lenght ?
> passing the yyerror string in a gui program to a window and
> need to estimate how long the yyerror string may be.

You can't use strlen?

As I posted earlier today, we have plans to provide an alternative to 
yyerror.  One feature we've discussed is the ability to iterate the 
expected tokens and construct the error message yourself.  That would 
allow you to place whatever limit you like on the length.




reply via email to

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