On 19/02/2021 15:33, Geoff Clare via austin-group-l at The Open Group wrote:
Harald van Dijk wrote, on 19 Feb 2021:
On 19/02/2021 15:04, Geoff Clare via austin-group-l at The Open Group wrote:
Harald van Dijk wrote, on 19 Feb 2021:
On 19/02/2021 09:59, Geoff Clare via austin-group-l at The Open Group wrote:
How about changing that problem sentence in 2.10.1 to:
When a TOKEN is seen where one of those annotated productions could
be used to reduce the symbol, the applicable rule shall be applied to
convert the token identifier type of the TOKEN to:
* The token identifier of the recognized reserved word, for rule 1.
* A token identifier acceptable at that point in the grammar, for
all other rules.
This change would allow
case esac in
(esac) echo match
esac
which is currently invalid and rejected by bash, and when invoked in POSIX
mode, also rejected by yash and zsh. Should that become valid, or should
that remain an error?
It's currently valid and the above change wouldn't affect that (since
the change only affects when rule 1 can be applied, and this example
does not involve rule 1 except for the initial "case").
It's currently invalid. The grammar reads:
case_item : pattern ')' linebreak DSEMI linebreak
| pattern ')' compound_list DSEMI linebreak
| '(' pattern ')' linebreak DSEMI linebreak
| '(' pattern ')' compound_list DSEMI linebreak
;
pattern : WORD /* Apply rule 4 */
| pattern '|' WORD /* Do not apply rule 4 */
Observe that rule 4 is applied for the first word in a pattern even if that
pattern follows an opening parenthesis. Because of that, in my example, the
esac in parentheses is interpreted as the esac keyword token, not a regular
WORD token that makes for a valid pattern.
Yes, rule 4 is applied there, but your mistake is in assuming that
the *result* of rule 4 is that the token is converted to an Esac.
Looking more closely, I do see now that you are correct that the
"acceptable at that point in the grammar" requirement already appears in
the current standard. I missed that there, you indeed did not change
that. This is an issue separate from your wording changes.
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.
Cheers,
Harald van Dijk