Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: Separate cover grammar text into a subsection with autolink targets #3223

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -575,17 +575,21 @@ <h1>The Syntactic Grammar</h1>
<emu-note>Parse Nodes are specification artefacts, and implementations are not required to use an analogous data structure.</emu-note>
<p>Productions of the syntactic grammar are distinguished by having just one colon “<b>:</b>” as punctuation.</p>
<p>The syntactic grammar as presented in clauses <emu-xref href="#sec-ecmascript-language-expressions"></emu-xref> through <emu-xref href="#sec-ecmascript-language-scripts-and-modules"></emu-xref> is not a complete account of which token sequences are accepted as a correct ECMAScript |Script| or |Module|. Certain additional token sequences are also accepted, namely, those that would be described by the grammar if only semicolons were added to the sequence in certain places (such as before line terminator characters). Furthermore, certain token sequences that are described by the grammar are not considered acceptable if a line terminator character appears in certain “awkward” places.</p>
<p>In certain cases, in order to avoid ambiguities, the syntactic grammar uses generalized productions that permit token sequences that do not form a valid ECMAScript |Script| or |Module|. For example, this technique is used for object literals and object destructuring patterns. In such cases a more restrictive <em>supplemental grammar</em> is provided that further restricts the acceptable token sequences. Typically, an early error rule will then state that, in certain contexts, "_P_ <dfn id="must-cover">must cover</dfn> an _N_", where _P_ is a Parse Node (an instance of the generalized production) and _N_ is a nonterminal from the supplemental grammar. This means:</p>
<ol>
<li>The sequence of tokens originally matched by _P_ is parsed again using _N_ as the goal symbol. If _N_ takes grammatical parameters, then they are set to the same values used when _P_ was originally parsed.</li>
<li>If the sequence of tokens can be parsed as a single instance of _N_, with no tokens left over, then:
<ol>
<li>We refer to that instance of _N_ (a Parse Node, unique for a given _P_) as "the _N_ that is <dfn>covered</dfn> by _P_".</li>
<li>All Early Error rules for _N_ and its derived productions also apply to the _N_ that is covered by _P_.</li>
</ol>
</li>
<li>Otherwise (if the parse fails), it is an early Syntax Error.</li>
</ol>

<emu-clause id="sec-cover-grammars">
<h1>Cover Grammars</h1>
<p>In certain cases, in order to avoid ambiguities, the syntactic grammar uses generalized <dfn>cover grammar</dfn> productions that permit token sequences that do not form a valid ECMAScript |Script| or |Module|. For example, this technique is used for object literals and object destructuring patterns. In such cases, instances of the cover grammar production are <dfn>refined</dfn> using a <dfn>supplemental grammar</dfn> that further restricts the acceptable token sequences. Typically, an early error rule will then state that, in certain contexts, "_P_ <dfn id="must-cover">must cover</dfn> an _N_", where _P_ is a Parse Node (an instance of the generalized production) and _N_ is a nonterminal from the supplemental grammar. This means:</p>
<ol>
<li>The sequence of tokens originally matched by _P_ is parsed again using _N_ as the goal symbol. If _N_ takes grammatical parameters, then they are set to the same values used when _P_ was originally parsed.</li>
<li>If the sequence of tokens can be parsed as a single instance of _N_, with no tokens left over, then:
<ol>
<li>We refer to that instance of _N_ (a Parse Node, unique for a given _P_) as "the _N_ that is <dfn>covered</dfn> by _P_".</li>
<li>All Early Error rules for _N_ and its derived productions also apply to the _N_ that is covered by _P_.</li>
</ol>
</li>
<li>Otherwise (if the parse fails), it is an early Syntax Error.</li>
</ol>
</emu-clause>
</emu-clause>

<emu-clause id="sec-grammar-notation" namespace="grammar-notation">
Expand Down Expand Up @@ -18400,7 +18404,7 @@ <h2>Syntax</h2>
<p>|MethodDefinition| is defined in <emu-xref href="#sec-method-definitions"></emu-xref>.</p>
</emu-note>
<emu-note>
<p>In certain contexts, |ObjectLiteral| is used as a cover grammar for a more restricted secondary grammar. The |CoverInitializedName| production is necessary to fully cover these secondary grammars. However, use of this production results in an early Syntax Error in normal contexts where an actual |ObjectLiteral| is expected.</p>
<p>In certain contexts, |ObjectLiteral| is used as a cover grammar for a more restricted supplemental grammar. The |CoverInitializedName| production is necessary to fully cover these supplemental grammars. However, use of this production results in an early Syntax Error in normal contexts where an actual |ObjectLiteral| is expected.</p>
</emu-note>

<emu-clause id="sec-object-initializer-static-semantics-early-errors" oldids="sec-__proto__-property-names-in-object-initializers">
Expand Down
Loading