On 22/02/2021 09:51, Geoff Clare via austin-group-l at The Open Group wrote:
I think your suggestion works, but having a separate production to
add the ')' seems unnecessary. I'd also rename "pattern" since it is
really just WORD that constitutes a pattern to be matched. So how
about this:
case_item_ns : pattern_list ')' linebreak
| pattern_list ')' compound_list
;
case_item : pattern_list ')' linebreak DSEMI linebreak
| pattern_list ')' compound_list DSEMI linebreak
;
pattern_list : WORD /* Apply rule 4 */
| '(' WORD /* Do not apply rule 4 */
| pattern_list '|' WORD /* Do not apply rule 4 */
;
Sure, that looks just fine to me. I tried avoiding having only one of
'(' or ')' part of the pattern (now pattern_list) rule for readability
reasons, but if you prefer a shorter grammar instead, that makes sense
to me too.
Cheers,
Harald van Dijk