At that point in the grammar TOKEN is "esac)" or "(esac)", from which the WORD 
"esac" is extracted, not converted to Esac, as right paren is not an operator 
character that terminates token recognition. Rule 4 applies to "esac ;" or 
"esac" linebreak, no right paren discovered on lookahead, that I see. Same with 
the '|' char, it does not terminate the TOKEN. It could be more explicit that 
the pattern production is subcontext delimited by the ')', I suppose.
On Friday, February 19, 2021 Chet Ramey via austin-group-l at The Open Group 
<chet.ra...@case.edu> wrote:
On 2/19/21 11:21 AM, Geoff Clare via austin-group-l at The Open Group wrote:

>> There is no way to apply rule 4 to produce "a token identifier acceptable at
>> that point in the grammar". The only token identifier acceptable at that
>> point in the grammar is WORD, and rule 4 does not produce WORD. Rule 4
>> reads:
>>
>>    When the TOKEN is exactly the reserved word esac, the token identifier
>>    for esac shall result. Otherwise, the token WORD shall be returned.
>>
>> Here, the TOKEN is exactly the reserved word esac, and you agree that this
>> rule is applied. This therefore produces the token identifier for esac.
>> There is nothing else that turns it into WORD, which is needed to parse it
>> as a pattern.
> 
> I see your point.  The wording of rule 4 itself does not yield WORD in
> this case; it's only when read in combination with the introductory text
> from 2.10.1 that it becomes apparent that this is the intention.

So "acceptable at that point in the grammar" is indeed carrying a heavy
load here. You might want to add the qualifying language you suggested.


> Incidentally, bash 3 on macOS gets the '|' case wrong, e.g.:
> 
> case esac in foo|esac) echo match;; esac
> 
> whereas bash5 accept that.  So it would appear that Chet fixed the
> preceded-by-'|' case at some point but not the preceded-by-'(' case.

It's just another special case in the grammar that lexical analysis
has to handle.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
        ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

              • ... Joerg Schilling via austin-group-l at The Open Group
              • ... Harald van Dijk via austin-group-l at The Open Group
            • ... Robert Elz via austin-group-l at The Open Group
              • ... Joerg Schilling via austin-group-l at The Open Group
            • ... Chet Ramey via austin-group-l at The Open Group
            • ... Robert Elz via austin-group-l at The Open Group
              • ... Chet Ramey via austin-group-l at The Open Group
            • ... Joerg Schilling via austin-group-l at The Open Group
            • ... Robert Elz via austin-group-l at The Open Group
          • ... Robert Elz via austin-group-l at The Open Group
  • Re: [1003.1(... shwaresyst via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group

Reply via email to