15:55
<Jack Works>
hello, is there any syntax pro? I'm stuck on designing cover grammar
15:58
<Jack Works>

Grammar:

MatchStatement: `match` [nLTh] `(` Expression `) [nLTh] `{ MatchStatementClauses `;` `}`

This is ambiguous with ExpressionStatement (cannot decide production for match (expr) until see { or any other token), therefore I need a CoverExpressionStatementAndMatchStatement grammar

16:00
<Jack Works>

Now I have this cover grammar:

CoverExpressionStatementAndMatchStatement :
    `match` [no LineTerminator here] Arguments

This can cover the match head match (a, b, c) (where , is comma operator) and a call expression match (a, b, c) (where , is parameter separator). But I don't know how to use it in ExpressionStatement

16:01
<Jack Works>
MatchStatement :
    CoverExpressionStatementAndMatchStatement [no LineTerminator here] `{ ` MatchStatementClauses `;` `}`

// Refined to
MatchHead :
    `match` [no LineTerminator here] `(` Expression `)` [no LineTerminator here] `{ ` MatchStatementClauses `;` `}`

This looks good to me for now

16:03
<Jack Works>
ExpressionStatement :
        CoverExpressionStatementAndMatchStatement
        (current definition)

This one does not. It does not cover everything that can follow a CallExpression, like match (expr) + 1 or match(expr).prop.

16:05
<Jack Works>
It looks like I need to add all expressions to this cover grammar (e.g. it can follow a ++ or .x or [prop] or (...args)) which is unrealistic.
20:15
<Richard Gibson>

Jack Works: for that approach, I think you'll want to use and rename (and probably generalize) |CoverCallExpressionAndAsyncArrowHead|, e.g.

<emu-grammar type="definition">
  MatchStatement : 
    CoverCallExpressionAndAsyncArrowHeadAndMatchHead [no LineTerminator here] `{` MatchStatementClauses `;` `}`
</emu-grammar>
<h2>Supplemental Syntax</h2>
<p>
  When processing an instance of the production<br>
  <emu-grammar>MatchStatement : CoverCallExpressionAndAsyncArrowHeadAndMatchHead [no LineTerminator here] `{` MatchStatementClauses `;` `}`</emu-grammar><br>
  the interpretation of |CoverCallExpressionAndAsyncArrowHeadAndMatchHead| is refined using the following grammar:
</p>
<emu-grammar type="definition">
  MatchHead :
    `match` [no LineTerminator here] `(` Expression `)
</emu-grammar>

(following the pattern in Async Arrow Function Definitions)