Re: Token value in custom error reporting

2020-06-19 Thread Hans Åberg
> On 19 Jun 2020, at 07:16, Akim Demaille wrote: > >> Le 18 juin 2020 à 20:46, Hans Åberg a écrit : >> >> Otherwise, in your link above you suggest not using the semantic value in >> error messages, but when using locations, it contains the token >> delimitations. So there seems to be no ad

Re: Token value in custom error reporting

2020-06-18 Thread Akim Demaille
> Le 18 juin 2020 à 20:46, Hans Åberg a écrit : > > Otherwise, in your link above you suggest not using the semantic value in > error messages, but when using locations, it contains the token > delimitations. So there seems to be no advantage letting the lexer generating > the error. It is

Re: Token value in custom error reporting

2020-06-18 Thread Hans Åberg
> On 18 Jun 2020, at 19:21, Akim Demaille wrote: > >> Le 18 juin 2020 à 19:11, Hans Åberg a écrit : >> >>> On 18 Jun 2020, at 18:56, Akim Demaille wrote: >>> >>> I have already explained what I don't think this is a good idea. >>> >>> https://lists.gnu.org/r/help-bison/2020-06/msg00017.htm

Re: Token value in custom error reporting

2020-06-18 Thread Akim Demaille
> Le 18 juin 2020 à 19:11, Hans Åberg a écrit : > > >> On 18 Jun 2020, at 18:56, Akim Demaille wrote: >> >>> Le 18 juin 2020 à 14:54, Hans Åberg a écrit : >>> >>> In my C++ parser, the lexer has rule >>> . { return my_parser::token::token_error; } >>> >>> When it is triggers, I

Re: Token value in custom error reporting

2020-06-18 Thread Hans Åberg
> On 18 Jun 2020, at 18:56, Akim Demaille wrote: > >> Le 18 juin 2020 à 14:54, Hans Åberg a écrit : >> >> In my C++ parser, the lexer has rule >> . { return my_parser::token::token_error; } >> >> When it is triggers, I get the error: >> :21.1: error: syntax error, unexpected token e

Re: Token value in custom error reporting

2020-06-18 Thread Adrian Vogelsgesang
Hi Akim, > That being said, this is clearly a nice-to-have and by no means necessary. > Also, I guess I would run into different issues, first (e.g., when encountering an error I would like to check "given the current state, would an identifier be valid". I don't think bison currentl

Re: Token value in custom error reporting

2020-06-18 Thread Akim Demaille
> Le 18 juin 2020 à 14:54, Hans Åberg a écrit : > > In my C++ parser, the lexer has rule > . { return my_parser::token::token_error; } > > When it is triggers, I get the error: > :21.1: error: syntax error, unexpected token error > > It might be nicer to actually write out this tok

Re: Token value in custom error reporting

2020-06-18 Thread Akim Demaille
Hi Adrian, > Le 18 juin 2020 à 11:26, Adrian Vogelsgesang a > écrit : > > Hi Akim, hi Daniele, > > It would probably help, if the error message would include something like >> Hint: Did you mean to refer to table "MyTable" instead of the string-literal >> 'MyTable'? >> If so, use double-quote

Re: Token value in custom error reporting

2020-06-18 Thread Akim Demaille
Daniele, > Le 18 juin 2020 à 10:24, Daniele Nicolodi a écrit : > >> Would you have an example of what you mean? > > Sure, but it is rather contrived :-) > > I am working on a project that is based on Flex and Bison 3.4. The code > goes through some contortions so that the lexer can report erro

Re: Token value in custom error reporting

2020-06-18 Thread Hans Åberg
> On 18 Jun 2020, at 10:24, Daniele Nicolodi wrote: > > On 18/06/2020 00:39, Akim Demaille wrote: >> >> Would you have an example of what you mean? > … > In the existing code, on error the lexer emits a LEX_ERROR token. This > results in a grammar error that triggers error recovery (good) but

Re: Token value in custom error reporting

2020-06-18 Thread Adrian Vogelsgesang
Hi Akim, hi Daniele, actually, I would have a use case for accessing the semantic value for error message formatting, too... Probably less contrived ;) I am using bison for a SQL parser. One of the most common mistakes I see in queries written by beginners is that they get confused between stri

Re: Token value in custom error reporting

2020-06-18 Thread Daniele Nicolodi
On 18/06/2020 00:39, Akim Demaille wrote: > > >> Le 18 juin 2020 à 07:49, Daniele Nicolodi a écrit : >> >> Hi Akim, >> >> On 17/06/2020 23:43, Akim Demaille wrote: >>> I think it's a mistake to try to use the semantic value in error messages. >> >> The goal would not be to use the semantic value

Re: Token value in custom error reporting

2020-06-17 Thread Akim Demaille
> Le 18 juin 2020 à 07:49, Daniele Nicolodi a écrit : > > Hi Akim, > > On 17/06/2020 23:43, Akim Demaille wrote: >> I think it's a mistake to try to use the semantic value in error messages. > > The goal would not be to use the semantic value in the error message, > but to use additional con

Re: Token value in custom error reporting

2020-06-17 Thread Daniele Nicolodi
Hi Akim, On 17/06/2020 23:43, Akim Demaille wrote: > I think it's a mistake to try to use the semantic value in error messages. The goal would not be to use the semantic value in the error message, but to use additional context attached to the token by the lexer to decide how to report the error.

Re: Token value in custom error reporting

2020-06-17 Thread Akim Demaille
Hi Daniele, > Le 17 juin 2020 à 21:56, Daniele Nicolodi a écrit : > > Hello, > > error reporting has always been a pain point for me in the use of flex > and bison, especially in coordinated error handling between the scanner > and the grammar. I am very happy to see a lot of improvements in th