mainThe GNU Bourne-Again SHell - Support: sr #110747, Include expected token in error...


sr #110747: Include expected token in error messages

Submitter:  None
Submitted:  Mon 24 Oct 2022 08:10:04 PM UTC
Category:  None Priority:  5 - Normal
Severity:  1 - Wish Status:  Done
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  Mac OS
* Mandatory Fields

Add a New Comment Rich Markup

Mon 31 Oct 2022 01:53:02 PM UTC, comment #1: 

It's a little harder than you think. A bison parser doesn't really know what it's `looking for', it knows it has a complete command when the rule reduces. In this case, for instance, it knows that none of the possible rule matches can have `done' as the next token.

If the bison lookahead set isn't private, I might be able to parse it out here, but we'll see.

Chet Ramey <chet>
Group administrator
Mon 24 Oct 2022 08:10:04 PM UTC, original submission:  

Say I have a while loop, and I have an if statement inside, like:

while true
    if something; then
        run code

And since I left out the fi there, then I get an error message "syntax error near unexpected token `done'".

Wouldn't it be possible to add an "Expected token 'fi'" to that error message? Since it must know what token it's expecting if 'done' is unexpected.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-10-31 chet StatusNone Done

    Back to the top

    Powered by Savane 3.13-b921.
    Corresponding source code