From 3b9ee614d006619b6ce0685227f0bbd28248a475 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 19 Jan 2024 18:50:14 -0500 Subject: [PATCH] Fix line endings in spec.emu --- spec.emu | 784 +++++++++++++++++++++++++++---------------------------- 1 file changed, 392 insertions(+), 392 deletions(-) diff --git a/spec.emu b/spec.emu index 35f5ab1..1ae2193 100644 --- a/spec.emu +++ b/spec.emu @@ -1,393 +1,393 @@ - - - - - -
-title: ECMAScript 'throw' expressions
-status: proposal
-stage: 2
-contributors: Ron Buckton, Ecma International
-
- - - - -

Introduction

-

This proposal defines new syntax to throw exceptions from within an expression context.

-

See the proposal repository for background material and discussion.

-
- - -

Syntax-Directed Operations

-

In addition to those defined in this section, specialized syntax-directed operations are defined throughout this specification.

- -

Function Name Inference

- - -

Static Semantics: IsFunctionDefinition ( ): a Boolean

-
-
- PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList - - 1. Let _expr_ be the |ParenthesizedExpression| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. - 1. Return IsFunctionDefinition of _expr_. - - - PrimaryExpression : - `this` - IdentifierReference - Literal - ArrayLiteral - ObjectLiteral - RegularExpressionLiteral - TemplateLiteral - - MemberExpression : - MemberExpression `[` Expression `]` - MemberExpression `.` IdentifierName - MemberExpression TemplateLiteral - SuperProperty - MetaProperty - `new` MemberExpression Arguments - MemberExpression `.` PrivateIdentifier - - NewExpression : - `new` NewExpression - - LeftHandSideExpression : - CallExpression - OptionalExpression - - UpdateExpression : - LeftHandSideExpression `++` - LeftHandSideExpression `--` - `++` UnaryExpression - `--` UnaryExpression - - UnaryExpression : - `delete` UnaryExpression - `void` UnaryExpression - `typeof` UnaryExpression - `throw` UnaryExpression - `+` UnaryExpression - `-` UnaryExpression - `~` UnaryExpression - `!` UnaryExpression - AwaitExpression - - ExponentiationExpression : - UpdateExpression `**` ExponentiationExpression - - MultiplicativeExpression : - MultiplicativeExpression MultiplicativeOperator ExponentiationExpression - - AdditiveExpression : - AdditiveExpression `+` MultiplicativeExpression - AdditiveExpression `-` MultiplicativeExpression - - ShiftExpression : - ShiftExpression `<<` AdditiveExpression - ShiftExpression `>>` AdditiveExpression - ShiftExpression `>>>` AdditiveExpression - - RelationalExpression : - RelationalExpression `<` ShiftExpression - RelationalExpression `>` ShiftExpression - RelationalExpression `<=` ShiftExpression - RelationalExpression `>=` ShiftExpression - RelationalExpression `instanceof` ShiftExpression - RelationalExpression `in` ShiftExpression - PrivateIdentifier `in` ShiftExpression - - EqualityExpression : - EqualityExpression `==` RelationalExpression - EqualityExpression `!=` RelationalExpression - EqualityExpression `===` RelationalExpression - EqualityExpression `!==` RelationalExpression - - BitwiseANDExpression : - BitwiseANDExpression `&` EqualityExpression - - BitwiseXORExpression : - BitwiseXORExpression `^` BitwiseANDExpression - - BitwiseORExpression : - BitwiseORExpression `|` BitwiseXORExpression - - LogicalANDExpression : - LogicalANDExpression `&&` BitwiseORExpression - - LogicalORExpression : - LogicalORExpression `||` LogicalANDExpression - - CoalesceExpression : - CoalesceExpressionHead `??` BitwiseORExpression - - ConditionalExpression : - ShortCircuitExpression `?` AssignmentExpression `:` AssignmentExpression - - AssignmentExpression : - YieldExpression - LeftHandSideExpression `=` AssignmentExpression - LeftHandSideExpression AssignmentOperator AssignmentExpression - LeftHandSideExpression `&&=` AssignmentExpression - LeftHandSideExpression `||=` AssignmentExpression - LeftHandSideExpression `??=` AssignmentExpression - - Expression : - Expression `,` AssignmentExpression - - - 1. Return *false*. - - - AssignmentExpression : - ArrowFunction - AsyncArrowFunction - - FunctionExpression : - `function` BindingIdentifier? `(` FormalParameters `)` `{` FunctionBody `}` - - GeneratorExpression : - `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` GeneratorBody `}` - - AsyncGeneratorExpression : - `async` `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}` - - AsyncFunctionExpression : - `async` `function` BindingIdentifier? `(` FormalParameters `)` `{` AsyncFunctionBody `}` - - ClassExpression : - `class` BindingIdentifier? ClassTail - - - 1. Return *true*. - -
-
- - -

Miscellaneous

-

These operations are used in multiple places throughout the specification.

- -

Static Semantics: AssignmentTargetType ( ): ~simple~ or ~invalid~

-
-
- IdentifierReference : Identifier - - 1. If this |IdentifierReference| is contained in strict mode code and StringValue of |Identifier| is either *"eval"* or *"arguments"*, return ~invalid~. - 1. Return ~simple~. - - - IdentifierReference : - `yield` - `await` - - CallExpression : - CallExpression `[` Expression `]` - CallExpression `.` IdentifierName - CallExpression `.` PrivateIdentifier - - MemberExpression : - MemberExpression `[` Expression `]` - MemberExpression `.` IdentifierName - SuperProperty - MemberExpression `.` PrivateIdentifier - - - 1. Return ~simple~. - - - PrimaryExpression : - CoverParenthesizedExpressionAndArrowParameterList - - - 1. Let _expr_ be the |ParenthesizedExpression| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. - 1. Return AssignmentTargetType of _expr_. - - - PrimaryExpression : - `this` - Literal - ArrayLiteral - ObjectLiteral - FunctionExpression - ClassExpression - GeneratorExpression - AsyncFunctionExpression - AsyncGeneratorExpression - RegularExpressionLiteral - TemplateLiteral - - CallExpression : - CoverCallExpressionAndAsyncArrowHead - SuperCall - ImportCall - CallExpression Arguments - CallExpression TemplateLiteral - - NewExpression : - `new` NewExpression - - MemberExpression : - MemberExpression TemplateLiteral - `new` MemberExpression Arguments - - NewTarget : - `new` `.` `target` - - ImportMeta : - `import` `.` `meta` - - LeftHandSideExpression : - OptionalExpression - - UpdateExpression : - LeftHandSideExpression `++` - LeftHandSideExpression `--` - `++` UnaryExpression - `--` UnaryExpression - - UnaryExpression : - `delete` UnaryExpression - `void` UnaryExpression - `typeof` UnaryExpression - `throw` UnaryExpression - `+` UnaryExpression - `-` UnaryExpression - `~` UnaryExpression - `!` UnaryExpression - AwaitExpression - - ExponentiationExpression : - UpdateExpression `**` ExponentiationExpression - - MultiplicativeExpression : - MultiplicativeExpression MultiplicativeOperator ExponentiationExpression - - AdditiveExpression : - AdditiveExpression `+` MultiplicativeExpression - AdditiveExpression `-` MultiplicativeExpression - - ShiftExpression : - ShiftExpression `<<` AdditiveExpression - ShiftExpression `>>` AdditiveExpression - ShiftExpression `>>>` AdditiveExpression - - RelationalExpression : - RelationalExpression `<` ShiftExpression - RelationalExpression `>` ShiftExpression - RelationalExpression `<=` ShiftExpression - RelationalExpression `>=` ShiftExpression - RelationalExpression `instanceof` ShiftExpression - RelationalExpression `in` ShiftExpression - PrivateIdentifier `in` ShiftExpression - - EqualityExpression : - EqualityExpression `==` RelationalExpression - EqualityExpression `!=` RelationalExpression - EqualityExpression `===` RelationalExpression - EqualityExpression `!==` RelationalExpression - - BitwiseANDExpression : - BitwiseANDExpression `&` EqualityExpression - - BitwiseXORExpression : - BitwiseXORExpression `^` BitwiseANDExpression - - BitwiseORExpression : - BitwiseORExpression `|` BitwiseXORExpression - - LogicalANDExpression : - LogicalANDExpression `&&` BitwiseORExpression - - LogicalORExpression : - LogicalORExpression `||` LogicalANDExpression - - CoalesceExpression : - CoalesceExpressionHead `??` BitwiseORExpression - - ConditionalExpression : - ShortCircuitExpression `?` AssignmentExpression `:` AssignmentExpression - - AssignmentExpression : - YieldExpression - ArrowFunction - AsyncArrowFunction - LeftHandSideExpression `=` AssignmentExpression - LeftHandSideExpression AssignmentOperator AssignmentExpression - LeftHandSideExpression `&&=` AssignmentExpression - LeftHandSideExpression `||=` AssignmentExpression - LeftHandSideExpression `??=` AssignmentExpression - - Expression : - Expression `,` AssignmentExpression - - - 1. Return ~invalid~. - -
-
-
- - -

ECMAScript Language: Expressions

- - -

Unary Operators

-

Syntax

- - UnaryExpression[Yield, Await] : - UpdateExpression[?Yield, ?Await] - `delete` UnaryExpression[?Yield, ?Await] - `void` UnaryExpression[?Yield, ?Await] - `typeof` UnaryExpression[?Yield, ?Await] - `throw` UnaryExpression[?Yield, ?Await] [lookahead ∉ ThrowExpressionInvalidPunctuator] - `+` UnaryExpression[?Yield, ?Await] - `-` UnaryExpression[?Yield, ?Await] - `~` UnaryExpression[?Yield, ?Await] - `!` UnaryExpression[?Yield, ?Await] - [+Await] AwaitExpression[?Yield] - - - ThrowExpressionInvalidPunctuator : one of `,` `<` `>` `<=` `>=` `==` `!=` `===` `!==` `+` `-` `*` `/` `%` `**` `<<` `>>` `>>>` `&` `|` `^` `&&` `||` `??` `=` `+=` `-=` `*=` `/=` `%=` `**=` `<<=` `>>=` `>>>=` `&=` `|=` `^=` `&&=` `||=` `??=` `?` - - -
- - -

The `throw` Operator

- -

Runtime Semantics: Evaluation

- UnaryExpression : `throw` UnaryExpression - - 1. Let _exprRef_ be ? Evaluation of |UnaryExpression|. - 1. Let _exprValue_ be ? GetValue(_exprRef_). - 1. Return ThrowCompletion(_exprValue_). - -
-
-
- - -

ECMAScript Language: Statements and Declarations

- -

Expression Statement

-

Syntax

- - ExpressionStatement[Yield, Await] : - [lookahead ∉ { `{`, `function`, `async` [no LineTerminator here] `function`, `class`, `let [` }] Expression[+In, ?Yield, ?Await] `;` - [lookahead ∉ { `{`, `function`, `async` [no LineTerminator here] `function`, `class`, `let [`, `throw` }] Expression[+In, ?Yield, ?Await] `;` - - -

- An |ExpressionStatement| cannot start with a U+007B (LEFT CURLY BRACKET) because that might make it ambiguous with a |Block|. - An |ExpressionStatement| cannot start with the `function` or `class` keywords because that would make it ambiguous with a |FunctionDeclaration|, a |GeneratorDeclaration|, or a |ClassDeclaration|. - An |ExpressionStatement| cannot start with `async function` because that would make it ambiguous with an |AsyncFunctionDeclaration|. - An |ExpressionStatement| cannot start with the two token sequence `let [` because that would make it ambiguous with a `let` |LexicalDeclaration| whose first |LexicalBinding| was an |ArrayBindingPattern|. - An |ExpressionStatement| cannot start with `throw` because that would make it ambiguous with a |ThrowStatement|. -

-
-
+ + + + + + + + + + +

Introduction

+

This proposal defines new syntax to throw exceptions from within an expression context.

+

See the proposal repository for background material and discussion.

+
+ + +

Syntax-Directed Operations

+

In addition to those defined in this section, specialized syntax-directed operations are defined throughout this specification.

+ +

Function Name Inference

+ + +

Static Semantics: IsFunctionDefinition ( ): a Boolean

+
+
+ PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList + + 1. Let _expr_ be the |ParenthesizedExpression| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Return IsFunctionDefinition of _expr_. + + + PrimaryExpression : + `this` + IdentifierReference + Literal + ArrayLiteral + ObjectLiteral + RegularExpressionLiteral + TemplateLiteral + + MemberExpression : + MemberExpression `[` Expression `]` + MemberExpression `.` IdentifierName + MemberExpression TemplateLiteral + SuperProperty + MetaProperty + `new` MemberExpression Arguments + MemberExpression `.` PrivateIdentifier + + NewExpression : + `new` NewExpression + + LeftHandSideExpression : + CallExpression + OptionalExpression + + UpdateExpression : + LeftHandSideExpression `++` + LeftHandSideExpression `--` + `++` UnaryExpression + `--` UnaryExpression + + UnaryExpression : + `delete` UnaryExpression + `void` UnaryExpression + `typeof` UnaryExpression + `throw` UnaryExpression + `+` UnaryExpression + `-` UnaryExpression + `~` UnaryExpression + `!` UnaryExpression + AwaitExpression + + ExponentiationExpression : + UpdateExpression `**` ExponentiationExpression + + MultiplicativeExpression : + MultiplicativeExpression MultiplicativeOperator ExponentiationExpression + + AdditiveExpression : + AdditiveExpression `+` MultiplicativeExpression + AdditiveExpression `-` MultiplicativeExpression + + ShiftExpression : + ShiftExpression `<<` AdditiveExpression + ShiftExpression `>>` AdditiveExpression + ShiftExpression `>>>` AdditiveExpression + + RelationalExpression : + RelationalExpression `<` ShiftExpression + RelationalExpression `>` ShiftExpression + RelationalExpression `<=` ShiftExpression + RelationalExpression `>=` ShiftExpression + RelationalExpression `instanceof` ShiftExpression + RelationalExpression `in` ShiftExpression + PrivateIdentifier `in` ShiftExpression + + EqualityExpression : + EqualityExpression `==` RelationalExpression + EqualityExpression `!=` RelationalExpression + EqualityExpression `===` RelationalExpression + EqualityExpression `!==` RelationalExpression + + BitwiseANDExpression : + BitwiseANDExpression `&` EqualityExpression + + BitwiseXORExpression : + BitwiseXORExpression `^` BitwiseANDExpression + + BitwiseORExpression : + BitwiseORExpression `|` BitwiseXORExpression + + LogicalANDExpression : + LogicalANDExpression `&&` BitwiseORExpression + + LogicalORExpression : + LogicalORExpression `||` LogicalANDExpression + + CoalesceExpression : + CoalesceExpressionHead `??` BitwiseORExpression + + ConditionalExpression : + ShortCircuitExpression `?` AssignmentExpression `:` AssignmentExpression + + AssignmentExpression : + YieldExpression + LeftHandSideExpression `=` AssignmentExpression + LeftHandSideExpression AssignmentOperator AssignmentExpression + LeftHandSideExpression `&&=` AssignmentExpression + LeftHandSideExpression `||=` AssignmentExpression + LeftHandSideExpression `??=` AssignmentExpression + + Expression : + Expression `,` AssignmentExpression + + + 1. Return *false*. + + + AssignmentExpression : + ArrowFunction + AsyncArrowFunction + + FunctionExpression : + `function` BindingIdentifier? `(` FormalParameters `)` `{` FunctionBody `}` + + GeneratorExpression : + `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` GeneratorBody `}` + + AsyncGeneratorExpression : + `async` `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}` + + AsyncFunctionExpression : + `async` `function` BindingIdentifier? `(` FormalParameters `)` `{` AsyncFunctionBody `}` + + ClassExpression : + `class` BindingIdentifier? ClassTail + + + 1. Return *true*. + +
+
+ + +

Miscellaneous

+

These operations are used in multiple places throughout the specification.

+ +

Static Semantics: AssignmentTargetType ( ): ~simple~ or ~invalid~

+
+
+ IdentifierReference : Identifier + + 1. If this |IdentifierReference| is contained in strict mode code and StringValue of |Identifier| is either *"eval"* or *"arguments"*, return ~invalid~. + 1. Return ~simple~. + + + IdentifierReference : + `yield` + `await` + + CallExpression : + CallExpression `[` Expression `]` + CallExpression `.` IdentifierName + CallExpression `.` PrivateIdentifier + + MemberExpression : + MemberExpression `[` Expression `]` + MemberExpression `.` IdentifierName + SuperProperty + MemberExpression `.` PrivateIdentifier + + + 1. Return ~simple~. + + + PrimaryExpression : + CoverParenthesizedExpressionAndArrowParameterList + + + 1. Let _expr_ be the |ParenthesizedExpression| that is covered by |CoverParenthesizedExpressionAndArrowParameterList|. + 1. Return AssignmentTargetType of _expr_. + + + PrimaryExpression : + `this` + Literal + ArrayLiteral + ObjectLiteral + FunctionExpression + ClassExpression + GeneratorExpression + AsyncFunctionExpression + AsyncGeneratorExpression + RegularExpressionLiteral + TemplateLiteral + + CallExpression : + CoverCallExpressionAndAsyncArrowHead + SuperCall + ImportCall + CallExpression Arguments + CallExpression TemplateLiteral + + NewExpression : + `new` NewExpression + + MemberExpression : + MemberExpression TemplateLiteral + `new` MemberExpression Arguments + + NewTarget : + `new` `.` `target` + + ImportMeta : + `import` `.` `meta` + + LeftHandSideExpression : + OptionalExpression + + UpdateExpression : + LeftHandSideExpression `++` + LeftHandSideExpression `--` + `++` UnaryExpression + `--` UnaryExpression + + UnaryExpression : + `delete` UnaryExpression + `void` UnaryExpression + `typeof` UnaryExpression + `throw` UnaryExpression + `+` UnaryExpression + `-` UnaryExpression + `~` UnaryExpression + `!` UnaryExpression + AwaitExpression + + ExponentiationExpression : + UpdateExpression `**` ExponentiationExpression + + MultiplicativeExpression : + MultiplicativeExpression MultiplicativeOperator ExponentiationExpression + + AdditiveExpression : + AdditiveExpression `+` MultiplicativeExpression + AdditiveExpression `-` MultiplicativeExpression + + ShiftExpression : + ShiftExpression `<<` AdditiveExpression + ShiftExpression `>>` AdditiveExpression + ShiftExpression `>>>` AdditiveExpression + + RelationalExpression : + RelationalExpression `<` ShiftExpression + RelationalExpression `>` ShiftExpression + RelationalExpression `<=` ShiftExpression + RelationalExpression `>=` ShiftExpression + RelationalExpression `instanceof` ShiftExpression + RelationalExpression `in` ShiftExpression + PrivateIdentifier `in` ShiftExpression + + EqualityExpression : + EqualityExpression `==` RelationalExpression + EqualityExpression `!=` RelationalExpression + EqualityExpression `===` RelationalExpression + EqualityExpression `!==` RelationalExpression + + BitwiseANDExpression : + BitwiseANDExpression `&` EqualityExpression + + BitwiseXORExpression : + BitwiseXORExpression `^` BitwiseANDExpression + + BitwiseORExpression : + BitwiseORExpression `|` BitwiseXORExpression + + LogicalANDExpression : + LogicalANDExpression `&&` BitwiseORExpression + + LogicalORExpression : + LogicalORExpression `||` LogicalANDExpression + + CoalesceExpression : + CoalesceExpressionHead `??` BitwiseORExpression + + ConditionalExpression : + ShortCircuitExpression `?` AssignmentExpression `:` AssignmentExpression + + AssignmentExpression : + YieldExpression + ArrowFunction + AsyncArrowFunction + LeftHandSideExpression `=` AssignmentExpression + LeftHandSideExpression AssignmentOperator AssignmentExpression + LeftHandSideExpression `&&=` AssignmentExpression + LeftHandSideExpression `||=` AssignmentExpression + LeftHandSideExpression `??=` AssignmentExpression + + Expression : + Expression `,` AssignmentExpression + + + 1. Return ~invalid~. + +
+
+
+ + +

ECMAScript Language: Expressions

+ + +

Unary Operators

+

Syntax

+ + UnaryExpression[Yield, Await] : + UpdateExpression[?Yield, ?Await] + `delete` UnaryExpression[?Yield, ?Await] + `void` UnaryExpression[?Yield, ?Await] + `typeof` UnaryExpression[?Yield, ?Await] + `throw` UnaryExpression[?Yield, ?Await] [lookahead ∉ ThrowExpressionInvalidPunctuator] + `+` UnaryExpression[?Yield, ?Await] + `-` UnaryExpression[?Yield, ?Await] + `~` UnaryExpression[?Yield, ?Await] + `!` UnaryExpression[?Yield, ?Await] + [+Await] AwaitExpression[?Yield] + + + ThrowExpressionInvalidPunctuator : one of `,` `<` `>` `<=` `>=` `==` `!=` `===` `!==` `+` `-` `*` `/` `%` `**` `<<` `>>` `>>>` `&` `|` `^` `&&` `||` `??` `=` `+=` `-=` `*=` `/=` `%=` `**=` `<<=` `>>=` `>>>=` `&=` `|=` `^=` `&&=` `||=` `??=` `?` + + +
+ + +

The `throw` Operator

+ +

Runtime Semantics: Evaluation

+ UnaryExpression : `throw` UnaryExpression + + 1. Let _exprRef_ be ? Evaluation of |UnaryExpression|. + 1. Let _exprValue_ be ? GetValue(_exprRef_). + 1. Return ThrowCompletion(_exprValue_). + +
+
+
+ + +

ECMAScript Language: Statements and Declarations

+ +

Expression Statement

+

Syntax

+ + ExpressionStatement[Yield, Await] : + [lookahead ∉ { `{`, `function`, `async` [no LineTerminator here] `function`, `class`, `let [` }] Expression[+In, ?Yield, ?Await] `;` + [lookahead ∉ { `{`, `function`, `async` [no LineTerminator here] `function`, `class`, `let [`, `throw` }] Expression[+In, ?Yield, ?Await] `;` + + +

+ An |ExpressionStatement| cannot start with a U+007B (LEFT CURLY BRACKET) because that might make it ambiguous with a |Block|. + An |ExpressionStatement| cannot start with the `function` or `class` keywords because that would make it ambiguous with a |FunctionDeclaration|, a |GeneratorDeclaration|, or a |ClassDeclaration|. + An |ExpressionStatement| cannot start with `async function` because that would make it ambiguous with an |AsyncFunctionDeclaration|. + An |ExpressionStatement| cannot start with the two token sequence `let [` because that would make it ambiguous with a `let` |LexicalDeclaration| whose first |LexicalBinding| was an |ArrayBindingPattern|. + An |ExpressionStatement| cannot start with `throw` because that would make it ambiguous with a |ThrowStatement|. +

+
+
\ No newline at end of file