From e51a96ff55a68d9db9edc264416b9289d7e15a68 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Sat, 18 Nov 2023 14:03:10 -0500 Subject: [PATCH 1/2] Editorial: Add s for cover grammar linking --- spec.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.html b/spec.html index 504dbfdee8..5f427e7807 100644 --- a/spec.html +++ b/spec.html @@ -575,7 +575,7 @@

The Syntactic Grammar

Parse Nodes are specification artefacts, and implementations are not required to use an analogous data structure.

Productions of the syntactic grammar are distinguished by having just one colon “:” as punctuation.

The syntactic grammar as presented in clauses through 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.

-

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 supplemental grammar is provided that further restricts the acceptable token sequences. Typically, an early error rule will then state that, in certain contexts, "_P_ must cover 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:

+

In certain cases, in order to avoid ambiguities, the syntactic grammar uses generalized cover grammar 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 refined using a supplemental grammar that further restricts the acceptable token sequences. Typically, an early error rule will then state that, in certain contexts, "_P_ must cover 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:

  1. 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.
  2. If the sequence of tokens can be parsed as a single instance of _N_, with no tokens left over, then: @@ -18400,7 +18400,7 @@

    Syntax

    |MethodDefinition| is defined in .

    -

    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.

    +

    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.

    From b671b1b21d2ae60c25a007de025a4483b82beff6 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Sat, 18 Nov 2023 14:11:40 -0500 Subject: [PATCH 2/2] Editorial: Separate cover grammar text into a subsection --- spec.html | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/spec.html b/spec.html index 5f427e7807..5ae503c3fd 100644 --- a/spec.html +++ b/spec.html @@ -575,17 +575,21 @@

    The Syntactic Grammar

    Parse Nodes are specification artefacts, and implementations are not required to use an analogous data structure.

    Productions of the syntactic grammar are distinguished by having just one colon “:” as punctuation.

    The syntactic grammar as presented in clauses through 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.

    -

    In certain cases, in order to avoid ambiguities, the syntactic grammar uses generalized cover grammar 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 refined using a supplemental grammar that further restricts the acceptable token sequences. Typically, an early error rule will then state that, in certain contexts, "_P_ must cover 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:

    -
      -
    1. 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.
    2. -
    3. If the sequence of tokens can be parsed as a single instance of _N_, with no tokens left over, then: -
        -
      1. We refer to that instance of _N_ (a Parse Node, unique for a given _P_) as "the _N_ that is covered by _P_".
      2. -
      3. All Early Error rules for _N_ and its derived productions also apply to the _N_ that is covered by _P_.
      4. -
      -
    4. -
    5. Otherwise (if the parse fails), it is an early Syntax Error.
    6. -
    + + +

    Cover Grammars

    +

    In certain cases, in order to avoid ambiguities, the syntactic grammar uses generalized cover grammar 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 refined using a supplemental grammar that further restricts the acceptable token sequences. Typically, an early error rule will then state that, in certain contexts, "_P_ must cover 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:

    +
      +
    1. 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.
    2. +
    3. If the sequence of tokens can be parsed as a single instance of _N_, with no tokens left over, then: +
        +
      1. We refer to that instance of _N_ (a Parse Node, unique for a given _P_) as "the _N_ that is covered by _P_".
      2. +
      3. All Early Error rules for _N_ and its derived productions also apply to the _N_ that is covered by _P_.
      4. +
      +
    4. +
    5. Otherwise (if the parse fails), it is an early Syntax Error.
    6. +
    +