Re: Token value in custom error reporting

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
Hi Adrian,

> Le 18 juin 2020 à 11:26, Adrian Vogelsgesang <[email protected]> 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-quotes.

That does sound like a nice idea.

However, you might want to add a rule for this in your grammar: accept
identifiers where strings are expected, and generates the error message
there.  You could even register the error, and yet continue with the
identifier turned into a string.  Not just better diagnostics, but also
better error recovery.

It might be impractical if that generates tons of new conflicts, of course.

> 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 currently offers the API to do so)

Well, in a way it does: check if it's in the expected tokens.  Agreed,
it's more costly than it could be, but it's available.

I'm not opposed to extending the API, but it does frighten me:
API are really binding us, and make evolutions much more difficult.

Cheers!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.