Skip to content

Commit

Permalink
Normative: plug some holes in the coverage of syntax-directed operati…
Browse files Browse the repository at this point in the history
…ons (tc39#1301)

 - CoveredCallExpression: change production
      When an SDO is applied to a Parse Node, the appropriate definition of the SDO
      is the one for the production of which the Parse Node is an instance
      (ignoring the complication of chain productions).

      The only invocation of CoveredCallExpression
      is on a |CoverCallExpressionAndAsyncArrowHead|,
      so we expect CoveredCallExpression to be defined on
          CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments
      not
          CallExpression : CoverCallExpressionAndAsyncArrowHead
 - BoundNames: add def for ObjectBindingPattern
      BoundNames was missing a definition for
          ObjectBindingPattern : `{` BindingPropertyList `,` BindingRestProperty `}`
 - ContainsExpression: add a few defs
      ContainsExpression was missing definitions for:
          ObjectBindingPattern : `{` BindingRestProperty `}`
          ObjectBindingPattern : `{` BindingPropertyList `,` BindingRestProperty `}`
          ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
 - ExpectedArgumentCount: add a few defs
      ExpectedArgumentCount was missing definitions for:
          FormalParameters : FunctionRestParameter
          FormalParameterList : FormalParameter
          ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
 - CoveredFormalsList: add a def
      CoveredFormalsList was missing a definition for
          CoverParenthesizedExpressionAndArrowParameterList : `(` Expression `,` `)`
 - IteratorBindingInitialization: add a def
      IteratorBindingInitialization was missing a definition for:
          ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
 - HasCallInTailPosition: add a few defs
      HasCallInTailPosition was missing definitions for the 3
          IterationStatement : `for` `await` `(` productions.
 - define 3 SDOs on empty FunctionStatementList
      specifically:
       - ContainsDuplicateLabels
       - ContainsUndefinedBreakTarget
       - ContainsUndefinedContinueTarget
 - MV: add def for Hex4Digits
      PR tc39#984 added a reference to "the MV of |Hex4Digits|"
      (in the definition of CharacterValue)
      but didn't add a definition for it.

      Extract one from the definition for "the SV of |Hex4Digits|".
 - eliminate unsupported "SV of |SourceCharacter|"
      We have rules that say the TRV of something is:
       - the SV of the |SourceCharacter| that is that single code point; or
       - the SV of the |SourceCharacter| that is that |HexDigit|.

      but there's no definition for the SV of |SourceCharacter|.

      We could add such a definition, except that these usages are already odd,
      in that they introduce a |SourceCharacter| nonterminal when there isn't one
      in the parse tree. So instead, fix that oddity by eliminating the references
      to SV and |SourceCharacter|.

      And since I'm in the neighborhood,
         The TRV of a |HexDigit| ...
      is weird. No other SDO rule is written that way. Change it to:
         The TRV of <emu-grammar>HexDigit :: ....</emu-grammar> ...
  • Loading branch information
jmdyck authored and ljharb committed Feb 19, 2020
1 parent 386b9b5 commit efa4e7e
Showing 1 changed file with 82 additions and 7 deletions.
89 changes: 82 additions & 7 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -11395,6 +11395,9 @@ <h1>Static Semantics: MV</h1>
<li>
The MV of <emu-grammar>HexDigits :: HexDigits HexDigit</emu-grammar> is (the MV of |HexDigits| &times; 16<sub>ℝ</sub>) plus the MV of |HexDigit|.
</li>
<li>
The MV of <emu-grammar>Hex4Digits :: HexDigit HexDigit HexDigit HexDigit</emu-grammar> is (0x1000<sub>ℝ</sub> times the MV of the first |HexDigit|) plus (0x100<sub>ℝ</sub> times the MV of the second |HexDigit|) plus (0x10<sub>ℝ</sub> times the MV of the third |HexDigit|) plus the MV of the fourth |HexDigit|.
</li>
</ul>
</emu-clause>

Expand Down Expand Up @@ -11760,7 +11763,7 @@ <h1>Static Semantics: SV</h1>
The SV of <emu-grammar>UnicodeEscapeSequence :: `u` Hex4Digits</emu-grammar> is the SV of |Hex4Digits|.
</li>
<li>
The SV of <emu-grammar>Hex4Digits :: HexDigit HexDigit HexDigit HexDigit</emu-grammar> is the code unit whose value is (0x1000<sub>ℝ</sub> times the MV of the first |HexDigit|) plus (0x100<sub>ℝ</sub> times the MV of the second |HexDigit|) plus (0x10<sub>ℝ</sub> times the MV of the third |HexDigit|) plus the MV of the fourth |HexDigit|.
The SV of <emu-grammar>Hex4Digits :: HexDigit HexDigit HexDigit HexDigit</emu-grammar> is the code unit whose value is the MV of |Hex4Digits|.
</li>
<li>
The SV of <emu-grammar>UnicodeEscapeSequence :: `u{` CodePoint `}`</emu-grammar> is the UTF16Encoding of the MV of |CodePoint|.
Expand Down Expand Up @@ -12043,7 +12046,7 @@ <h1>Static Semantics: TV and TRV</h1>
The TRV of <emu-grammar>NotEscapeSequence :: `u` `{` CodePoint [lookahead &lt;! HexDigit] [lookahead != `}`]</emu-grammar> is the sequence consisting of the code unit 0x0075 (LATIN SMALL LETTER U) followed by the code unit 0x007B (LEFT CURLY BRACKET) followed by the code units of the TRV of |CodePoint|.
</li>
<li>
The TRV of <emu-grammar>DecimalDigit :: one of `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`</emu-grammar> is the SV of the |SourceCharacter| that is that single code point.
The TRV of <emu-grammar>DecimalDigit :: one of `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`</emu-grammar> is the UTF16Encoding of the single code point matched by this production.
</li>
<li>
The TRV of <emu-grammar>CharacterEscapeSequence :: SingleEscapeCharacter</emu-grammar> is the TRV of |SingleEscapeCharacter|.
Expand All @@ -12052,7 +12055,7 @@ <h1>Static Semantics: TV and TRV</h1>
The TRV of <emu-grammar>CharacterEscapeSequence :: NonEscapeCharacter</emu-grammar> is the SV of |NonEscapeCharacter|.
</li>
<li>
The TRV of <emu-grammar>SingleEscapeCharacter :: one of `'` `"` `\` `b` `f` `n` `r` `t` `v`</emu-grammar> is the SV of the |SourceCharacter| that is that single code point.
The TRV of <emu-grammar>SingleEscapeCharacter :: one of `'` `"` `\` `b` `f` `n` `r` `t` `v`</emu-grammar> is the UTF16Encoding of the single code point matched by this production.
</li>
<li>
The TRV of <emu-grammar>HexEscapeSequence :: `x` HexDigit HexDigit</emu-grammar> is the sequence consisting of the code unit 0x0078 (LATIN SMALL LETTER X) followed by TRV of the first |HexDigit| followed by the TRV of the second |HexDigit|.
Expand All @@ -12073,7 +12076,7 @@ <h1>Static Semantics: TV and TRV</h1>
The TRV of <emu-grammar>HexDigits :: HexDigits HexDigit</emu-grammar> is the sequence consisting of TRV of |HexDigits| followed by TRV of |HexDigit|.
</li>
<li>
The TRV of a |HexDigit| is the SV of the |SourceCharacter| that is that |HexDigit|.
The TRV of <emu-grammar>HexDigit :: one of `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` `a` `b` `c` `d` `e` `f` `A` `B` `C` `D` `E` `F`</emu-grammar> is the UTF16Encoding of the single code point matched by this production.
</li>
<li>
The TRV of <emu-grammar>LineContinuation :: `\` LineTerminatorSequence</emu-grammar> is the sequence consisting of the code unit 0x005C (REVERSE SOLIDUS) followed by the code units of TRV of |LineTerminatorSequence|.
Expand Down Expand Up @@ -13581,7 +13584,7 @@ <h1>Static Semantics: Early Errors</h1>
<emu-clause id="sec-left-hand-side-expressions-static-semantics-coveredcallexpression">
<h1>Static Semantics: CoveredCallExpression</h1>
<emu-grammar>
CallExpression : CoverCallExpressionAndAsyncArrowHead
CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments
</emu-grammar>
<emu-alg>
1. Return the |CallMemberExpression| that is covered by |CoverCallExpressionAndAsyncArrowHead|.
Expand Down Expand Up @@ -16707,6 +16710,12 @@ <h1>Static Semantics: BoundNames</h1>
<emu-alg>
1. Return a new empty List.
</emu-alg>
<emu-grammar>ObjectBindingPattern : `{` BindingPropertyList `,` BindingRestProperty `}`</emu-grammar>
<emu-alg>
1. Let _names_ be BoundNames of |BindingPropertyList|.
1. Append to _names_ the elements of BoundNames of |BindingRestProperty|.
1. Return _names_.
</emu-alg>
<emu-grammar>ArrayBindingPattern : `[` Elision? `]`</emu-grammar>
<emu-alg>
1. Return a new empty List.
Expand Down Expand Up @@ -16758,10 +16767,18 @@ <h1>Static Semantics: BoundNames</h1>
<emu-clause id="sec-destructuring-binding-patterns-static-semantics-containsexpression">
<h1>Static Semantics: ContainsExpression</h1>
<emu-see-also-para op="ContainsExpression"></emu-see-also-para>
<emu-grammar>ObjectBindingPattern : `{` `}`</emu-grammar>
<emu-grammar>
ObjectBindingPattern :
`{` `}`
`{` BindingRestProperty `}`
</emu-grammar>
<emu-alg>
1. Return *false*.
</emu-alg>
<emu-grammar>ObjectBindingPattern : `{` BindingPropertyList `,` BindingRestProperty `}`</emu-grammar>
<emu-alg>
1. Return ContainsExpression of |BindingPropertyList|.
</emu-alg>
<emu-grammar>ArrayBindingPattern : `[` Elision? `]`</emu-grammar>
<emu-alg>
1. Return *false*.
Expand Down Expand Up @@ -19595,6 +19612,16 @@ <h1>Static Semantics: Contains</h1>
</emu-note>
</emu-clause>

<emu-clause id="sec-function-definitions-static-semantics-containsduplicatelabels">
<h1>Static Semantics: ContainsDuplicateLabels</h1>
<p>With parameter _labelSet_.</p>
<emu-see-also-para op="ContainsDuplicateLabels"></emu-see-also-para>
<emu-grammar>FunctionStatementList : [empty]</emu-grammar>
<emu-alg>
1. Return *false*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-function-definitions-static-semantics-containsexpression">
<h1>Static Semantics: ContainsExpression</h1>
<emu-see-also-para op="ContainsExpression"></emu-see-also-para>
Expand All @@ -19614,6 +19641,26 @@ <h1>Static Semantics: ContainsExpression</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-function-definitions-static-semantics-containsundefinedbreaktarget">
<h1>Static Semantics: ContainsUndefinedBreakTarget</h1>
<p>With parameter _labelSet_.</p>
<emu-see-also-para op="ContainsUndefinedBreakTarget"></emu-see-also-para>
<emu-grammar>FunctionStatementList : [empty]</emu-grammar>
<emu-alg>
1. Return *false*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-function-definitions-static-semantics-containsundefinedcontinuetarget">
<h1>Static Semantics: ContainsUndefinedContinueTarget</h1>
<p>With parameters _iterationSet_ and _labelSet_.</p>
<emu-see-also-para op="ContainsUndefinedContinueTarget"></emu-see-also-para>
<emu-grammar>FunctionStatementList : [empty]</emu-grammar>
<emu-alg>
1. Return *false*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-function-definitions-static-semantics-containsusestrict">
<h1>Static Semantics: ContainsUseStrict</h1>
<emu-see-also-para op="ContainsUseStrict"></emu-see-also-para>
Expand All @@ -19626,7 +19673,11 @@ <h1>Static Semantics: ContainsUseStrict</h1>
<emu-clause id="sec-function-definitions-static-semantics-expectedargumentcount">
<h1>Static Semantics: ExpectedArgumentCount</h1>
<emu-see-also-para op="ExpectedArgumentCount"></emu-see-also-para>
<emu-grammar>FormalParameters : [empty]</emu-grammar>
<emu-grammar>
FormalParameters :
[empty]
FunctionRestParameter
</emu-grammar>
<emu-alg>
1. Return 0.
</emu-alg>
Expand All @@ -19637,6 +19688,11 @@ <h1>Static Semantics: ExpectedArgumentCount</h1>
<emu-note>
<p>The ExpectedArgumentCount of a |FormalParameterList| is the number of |FormalParameters| to the left of either the rest parameter or the first |FormalParameter| with an Initializer. A |FormalParameter| without an initializer is allowed after the first parameter with an initializer but such parameters are considered to be optional with *undefined* as their default value.</p>
</emu-note>
<emu-grammar>FormalParameterList : FormalParameter</emu-grammar>
<emu-alg>
1. If HasInitializer of |FormalParameter| is *true*, return 0.
1. Return 1.
</emu-alg>
<emu-grammar>FormalParameterList : FormalParameterList `,` FormalParameter</emu-grammar>
<emu-alg>
1. Let _count_ be ExpectedArgumentCount of |FormalParameterList|.
Expand Down Expand Up @@ -20000,6 +20056,11 @@ <h1>Static Semantics: ContainsExpression</h1>
<emu-alg>
1. Return *false*.
</emu-alg>
<emu-grammar>ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList</emu-grammar>
<emu-alg>
1. Let _formals_ be CoveredFormalsList of |CoverParenthesizedExpressionAndArrowParameterList|.
1. Return ContainsExpression of _formals_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-arrow-function-definitions-static-semantics-containsusestrict">
Expand All @@ -20018,6 +20079,11 @@ <h1>Static Semantics: ExpectedArgumentCount</h1>
<emu-alg>
1. Return 1.
</emu-alg>
<emu-grammar>ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList</emu-grammar>
<emu-alg>
1. Let _formals_ be CoveredFormalsList of |CoverParenthesizedExpressionAndArrowParameterList|.
1. Return ExpectedArgumentCount of _formals_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-arrow-function-definitions-static-semantics-hasname">
Expand Down Expand Up @@ -20052,6 +20118,7 @@ <h1>Static Semantics: CoveredFormalsList</h1>
<emu-grammar>
CoverParenthesizedExpressionAndArrowParameterList :
`(` Expression `)`
`(` Expression `,` `)`
`(` `)`
`(` `...` BindingIdentifier `)`
`(` `...` BindingPattern `)`
Expand Down Expand Up @@ -20120,6 +20187,11 @@ <h1>Runtime Semantics: IteratorBindingInitialization</h1>
1. If _iteratorRecord_.[[Done]] is *true*, let _v_ be *undefined*.
1. Return the result of performing BindingInitialization for |BindingIdentifier| using _v_ and _environment_ as the arguments.
</emu-alg>
<emu-grammar>ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList</emu-grammar>
<emu-alg>
1. Let _formals_ be CoveredFormalsList of |CoverParenthesizedExpressionAndArrowParameterList|.
1. Return IteratorBindingInitialization of _formals_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-arrow-function-definitions-runtime-semantics-evaluatebody">
Expand Down Expand Up @@ -21984,6 +22056,9 @@ <h1>Statement Rules</h1>
`for` `(` LeftHandSideExpression `in` Expression `)` Statement
`for` `(` `var` ForBinding `in` Expression `)` Statement
`for` `(` ForDeclaration `in` Expression `)` Statement
`for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement
`for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement
`for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement

WithStatement : `with` `(` Expression `)` Statement
</emu-grammar>
Expand Down

0 comments on commit efa4e7e

Please sign in to comment.