help-bison
[Top][All Lists]
Advanced

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

Re: Is there an option to change the message produced by YYERROR_VERBOSE


From: Simon Sobisch
Subject: Re: Is there an option to change the message produced by YYERROR_VERBOSE?
Date: Wed, 27 Apr 2016 23:15:00 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2

Hello Hans,
this could work if we pass the current token, using

        %parse-param (char * yytext)

tehn use a wrapper for the current yyerror function.
If we get this specific error we we can do the checks on the passed yytext.

The problem here:
How do we know that the error message "Unexpected %s" occured? A string
compare against all the translated texts (all 5 versions) looks stupid
and brake if the message is ever changed.
In this case we better would add a post-conversion hook via sed in the
makefile adding a function call after

  switch (yycount)
    {
# define YYCASE_(N, S)                      \
      case N:                               \
        yyformat = S;                       \
      break
      YYCASE_(0, YY_("syntax error"));
      YYCASE_(1, YY_("syntax error, unexpected %s"));
      YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
      YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
      YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or
%s"));
      YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or
%s or %s"));
# undef YYCASE_
    }
--> adding here: check_unused_reserved(yytext);

Do I missed the point? Are there other options to consider?


Simon

Am 26.04.2016 um 23:52 schrieb Hans Åberg:
> 
>> On 26 Apr 2016, at 21:39, Simon Sobisch <address@hidden> wrote:
> 
>> If the unexpected %s is not in the reserved words list currently active
>> because of the compiler configuration but is in the global one we add
>> another line to the warning, something like "%s not supported with std %s".
>>
>> How can this be achieved?
> 
> Perhaps you might add an argument with additional info using %parse-param, 
> affecting both yyparse and yyerror; see the manual, sec. 4.1, "The Parser 
> Function yyparse".
> 
> 
> 
> 



reply via email to

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