[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to get left hand side symbol in action
From: |
Derek Clegg |
Subject: |
Re: how to get left hand side symbol in action |
Date: |
Fri, 10 May 2019 13:38:33 -0700 |
> On May 10, 2019, at 10:43 AM, Akim Demaille <address@hidden> wrote:
>
>
>
>> Le 10 mai 2019 à 16:28, Christian Schoenebeck <address@hidden> a écrit :
>>
>> On Freitag, 10. Mai 2019 06:57:00 CEST Derek Clegg wrote:
>>> In fact, I do not think error messages in the generated parser should be
>>> provided by bison, except as a trivial default. Instead, I’d like to see
>>> bison call a function (which I provide) when a syntax error occurs, with a
>>> list of what was expected along with what was encountered. Obviously, they
>>> should be provided without translation. That would be the most flexible.
>>
>> Yep, I can just agree.
>
> Except that you don't. The API that was proposed initially did not
> fit your need. At least, that was my understanding of
>
> https://lists.gnu.org/archive/html/help-bison/2019-02/msg00018.html
>
> Listen guys (Derek, Christian): how about you submit a patch of what
> you think the feature should be?
I believe that my suggestion in the above post would be a good starting point.
While Christian’s concern is valid, I think my proposal would be an improvement
over the current method of error reporting. Just to reiterate, I suggested this
approach:
> ...replace the code starting with
>
> char const* yyformat = YY_NULLPTR;
> switch (yycount)
> {
> #define YYCASE_(N, S) \
> case N: \
> yyformat = S; \
> break
> …
> return yyres;
>
> in yysyntax_error_ with a call like
>
> my_yysyntax_error(yyarg, yycount);
>
> where “my_yysyntax_error” is a user-defined function which does the work of
> handling syntax error reporting.
>
> In C++, we could be fancier: have two functions, one for a “pure” syntax
> error:
>
> void my_yysyntax_error();
>
> and one for syntax errors involving unexpected tokens:
>
> void my_yysyntax_error(std::string unexpected_token,
> std::vector<std::string> expected_tokens);
>
> The call would be something like this:
>
> if (yycount == 0) {
> my_yysyntax_error();
> } else {
> my_yysyntax_error(yyarg[0], std::vector<std::string>{yyarg + 1, yyarg +
> yycount});
> }
- Re: how to get left hand side symbol in action, (continued)
- Re: how to get left hand side symbol in action, Hans Åberg, 2019/05/06
- Re: how to get left hand side symbol in action, Akim Demaille, 2019/05/09
- Re: how to get left hand side symbol in action, Hans Åberg, 2019/05/09
- Re: how to get left hand side symbol in action, Christian Schoenebeck, 2019/05/09
- Re: how to get left hand side symbol in action, r0ller, 2019/05/09
- Re: how to get left hand side symbol in action, Akim Demaille, 2019/05/10
- Re: how to get left hand side symbol in action, Hans Åberg, 2019/05/10
- Re: how to get left hand side symbol in action, Derek Clegg, 2019/05/10
- Re: how to get left hand side symbol in action, Christian Schoenebeck, 2019/05/10
- Re: how to get left hand side symbol in action, Akim Demaille, 2019/05/10
- Re: how to get left hand side symbol in action,
Derek Clegg <=
- Re: how to get left hand side symbol in action, Christian Schoenebeck, 2019/05/11
- Re: how to get left hand side symbol in action, Akim Demaille, 2019/05/19
- Re: how to get left hand side symbol in action, Christian Schoenebeck, 2019/05/20
- Re: how to get left hand side symbol in action, Christian Schoenebeck, 2019/05/10
- Re: how to get left hand side symbol in action, Akim Demaille, 2019/05/10
- Re: how to get left hand side symbol in action, Christian Schoenebeck, 2019/05/10
- Re: how to get left hand side symbol in action, Hans Åberg, 2019/05/10
- Re: how to get left hand side symbol in action, Derek Clegg, 2019/05/10