8 语法制导操作

除本节中定义的操作外,本规范各处还定义了专门的语法制导操作

8.1 Runtime Semantics: Evaluation

The syntax-directed operation Evaluation takes no arguments and returns a Completion Record.

Note
此操作的定义分布在本规范的“ECMAScript 语言”各节中。每个定义都出现在相关产生式的定义性出现之后。

8.2 作用域分析

8.2.1 Static Semantics: BoundNames

The syntax-directed operation BoundNames takes no arguments and returns a List of Strings.

Note

"*default*" 在本规范中用作模块默认导出的合成名称,当该默认导出没有其他名称时使用。模块的 [[Environment]] 中会用该名称创建一个条目并保存对应的值,并且通过为该模块调用 ResolveExport ( exportName [ , resolveSet ] ) 来解析名为 "default" 的导出,将返回一个 [[BindingName]]"*default*"ResolvedBinding Record,随后它会在模块的 [[Environment]] 中解析为上述值。这样做只是为了方便规范表述,使匿名默认导出可以像任何其他导出一样被解析。这个 "*default*" 字符串永远不能被 ECMAScript 代码或模块链接算法访问。

It is defined piecewise over the following productions:

BindingIdentifier : Identifier
  1. 返回一个 List,其唯一元素是 IdentifierStringValue
BindingIdentifier : yield
  1. 返回 « "yield" »。
BindingIdentifier : await
  1. 返回 « "await" »。
LexicalDeclaration : LetOrConst BindingList ;
  1. 返回 BindingListBoundNames
UsingDeclaration : using BindingList ; AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList ;
  1. 返回 BindingListBoundNames
BindingList : BindingList , LexicalBinding
  1. names1BindingListBoundNames
  2. names2LexicalBindingBoundNames
  3. 返回 names1names2列表连接
LexicalBinding : BindingIdentifier Initializeropt
  1. 返回 BindingIdentifierBoundNames
LexicalBinding : BindingPattern Initializer
  1. 返回 BindingPatternBoundNames
VariableDeclarationList : VariableDeclarationList , VariableDeclaration
  1. names1VariableDeclarationListBoundNames
  2. names2VariableDeclarationBoundNames
  3. 返回 names1names2列表连接
VariableDeclaration : BindingIdentifier Initializeropt
  1. 返回 BindingIdentifierBoundNames
VariableDeclaration : BindingPattern Initializer
  1. 返回 BindingPatternBoundNames
ObjectBindingPattern : { }
  1. 返回一个新的空 List
ObjectBindingPattern : { BindingPropertyList , BindingRestProperty }
  1. names1BindingPropertyListBoundNames
  2. names2BindingRestPropertyBoundNames
  3. 返回 names1names2列表连接
ArrayBindingPattern : [ Elisionopt ]
  1. 返回一个新的空 List
ArrayBindingPattern : [ Elisionopt BindingRestElement ]
  1. 返回 BindingRestElementBoundNames
ArrayBindingPattern : [ BindingElementList , Elisionopt ]
  1. 返回 BindingElementListBoundNames
ArrayBindingPattern : [ BindingElementList , Elisionopt BindingRestElement ]
  1. names1BindingElementListBoundNames
  2. names2BindingRestElementBoundNames
  3. 返回 names1names2列表连接
BindingPropertyList : BindingPropertyList , BindingProperty
  1. names1BindingPropertyListBoundNames
  2. names2BindingPropertyBoundNames
  3. 返回 names1names2列表连接
BindingElementList : BindingElementList , BindingElisionElement
  1. names1BindingElementListBoundNames
  2. names2BindingElisionElementBoundNames
  3. 返回 names1names2列表连接
BindingElisionElement : Elisionopt BindingElement
  1. 返回 BindingElementBoundNames
BindingProperty : PropertyName : BindingElement
  1. 返回 BindingElementBoundNames
SingleNameBinding : BindingIdentifier Initializeropt
  1. 返回 BindingIdentifierBoundNames
BindingElement : BindingPattern Initializeropt
  1. 返回 BindingPatternBoundNames
ForDeclaration : LetOrConst ForBinding
  1. 返回 ForBindingBoundNames
FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody }
  1. 返回 BindingIdentifierBoundNames
FunctionDeclaration : function ( FormalParameters ) { FunctionBody }
  1. 返回 « "*default*" »。
FormalParameters : [empty]
  1. 返回一个新的空 List
FormalParameters : FormalParameterList , FunctionRestParameter
  1. names1FormalParameterListBoundNames
  2. names2FunctionRestParameterBoundNames
  3. 返回 names1names2列表连接
FormalParameterList : FormalParameterList , FormalParameter
  1. names1FormalParameterListBoundNames
  2. names2FormalParameterBoundNames
  3. 返回 names1names2列表连接
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
  1. formalsCoverParenthesizedExpressionAndArrowParameterList覆盖的 ArrowFormalParameters
  2. 返回 formalsBoundNames
GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody }
  1. 返回 BindingIdentifierBoundNames
GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody }
  1. 返回 « "*default*" »。
AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody }
  1. 返回 BindingIdentifierBoundNames
AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody }
  1. 返回 « "*default*" »。
ClassDeclaration : class BindingIdentifier ClassTail
  1. 返回 BindingIdentifierBoundNames
ClassDeclaration : class ClassTail
  1. 返回 « "*default*" »。
AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
  1. 返回 BindingIdentifierBoundNames
AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody }
  1. 返回 « "*default*" »。
CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments
  1. headCoverCallExpressionAndAsyncArrowHead覆盖的 AsyncArrowHead
  2. 返回 headBoundNames
ImportDeclaration : import ImportClause FromClause WithClauseopt ;
  1. 返回 ImportClauseBoundNames
ImportDeclaration : import ModuleSpecifier WithClauseopt ;
  1. 返回一个新的空 List
ImportClause : ImportedDefaultBinding , NameSpaceImport
  1. names1ImportedDefaultBindingBoundNames
  2. names2NameSpaceImportBoundNames
  3. 返回 names1names2列表连接
ImportClause : ImportedDefaultBinding , NamedImports
  1. names1ImportedDefaultBindingBoundNames
  2. names2NamedImportsBoundNames
  3. 返回 names1names2列表连接
NamedImports : { }
  1. 返回一个新的空 List
ImportsList : ImportsList , ImportSpecifier
  1. names1ImportsListBoundNames
  2. names2ImportSpecifierBoundNames
  3. 返回 names1names2列表连接
ImportSpecifier : ModuleExportName as ImportedBinding
  1. 返回 ImportedBindingBoundNames
ExportDeclaration : export ExportFromClause FromClause WithClauseopt ; export NamedExports ;
  1. 返回一个新的空 List
ExportDeclaration : export VariableStatement
  1. 返回 VariableStatementBoundNames
ExportDeclaration : export Declaration
  1. 返回 DeclarationBoundNames
ExportDeclaration : export default HoistableDeclaration
  1. declNamesHoistableDeclarationBoundNames
  2. 如果 declNames包含元素 "*default*",则将 "*default*" 追加到 declNames
  3. 返回 declNames
ExportDeclaration : export default ClassDeclaration
  1. declNamesClassDeclarationBoundNames
  2. 如果 declNames包含元素 "*default*",则将 "*default*" 追加到 declNames
  3. 返回 declNames
ExportDeclaration : export default AssignmentExpression ;
  1. 返回 « "*default*" »。

8.2.2 Static Semantics: DeclarationPart

The syntax-directed operation DeclarationPart takes no arguments and returns a Parse Node. It is defined piecewise over the following productions:

HoistableDeclaration : FunctionDeclaration
  1. 返回 FunctionDeclaration
HoistableDeclaration : GeneratorDeclaration
  1. 返回 GeneratorDeclaration
HoistableDeclaration : AsyncFunctionDeclaration
  1. 返回 AsyncFunctionDeclaration
HoistableDeclaration : AsyncGeneratorDeclaration
  1. 返回 AsyncGeneratorDeclaration
Declaration : ClassDeclaration
  1. 返回 ClassDeclaration
Declaration : LexicalDeclaration
  1. 返回 LexicalDeclaration

8.2.3 Static Semantics: IsConstantDeclaration

The syntax-directed operation IsConstantDeclaration takes no arguments and returns a Boolean. It is defined piecewise over the following productions:

LexicalDeclaration : LetOrConst BindingList ;
  1. 返回 LetOrConstIsConstantDeclaration
LetOrConst : let
  1. 返回 false
LetOrConst : const
  1. 返回 true
UsingDeclaration : using BindingList ; AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList ;
  1. 返回 true
FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } function ( FormalParameters ) { FunctionBody } GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } function * ( FormalParameters ) { GeneratorBody } AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } async function * ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } async function ( FormalParameters ) { AsyncFunctionBody }
  1. 返回 false
ClassDeclaration : class BindingIdentifier ClassTail class ClassTail
  1. 返回 false
ExportDeclaration : export ExportFromClause FromClause ; export NamedExports ; export default AssignmentExpression ;
  1. 返回 false
Note

无需将 export default AssignmentExpression 视为常量声明,因为没有语法允许对用于引用模块默认对象的内部绑定名称进行赋值。

8.2.4 Static Semantics: IsUsingDeclaration

The syntax-directed operation IsUsingDeclaration takes no arguments and returns Boolean. It is defined piecewise over the following productions:

LexicalDeclaration : LetOrConst BindingList ;
  1. 返回 false
UsingDeclaration : using BindingList ; AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList ;
  1. 返回 true
ForDeclaration : LetOrConst ForBinding
  1. 返回 false
ForDeclaration : using ForBinding await using ForBinding
  1. 返回 true
FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } function ( FormalParameters ) { FunctionBody } GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } function * ( FormalParameters ) { GeneratorBody } AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } async function * ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } async function ( FormalParameters ) { AsyncFunctionBody }
  1. 返回 false
ClassDeclaration : class BindingIdentifier ClassTail class ClassTail
  1. 返回 false

8.2.5 Static Semantics: IsAwaitUsingDeclaration

The syntax-directed operation IsAwaitUsingDeclaration takes no arguments and returns Boolean. It is defined piecewise over the following productions:

LexicalDeclaration : LetOrConst BindingList ;
  1. 返回 false
UsingDeclaration : using BindingList ;
  1. 返回 false
AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList ;
  1. 返回 true
ForDeclaration : LetOrConst ForBinding
  1. 返回 false
ForDeclaration : using ForBinding
  1. 返回 false
ForDeclaration : await using ForBinding
  1. 返回 true
FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } function ( FormalParameters ) { FunctionBody } GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } function * ( FormalParameters ) { GeneratorBody } AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } async function * ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } async function ( FormalParameters ) { AsyncFunctionBody }
  1. 返回 false
ClassDeclaration : class BindingIdentifier ClassTail class ClassTail
  1. 返回 false

8.2.6 Static Semantics: LexicallyDeclaredNames

The syntax-directed operation LexicallyDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

Block : { }
  1. 返回一个新的空 List
StatementList : StatementList StatementListItem
  1. names1StatementListLexicallyDeclaredNames
  2. names2StatementListItemLexicallyDeclaredNames
  3. 返回 names1names2列表连接
StatementListItem : Statement
  1. 如果 Statement Statement : LabelledStatement ,则返回 LabelledStatementLexicallyDeclaredNames
  2. 返回一个新的空 List
StatementListItem : Declaration
  1. 返回 DeclarationBoundNames
CaseBlock : { }
  1. 返回一个新的空 List
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,则令 names1 为第一个 CaseClausesLexicallyDeclaredNames
  2. 否则,令 names1 为一个新的空 List
  3. names2DefaultClauseLexicallyDeclaredNames
  4. 如果第二个 CaseClauses 存在,则令 names3 为第二个 CaseClausesLexicallyDeclaredNames
  5. 否则,令 names3 为一个新的空 List
  6. 返回 names1names2names3列表连接
CaseClauses : CaseClauses CaseClause
  1. names1CaseClausesLexicallyDeclaredNames
  2. names2CaseClauseLexicallyDeclaredNames
  3. 返回 names1names2列表连接
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementListLexicallyDeclaredNames
  2. 返回一个新的空 List
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementListLexicallyDeclaredNames
  2. 返回一个新的空 List
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItemLexicallyDeclaredNames
LabelledItem : Statement
  1. 返回一个新的空 List
LabelledItem : FunctionDeclaration
  1. 返回 FunctionDeclarationBoundNames
FunctionStatementList : [empty]
  1. 返回一个新的空 List
FunctionStatementList : StatementList
  1. 返回 StatementListTopLevelLexicallyDeclaredNames
ClassStaticBlockStatementList : [empty]
  1. 返回一个新的空 List
ClassStaticBlockStatementList : StatementList
  1. 返回 StatementListTopLevelLexicallyDeclaredNames
ConciseBody : ExpressionBody
  1. 返回一个新的空 List
AsyncConciseBody : ExpressionBody
  1. 返回一个新的空 List
Script : [empty]
  1. 返回一个新的空 List
ScriptBody : StatementList
  1. 返回 StatementListTopLevelLexicallyDeclaredNames
Note 1

Script 的顶层,函数声明会被像 var 声明一样处理,而不是像词法声明一样处理。

Note 2

Module 的 LexicallyDeclaredNames 包括其所有导入绑定的名称。

ModuleItemList : ModuleItemList ModuleItem
  1. names1ModuleItemListLexicallyDeclaredNames
  2. names2ModuleItemLexicallyDeclaredNames
  3. 返回 names1names2列表连接
ModuleItem : ImportDeclaration
  1. 返回 ImportDeclarationBoundNames
ModuleItem : ExportDeclaration
  1. 如果 ExportDeclarationexport VariableStatement,则返回一个新的空 List
  2. 返回 ExportDeclarationBoundNames
ModuleItem : StatementListItem
  1. 返回 StatementListItemLexicallyDeclaredNames
Note 3

Module 的顶层,函数声明会被像词法声明一样处理,而不是像 var 声明一样处理。

8.2.7 Static Semantics: LexicallyScopedDeclarations

The syntax-directed operation LexicallyScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. decls1StatementListLexicallyScopedDeclarations
  2. decls2StatementListItemLexicallyScopedDeclarations
  3. 返回 decls1decls2列表连接
StatementListItem : Statement
  1. 如果 Statement Statement : LabelledStatement ,则返回 LabelledStatementLexicallyScopedDeclarations
  2. 返回一个新的空 List
StatementListItem : Declaration
  1. 返回一个 List,其唯一元素是 DeclarationDeclarationPart
CaseBlock : { }
  1. 返回一个新的空 List
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,则令 decls1 为第一个 CaseClausesLexicallyScopedDeclarations
  2. 否则,令 decls1 为一个新的空 List
  3. decls2DefaultClauseLexicallyScopedDeclarations
  4. 如果第二个 CaseClauses 存在,则令 decls3 为第二个 CaseClausesLexicallyScopedDeclarations
  5. 否则,令 decls3 为一个新的空 List
  6. 返回 decls1decls2decls3列表连接
CaseClauses : CaseClauses CaseClause
  1. decls1CaseClausesLexicallyScopedDeclarations
  2. decls2CaseClauseLexicallyScopedDeclarations
  3. 返回 decls1decls2列表连接
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementListLexicallyScopedDeclarations
  2. 返回一个新的空 List
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementListLexicallyScopedDeclarations
  2. 返回一个新的空 List
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItemLexicallyScopedDeclarations
LabelledItem : Statement
  1. 返回一个新的空 List
LabelledItem : FunctionDeclaration
  1. 返回 « FunctionDeclaration »。
FunctionStatementList : [empty]
  1. 返回一个新的空 List
FunctionStatementList : StatementList
  1. 返回 StatementListTopLevelLexicallyScopedDeclarations
ClassStaticBlockStatementList : [empty]
  1. 返回一个新的空 List
ClassStaticBlockStatementList : StatementList
  1. 返回 StatementListTopLevelLexicallyScopedDeclarations
ConciseBody : ExpressionBody
  1. 返回一个新的空 List
AsyncConciseBody : ExpressionBody
  1. 返回一个新的空 List
Script : [empty]
  1. 返回一个新的空 List
ScriptBody : StatementList
  1. 返回 StatementListTopLevelLexicallyScopedDeclarations
Module : [empty]
  1. 返回一个新的空 List
ModuleItemList : ModuleItemList ModuleItem
  1. decls1ModuleItemListLexicallyScopedDeclarations
  2. decls2ModuleItemLexicallyScopedDeclarations
  3. 返回 decls1decls2列表连接
ModuleItem : ImportDeclaration
  1. 返回一个新的空 List
ExportDeclaration : export ExportFromClause FromClause WithClauseopt ; export NamedExports ; export VariableStatement
  1. 返回一个新的空 List
ExportDeclaration : export Declaration
  1. 返回一个 List,其唯一元素是 DeclarationDeclarationPart
ExportDeclaration : export default HoistableDeclaration
  1. 返回一个 List,其唯一元素是 HoistableDeclarationDeclarationPart
ExportDeclaration : export default ClassDeclaration
  1. 返回一个 List,其唯一元素是 ClassDeclaration
ExportDeclaration : export default AssignmentExpression ;
  1. 返回一个 List,其唯一元素是此 ExportDeclaration

8.2.8 Static Semantics: VarDeclaredNames

The syntax-directed operation VarDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

Statement : EmptyStatement ExpressionStatement ContinueStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement
  1. 返回一个新的空 List
Block : { }
  1. 返回一个新的空 List
StatementList : StatementList StatementListItem
  1. names1StatementListVarDeclaredNames
  2. names2StatementListItemVarDeclaredNames
  3. 返回 names1names2列表连接
StatementListItem : Declaration
  1. 返回一个新的空 List
VariableStatement : var VariableDeclarationList ;
  1. 返回 VariableDeclarationListBoundNames
IfStatement : if ( Expression ) Statement else Statement
  1. names1 为第一个 StatementVarDeclaredNames
  2. names2 为第二个 StatementVarDeclaredNames
  3. 返回 names1names2列表连接
IfStatement : if ( Expression ) Statement
  1. 返回 StatementVarDeclaredNames
DoWhileStatement : do Statement while ( Expression ) ;
  1. 返回 StatementVarDeclaredNames
WhileStatement : while ( Expression ) Statement
  1. 返回 StatementVarDeclaredNames
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement
  1. 返回 StatementVarDeclaredNames
ForStatement : for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
  1. names1VariableDeclarationListBoundNames
  2. names2StatementVarDeclaredNames
  3. 返回 names1names2列表连接
ForStatement : for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. 返回 StatementVarDeclaredNames
ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( ForDeclaration in Expression ) Statement for ( LeftHandSideExpression of AssignmentExpression ) Statement for ( ForDeclaration of AssignmentExpression ) Statement for await ( LeftHandSideExpression of AssignmentExpression ) Statement for await ( ForDeclaration of AssignmentExpression ) Statement
  1. 返回 StatementVarDeclaredNames
ForInOfStatement : for ( var ForBinding in Expression ) Statement for ( var ForBinding of AssignmentExpression ) Statement for await ( var ForBinding of AssignmentExpression ) Statement
  1. names1ForBindingBoundNames
  2. names2StatementVarDeclaredNames
  3. 返回 names1names2列表连接
Note

本节由附录 B.3.5 扩展。

WithStatement : with ( Expression ) Statement
  1. 返回 StatementVarDeclaredNames
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回 CaseBlockVarDeclaredNames
CaseBlock : { }
  1. 返回一个新的空 List
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,则令 names1 为第一个 CaseClausesVarDeclaredNames
  2. 否则,令 names1 为一个新的空 List
  3. names2DefaultClauseVarDeclaredNames
  4. 如果第二个 CaseClauses 存在,则令 names3 为第二个 CaseClausesVarDeclaredNames
  5. 否则,令 names3 为一个新的空 List
  6. 返回 names1names2names3列表连接
CaseClauses : CaseClauses CaseClause
  1. names1CaseClausesVarDeclaredNames
  2. names2CaseClauseVarDeclaredNames
  3. 返回 names1names2列表连接
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementListVarDeclaredNames
  2. 返回一个新的空 List
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementListVarDeclaredNames
  2. 返回一个新的空 List
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItemVarDeclaredNames
LabelledItem : FunctionDeclaration
  1. 返回一个新的空 List
TryStatement : try Block Catch
  1. names1BlockVarDeclaredNames
  2. names2CatchVarDeclaredNames
  3. 返回 names1names2列表连接
TryStatement : try Block Finally
  1. names1BlockVarDeclaredNames
  2. names2FinallyVarDeclaredNames
  3. 返回 names1names2列表连接
TryStatement : try Block Catch Finally
  1. names1BlockVarDeclaredNames
  2. names2CatchVarDeclaredNames
  3. names3FinallyVarDeclaredNames
  4. 返回 names1names2names3列表连接
Catch : catch ( CatchParameter ) Block
  1. 返回 BlockVarDeclaredNames
FunctionStatementList : [empty]
  1. 返回一个新的空 List
FunctionStatementList : StatementList
  1. 返回 StatementListTopLevelVarDeclaredNames
ClassStaticBlockStatementList : [empty]
  1. 返回一个新的空 List
ClassStaticBlockStatementList : StatementList
  1. 返回 StatementListTopLevelVarDeclaredNames
ConciseBody : ExpressionBody
  1. 返回一个新的空 List
AsyncConciseBody : ExpressionBody
  1. 返回一个新的空 List
Script : [empty]
  1. 返回一个新的空 List
ScriptBody : StatementList
  1. 返回 StatementListTopLevelVarDeclaredNames
ModuleItemList : ModuleItemList ModuleItem
  1. names1ModuleItemListVarDeclaredNames
  2. names2ModuleItemVarDeclaredNames
  3. 返回 names1names2列表连接
ModuleItem : ImportDeclaration
  1. 返回一个新的空 List
ModuleItem : ExportDeclaration
  1. 如果 ExportDeclarationexport VariableStatement,则返回 ExportDeclarationBoundNames
  2. 返回一个新的空 List

8.2.9 Static Semantics: VarScopedDeclarations

The syntax-directed operation VarScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

Statement : EmptyStatement ExpressionStatement ContinueStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement
  1. 返回一个新的空 List
Block : { }
  1. 返回一个新的空 List
StatementList : StatementList StatementListItem
  1. decls1StatementListVarScopedDeclarations
  2. decls2StatementListItemVarScopedDeclarations
  3. 返回 decls1decls2列表连接
StatementListItem : Declaration
  1. 返回一个新的空 List
VariableDeclarationList : VariableDeclaration
  1. 返回 « VariableDeclaration »。
VariableDeclarationList : VariableDeclarationList , VariableDeclaration
  1. decls1VariableDeclarationListVarScopedDeclarations
  2. 返回 decls1 与 « VariableDeclaration » 的列表连接
IfStatement : if ( Expression ) Statement else Statement
  1. decls1 为第一个 StatementVarScopedDeclarations
  2. decls2 为第二个 StatementVarScopedDeclarations
  3. 返回 decls1decls2列表连接
IfStatement : if ( Expression ) Statement
  1. 返回 StatementVarScopedDeclarations
DoWhileStatement : do Statement while ( Expression ) ;
  1. 返回 StatementVarScopedDeclarations
WhileStatement : while ( Expression ) Statement
  1. 返回 StatementVarScopedDeclarations
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement
  1. 返回 StatementVarScopedDeclarations
ForStatement : for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
  1. decls1VariableDeclarationListVarScopedDeclarations
  2. decls2StatementVarScopedDeclarations
  3. 返回 decls1decls2列表连接
ForStatement : for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. 返回 StatementVarScopedDeclarations
ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( ForDeclaration in Expression ) Statement for ( LeftHandSideExpression of AssignmentExpression ) Statement for ( ForDeclaration of AssignmentExpression ) Statement for await ( LeftHandSideExpression of AssignmentExpression ) Statement for await ( ForDeclaration of AssignmentExpression ) Statement
  1. 返回 StatementVarScopedDeclarations
ForInOfStatement : for ( var ForBinding in Expression ) Statement for ( var ForBinding of AssignmentExpression ) Statement for await ( var ForBinding of AssignmentExpression ) Statement
  1. decls1 为 « ForBinding »。
  2. decls2StatementVarScopedDeclarations
  3. 返回 decls1decls2列表连接
Note

本节由附录 B.3.5 扩展。

WithStatement : with ( Expression ) Statement
  1. 返回 StatementVarScopedDeclarations
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回 CaseBlockVarScopedDeclarations
CaseBlock : { }
  1. 返回一个新的空 List
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,则令 decls1 为第一个 CaseClausesVarScopedDeclarations
  2. 否则,令 decls1 为一个新的空 List
  3. decls2DefaultClauseVarScopedDeclarations
  4. 如果第二个 CaseClauses 存在,则令 decls3 为第二个 CaseClausesVarScopedDeclarations
  5. 否则,令 decls3 为一个新的空 List
  6. 返回 decls1decls2decls3列表连接
CaseClauses : CaseClauses CaseClause
  1. decls1CaseClausesVarScopedDeclarations
  2. decls2CaseClauseVarScopedDeclarations
  3. 返回 decls1decls2列表连接
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementListVarScopedDeclarations
  2. 返回一个新的空 List
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementListVarScopedDeclarations
  2. 返回一个新的空 List
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItemVarScopedDeclarations
LabelledItem : FunctionDeclaration
  1. 返回一个新的空 List
TryStatement : try Block Catch
  1. decls1BlockVarScopedDeclarations
  2. decls2CatchVarScopedDeclarations
  3. 返回 decls1decls2列表连接
TryStatement : try Block Finally
  1. decls1BlockVarScopedDeclarations
  2. decls2FinallyVarScopedDeclarations
  3. 返回 decls1decls2列表连接
TryStatement : try Block Catch Finally
  1. decls1BlockVarScopedDeclarations
  2. decls2CatchVarScopedDeclarations
  3. decls3FinallyVarScopedDeclarations
  4. 返回 decls1decls2decls3列表连接
Catch : catch ( CatchParameter ) Block
  1. 返回 BlockVarScopedDeclarations
FunctionStatementList : [empty]
  1. 返回一个新的空 List
FunctionStatementList : StatementList
  1. 返回 StatementListTopLevelVarScopedDeclarations
ClassStaticBlockStatementList : [empty]
  1. 返回一个新的空 List
ClassStaticBlockStatementList : StatementList
  1. 返回 StatementListTopLevelVarScopedDeclarations
ConciseBody : ExpressionBody
  1. 返回一个新的空 List
AsyncConciseBody : ExpressionBody
  1. 返回一个新的空 List
Script : [empty]
  1. 返回一个新的空 List
ScriptBody : StatementList
  1. 返回 StatementListTopLevelVarScopedDeclarations
Module : [empty]
  1. 返回一个新的空 List
ModuleItemList : ModuleItemList ModuleItem
  1. decls1ModuleItemListVarScopedDeclarations
  2. decls2ModuleItemVarScopedDeclarations
  3. 返回 decls1decls2列表连接
ModuleItem : ImportDeclaration
  1. 返回一个新的空 List
ModuleItem : ExportDeclaration
  1. 如果 ExportDeclarationexport VariableStatement,则返回 VariableStatementVarScopedDeclarations
  2. 返回一个新的空 List

8.2.10 Static Semantics: TopLevelLexicallyDeclaredNames

The syntax-directed operation TopLevelLexicallyDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. names1StatementListTopLevelLexicallyDeclaredNames
  2. names2StatementListItemTopLevelLexicallyDeclaredNames
  3. 返回 names1names2列表连接
StatementListItem : Statement
  1. 返回一个新的空 List
StatementListItem : Declaration
  1. 如果 Declaration Declaration : HoistableDeclaration ,则
    1. 返回一个新的空 List
  2. 返回 DeclarationBoundNames
Note

在函数或脚本的顶层,函数声明会被像 var 声明一样处理,而不是像词法声明一样处理。

8.2.11 Static Semantics: TopLevelLexicallyScopedDeclarations

The syntax-directed operation TopLevelLexicallyScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. decls1StatementListTopLevelLexicallyScopedDeclarations
  2. decls2StatementListItemTopLevelLexicallyScopedDeclarations
  3. 返回 decls1decls2列表连接
StatementListItem : Statement
  1. 返回一个新的空 List
StatementListItem : Declaration
  1. 如果 Declaration Declaration : HoistableDeclaration ,则
    1. 返回一个新的空 List
  2. 返回 « Declaration »。

8.2.12 Static Semantics: TopLevelVarDeclaredNames

The syntax-directed operation TopLevelVarDeclaredNames takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. names1StatementListTopLevelVarDeclaredNames
  2. names2StatementListItemTopLevelVarDeclaredNames
  3. 返回 names1names2列表连接
StatementListItem : Declaration
  1. 如果 Declaration Declaration : HoistableDeclaration ,则
    1. 返回 HoistableDeclarationBoundNames
  2. 返回一个新的空 List
StatementListItem : Statement
  1. 如果 Statement Statement : LabelledStatement ,则返回 StatementTopLevelVarDeclaredNames
  2. 返回 StatementVarDeclaredNames
Note

在函数或脚本的顶层,内部函数声明会被像 var 声明一样处理。

LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItemTopLevelVarDeclaredNames
LabelledItem : Statement
  1. 如果 Statement Statement : LabelledStatement ,则返回 StatementTopLevelVarDeclaredNames
  2. 返回 StatementVarDeclaredNames
LabelledItem : FunctionDeclaration
  1. 返回 FunctionDeclarationBoundNames

8.2.13 Static Semantics: TopLevelVarScopedDeclarations

The syntax-directed operation TopLevelVarScopedDeclarations takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. decls1StatementListTopLevelVarScopedDeclarations
  2. decls2StatementListItemTopLevelVarScopedDeclarations
  3. 返回 decls1decls2列表连接
StatementListItem : Statement
  1. 如果 Statement Statement : LabelledStatement ,则返回 StatementTopLevelVarScopedDeclarations
  2. 返回 StatementVarScopedDeclarations
StatementListItem : Declaration
  1. 如果 Declaration Declaration : HoistableDeclaration ,则
    1. declHoistableDeclarationDeclarationPart
    2. 返回 « decl »。
  2. 返回一个新的空 List
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItemTopLevelVarScopedDeclarations
LabelledItem : Statement
  1. 如果 Statement Statement : LabelledStatement ,则返回 StatementTopLevelVarScopedDeclarations
  2. 返回 StatementVarScopedDeclarations
LabelledItem : FunctionDeclaration
  1. 返回 « FunctionDeclaration »。

8.3 标签

8.3.1 Static Semantics: ContainsDuplicateLabels

The syntax-directed operation ContainsDuplicateLabels takes argument labelSet (a List of Strings) and returns a Boolean. It is defined piecewise over the following productions:

Statement : VariableStatement EmptyStatement ExpressionStatement ContinueStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement Block : { } StatementListItem : Declaration
  1. 返回 false
StatementList : StatementList StatementListItem
  1. hasDuplicatesStatementList 带实参 labelSetContainsDuplicateLabels
  2. 如果 hasDuplicatestrue,则返回 true
  3. 返回 StatementListItem 带实参 labelSetContainsDuplicateLabels
IfStatement : if ( Expression ) Statement else Statement
  1. hasDuplicate 为第一个 Statement 带实参 labelSetContainsDuplicateLabels
  2. 如果 hasDuplicatetrue,则返回 true
  3. 返回第二个 Statement 带实参 labelSetContainsDuplicateLabels
IfStatement : if ( Expression ) Statement
  1. 返回 Statement 带实参 labelSetContainsDuplicateLabels
DoWhileStatement : do Statement while ( Expression ) ;
  1. 返回 Statement 带实参 labelSetContainsDuplicateLabels
WhileStatement : while ( Expression ) Statement
  1. 返回 Statement 带实参 labelSetContainsDuplicateLabels
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. 返回 Statement 带实参 labelSetContainsDuplicateLabels
ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( var ForBinding in Expression ) Statement for ( ForDeclaration in Expression ) Statement for ( LeftHandSideExpression of AssignmentExpression ) Statement for ( var ForBinding of AssignmentExpression ) Statement for ( ForDeclaration of AssignmentExpression ) Statement for await ( LeftHandSideExpression of AssignmentExpression ) Statement for await ( var ForBinding of AssignmentExpression ) Statement for await ( ForDeclaration of AssignmentExpression ) Statement
  1. 返回 Statement 带实参 labelSetContainsDuplicateLabels
Note

本节由附录 B.3.5 扩展。

WithStatement : with ( Expression ) Statement
  1. 返回 Statement 带实参 labelSetContainsDuplicateLabels
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回 CaseBlock 带实参 labelSetContainsDuplicateLabels
CaseBlock : { }
  1. 返回 false
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,则
    1. 如果第一个 CaseClauses 带实参 labelSetContainsDuplicateLabelstrue,则返回 true
  2. 如果 DefaultClause 带实参 labelSetContainsDuplicateLabelstrue,则返回 true
  3. 如果第二个 CaseClauses 不存在,则返回 false
  4. 返回第二个 CaseClauses 带实参 labelSetContainsDuplicateLabels
CaseClauses : CaseClauses CaseClause
  1. hasDuplicatesCaseClauses 带实参 labelSetContainsDuplicateLabels
  2. 如果 hasDuplicatestrue,则返回 true
  3. 返回 CaseClause 带实参 labelSetContainsDuplicateLabels
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementList 带实参 labelSetContainsDuplicateLabels
  2. 返回 false
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementList 带实参 labelSetContainsDuplicateLabels
  2. 返回 false
LabelledStatement : LabelIdentifier : LabelledItem
  1. labelLabelIdentifierStringValue
  2. 如果 labelSet 包含 label,则返回 true
  3. newLabelSetlabelSet 与 « label » 的列表连接
  4. 返回 LabelledItem 带实参 newLabelSetContainsDuplicateLabels
LabelledItem : FunctionDeclaration
  1. 返回 false
TryStatement : try Block Catch
  1. hasDuplicatesBlock 带实参 labelSetContainsDuplicateLabels
  2. 如果 hasDuplicatestrue,则返回 true
  3. 返回 Catch 带实参 labelSetContainsDuplicateLabels
TryStatement : try Block Finally
  1. hasDuplicatesBlock 带实参 labelSetContainsDuplicateLabels
  2. 如果 hasDuplicatestrue,则返回 true
  3. 返回 Finally 带实参 labelSetContainsDuplicateLabels
TryStatement : try Block Catch Finally
  1. 如果 Block 带实参 labelSetContainsDuplicateLabelstrue,则返回 true
  2. 如果 Catch 带实参 labelSetContainsDuplicateLabelstrue,则返回 true
  3. 返回 Finally 带实参 labelSetContainsDuplicateLabels
Catch : catch ( CatchParameter ) Block
  1. 返回 Block 带实参 labelSetContainsDuplicateLabels
FunctionStatementList : [empty]
  1. 返回 false
ClassStaticBlockStatementList : [empty]
  1. 返回 false
ModuleItemList : ModuleItemList ModuleItem
  1. hasDuplicatesModuleItemList 带实参 labelSetContainsDuplicateLabels
  2. 如果 hasDuplicatestrue,则返回 true
  3. 返回 ModuleItem 带实参 labelSetContainsDuplicateLabels
ModuleItem : ImportDeclaration ExportDeclaration
  1. 返回 false

8.3.2 Static Semantics: ContainsUndefinedBreakTarget

The syntax-directed operation ContainsUndefinedBreakTarget takes argument labelSet (a List of Strings) and returns a Boolean. It is defined piecewise over the following productions:

Statement : VariableStatement EmptyStatement ExpressionStatement ContinueStatement ReturnStatement ThrowStatement DebuggerStatement Block : { } StatementListItem : Declaration
  1. 返回 false
StatementList : StatementList StatementListItem
  1. hasUndefinedLabelsStatementList 带实参 labelSetContainsUndefinedBreakTarget
  2. 如果 hasUndefinedLabelstrue,则返回 true
  3. 返回 StatementListItem 带实参 labelSetContainsUndefinedBreakTarget
IfStatement : if ( Expression ) Statement else Statement
  1. hasUndefinedLabels 为第一个 Statement 带实参 labelSetContainsUndefinedBreakTarget
  2. 如果 hasUndefinedLabelstrue,则返回 true
  3. 返回第二个 Statement 带实参 labelSetContainsUndefinedBreakTarget
IfStatement : if ( Expression ) Statement
  1. 返回 Statement 带实参 labelSetContainsUndefinedBreakTarget
DoWhileStatement : do Statement while ( Expression ) ;
  1. 返回 Statement 带实参 labelSetContainsUndefinedBreakTarget
WhileStatement : while ( Expression ) Statement
  1. 返回 Statement 带实参 labelSetContainsUndefinedBreakTarget
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. 返回 Statement 带实参 labelSetContainsUndefinedBreakTarget
ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( var ForBinding in Expression ) Statement for ( ForDeclaration in Expression ) Statement for ( LeftHandSideExpression of AssignmentExpression ) Statement for ( var ForBinding of AssignmentExpression ) Statement for ( ForDeclaration of AssignmentExpression ) Statement for await ( LeftHandSideExpression of AssignmentExpression ) Statement for await ( var ForBinding of AssignmentExpression ) Statement for await ( ForDeclaration of AssignmentExpression ) Statement
  1. 返回 Statement 带实参 labelSetContainsUndefinedBreakTarget
Note

本节由附录 B.3.5 扩展。

BreakStatement : break ;
  1. 返回 false
BreakStatement : break LabelIdentifier ;
  1. 如果 labelSet 包含 LabelIdentifierStringValue,则返回 false
  2. 返回 true
WithStatement : with ( Expression ) Statement
  1. 返回 Statement 带实参 labelSetContainsUndefinedBreakTarget
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回 CaseBlock 带实参 labelSetContainsUndefinedBreakTarget
CaseBlock : { }
  1. 返回 false
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,则
    1. 如果第一个 CaseClauses 带实参 labelSetContainsUndefinedBreakTargettrue,则返回 true
  2. 如果 DefaultClause 带实参 labelSetContainsUndefinedBreakTargettrue,则返回 true
  3. 如果第二个 CaseClauses 不存在,则返回 false
  4. 返回第二个 CaseClauses 带实参 labelSetContainsUndefinedBreakTarget
CaseClauses : CaseClauses CaseClause
  1. hasUndefinedLabelsCaseClauses 带实参 labelSetContainsUndefinedBreakTarget
  2. 如果 hasUndefinedLabelstrue,则返回 true
  3. 返回 CaseClause 带实参 labelSetContainsUndefinedBreakTarget
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementList 带实参 labelSetContainsUndefinedBreakTarget
  2. 返回 false
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementList 带实参 labelSetContainsUndefinedBreakTarget
  2. 返回 false
LabelledStatement : LabelIdentifier : LabelledItem
  1. labelLabelIdentifierStringValue
  2. newLabelSetlabelSet 与 « label » 的列表连接
  3. 返回 LabelledItem 带实参 newLabelSetContainsUndefinedBreakTarget
LabelledItem : FunctionDeclaration
  1. 返回 false
TryStatement : try Block Catch
  1. hasUndefinedLabelsBlock 带实参 labelSetContainsUndefinedBreakTarget
  2. 如果 hasUndefinedLabelstrue,则返回 true
  3. 返回 Catch 带实参 labelSetContainsUndefinedBreakTarget
TryStatement : try Block Finally
  1. hasUndefinedLabelsBlock 带实参 labelSetContainsUndefinedBreakTarget
  2. 如果 hasUndefinedLabelstrue,则返回 true
  3. 返回 Finally 带实参 labelSetContainsUndefinedBreakTarget
TryStatement : try Block Catch Finally
  1. 如果 Block 带实参 labelSetContainsUndefinedBreakTargettrue,则返回 true
  2. 如果 Catch 带实参 labelSetContainsUndefinedBreakTargettrue,则返回 true
  3. 返回 Finally 带实参 labelSetContainsUndefinedBreakTarget
Catch : catch ( CatchParameter ) Block
  1. 返回 Block 带实参 labelSetContainsUndefinedBreakTarget
FunctionStatementList : [empty]
  1. 返回 false
ClassStaticBlockStatementList : [empty]
  1. 返回 false
ModuleItemList : ModuleItemList ModuleItem
  1. hasUndefinedLabelsModuleItemList 带实参 labelSetContainsUndefinedBreakTarget
  2. 如果 hasUndefinedLabelstrue,则返回 true
  3. 返回 ModuleItem 带实参 labelSetContainsUndefinedBreakTarget
ModuleItem : ImportDeclaration ExportDeclaration
  1. 返回 false

8.3.3 Static Semantics: ContainsUndefinedContinueTarget

The syntax-directed operation ContainsUndefinedContinueTarget takes arguments iterationSet (a List of Strings) and labelSet (a List of Strings) and returns a Boolean. It is defined piecewise over the following productions:

Statement : VariableStatement EmptyStatement ExpressionStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement Block : { } StatementListItem : Declaration
  1. 返回 false
Statement : BlockStatement
  1. 返回 BlockStatement 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
BreakableStatement : IterationStatement
  1. newIterationSetiterationSetlabelSet列表连接
  2. 返回 IterationStatement 带实参 newIterationSet 和 « » 的 ContainsUndefinedContinueTarget
StatementList : StatementList StatementListItem
  1. hasUndefinedLabelsStatementList 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
  2. 如果 hasUndefinedLabelstrue,则返回 true
  3. 返回 StatementListItem 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
IfStatement : if ( Expression ) Statement else Statement
  1. hasUndefinedLabels 为第一个 Statement 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
  2. 如果 hasUndefinedLabelstrue,则返回 true
  3. 返回第二个 Statement 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
IfStatement : if ( Expression ) Statement
  1. 返回 Statement 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
DoWhileStatement : do Statement while ( Expression ) ;
  1. 返回 Statement 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
WhileStatement : while ( Expression ) Statement
  1. 返回 Statement 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. 返回 Statement 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( var ForBinding in Expression ) Statement for ( ForDeclaration in Expression ) Statement for ( LeftHandSideExpression of AssignmentExpression ) Statement for ( var ForBinding of AssignmentExpression ) Statement for ( ForDeclaration of AssignmentExpression ) Statement for await ( LeftHandSideExpression of AssignmentExpression ) Statement for await ( var ForBinding of AssignmentExpression ) Statement for await ( ForDeclaration of AssignmentExpression ) Statement
  1. 返回 Statement 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
Note

本节由附录 B.3.5 扩展。

ContinueStatement : continue ;
  1. 返回 false
ContinueStatement : continue LabelIdentifier ;
  1. 如果 iterationSet 包含 LabelIdentifierStringValue,则返回 false
  2. 返回 true
WithStatement : with ( Expression ) Statement
  1. 返回 Statement 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回 CaseBlock 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
CaseBlock : { }
  1. 返回 false
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,则
    1. 如果第一个 CaseClauses 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTargettrue,则返回 true
  2. 如果 DefaultClause 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTargettrue,则返回 true
  3. 如果第二个 CaseClauses 不存在,则返回 false
  4. 返回第二个 CaseClauses 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
CaseClauses : CaseClauses CaseClause
  1. hasUndefinedLabelsCaseClauses 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
  2. 如果 hasUndefinedLabelstrue,则返回 true
  3. 返回 CaseClause 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementList 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
  2. 返回 false
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,则返回 StatementList 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
  2. 返回 false
LabelledStatement : LabelIdentifier : LabelledItem
  1. labelLabelIdentifierStringValue
  2. newLabelSetlabelSet 与 « label » 的列表连接
  3. 返回 LabelledItem 带实参 iterationSetnewLabelSetContainsUndefinedContinueTarget
LabelledItem : FunctionDeclaration
  1. 返回 false
TryStatement : try Block Catch
  1. hasUndefinedLabelsBlock 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
  2. 如果 hasUndefinedLabelstrue,则返回 true
  3. 返回 Catch 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
TryStatement : try Block Finally
  1. hasUndefinedLabelsBlock 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
  2. 如果 hasUndefinedLabelstrue,则返回 true
  3. 返回 Finally 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
TryStatement : try Block Catch Finally
  1. 如果 Block 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTargettrue,则返回 true
  2. 如果 Catch 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTargettrue,则返回 true
  3. 返回 Finally 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
Catch : catch ( CatchParameter ) Block
  1. 返回 Block 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
FunctionStatementList : [empty]
  1. 返回 false
ClassStaticBlockStatementList : [empty]
  1. 返回 false
ModuleItemList : ModuleItemList ModuleItem
  1. hasUndefinedLabelsModuleItemList 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
  2. 如果 hasUndefinedLabelstrue,则返回 true
  3. 返回 ModuleItem 带实参 iterationSet 和 « » 的 ContainsUndefinedContinueTarget
ModuleItem : ImportDeclaration ExportDeclaration
  1. 返回 false

8.4 函数名称推断

8.4.1 Static Semantics: HasName

The syntax-directed operation HasName takes no arguments and returns a Boolean. It is defined piecewise over the following productions:

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. exprCoverParenthesizedExpressionAndArrowParameterList覆盖的 ParenthesizedExpression
  2. 如果 exprIsFunctionDefinitionfalse,则返回 false
  3. 返回 exprHasName
FunctionExpression : function ( FormalParameters ) { FunctionBody } GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } AsyncGeneratorExpression : async function * ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } ArrowFunction : ArrowParameters => ConciseBody AsyncArrowFunction : async AsyncArrowBindingIdentifier => AsyncConciseBody CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody ClassExpression : class ClassTail
  1. 返回 false
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. 返回 true

8.4.2 Static Semantics: IsFunctionDefinition

The syntax-directed operation IsFunctionDefinition takes no arguments and returns a Boolean. It is defined piecewise over the following productions:

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. exprCoverParenthesizedExpressionAndArrowParameterList覆盖的 ParenthesizedExpression
  2. 返回 exprIsFunctionDefinition
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 + UnaryExpression - UnaryExpression ~ UnaryExpression ! UnaryExpression CoverAwaitExpressionAndAwaitUsingDeclarationHead 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. 返回 false
AssignmentExpression : ArrowFunction AsyncArrowFunction FunctionExpression : function BindingIdentifieropt ( FormalParameters ) { FunctionBody } GeneratorExpression : function * BindingIdentifieropt ( FormalParameters ) { GeneratorBody } AsyncGeneratorExpression : async function * BindingIdentifieropt ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionExpression : async function BindingIdentifieropt ( FormalParameters ) { AsyncFunctionBody } ClassExpression : class BindingIdentifieropt ClassTail
  1. 返回 true

8.4.3 Static Semantics: IsAnonymousFunctionDefinition ( expr )

The abstract operation IsAnonymousFunctionDefinition takes argument expr (an AssignmentExpression Parse Node, an Initializer Parse Node, or an Expression Parse Node) and returns a Boolean. 它确定其实参是否为不绑定名称的函数定义。 It performs the following steps when called:

  1. 如果 exprIsFunctionDefinitionfalse,则返回 false
  2. hasNameexprHasName
  3. 如果 hasNametrue,则返回 false
  4. 返回 true

8.4.4 Static Semantics: IsIdentifierRef

The syntax-directed operation IsIdentifierRef takes no arguments and returns a Boolean. It is defined piecewise over the following productions:

PrimaryExpression : IdentifierReference
  1. 返回 true
PrimaryExpression : this Literal ArrayLiteral ObjectLiteral FunctionExpression ClassExpression GeneratorExpression AsyncFunctionExpression AsyncGeneratorExpression RegularExpressionLiteral TemplateLiteral CoverParenthesizedExpressionAndArrowParameterList MemberExpression : MemberExpression [ Expression ] MemberExpression . IdentifierName MemberExpression TemplateLiteral SuperProperty MetaProperty new MemberExpression Arguments MemberExpression . PrivateIdentifier NewExpression : new NewExpression LeftHandSideExpression : CallExpression OptionalExpression
  1. 返回 false

8.4.5 Runtime Semantics: NamedEvaluation

The syntax-directed operation NamedEvaluation takes argument name (a property key or a Private Name) and returns either a normal completion containing a function object or an abrupt completion. It is defined piecewise over the following productions:

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. exprCoverParenthesizedExpressionAndArrowParameterList覆盖的 ParenthesizedExpression
  2. 返回 ? expr 带实参 nameNamedEvaluation
ParenthesizedExpression : ( Expression )
  1. 断言:IsAnonymousFunctionDefinition(Expression) 是 true
  2. 返回 ? Expression 带实参 nameNamedEvaluation
FunctionExpression : function ( FormalParameters ) { FunctionBody }
  1. 返回 FunctionExpression 带实参 nameInstantiateOrdinaryFunctionExpression
GeneratorExpression : function * ( FormalParameters ) { GeneratorBody }
  1. 返回 GeneratorExpression 带实参 nameInstantiateGeneratorFunctionExpression
AsyncGeneratorExpression : async function * ( FormalParameters ) { AsyncGeneratorBody }
  1. 返回 AsyncGeneratorExpression 带实参 nameInstantiateAsyncGeneratorFunctionExpression
AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody }
  1. 返回 AsyncFunctionExpression 带实参 nameInstantiateAsyncFunctionExpression
ArrowFunction : ArrowParameters => ConciseBody
  1. 返回 ArrowFunction 带实参 nameInstantiateArrowFunctionExpression
AsyncArrowFunction : async AsyncArrowBindingIdentifier => AsyncConciseBody CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody
  1. 返回 AsyncArrowFunction 带实参 nameInstantiateAsyncArrowFunctionExpression
ClassExpression : class ClassTail
  1. sourceTextClassExpression匹配的源文本
  2. 返回 ? ClassTail 带实参 undefinednamesourceTextClassDefinitionEvaluation

8.5 Contains

8.5.1 Static Semantics: Contains

The syntax-directed operation Contains takes argument symbol (a grammar symbol) and returns a Boolean.

本规范中未在下方列出的每个文法产生式替代项,都隐式具有以下 Contains 的默认定义:

  1. 对此 Parse Node 的每个子节点 child,执行:
    1. 如果 childsymbol 的实例,则返回 true
    2. 如果 child 是非终结符的实例,则
      1. containedchild Contains symbol 的结果。
      2. 如果 containedtrue,则返回 true
  2. 返回 false
FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } function ( FormalParameters ) { FunctionBody } FunctionExpression : function BindingIdentifieropt ( FormalParameters ) { FunctionBody } GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } function * ( FormalParameters ) { GeneratorBody } GeneratorExpression : function * BindingIdentifieropt ( FormalParameters ) { GeneratorBody } AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } async function * ( FormalParameters ) { AsyncGeneratorBody } AsyncGeneratorExpression : async function * BindingIdentifieropt ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } async function ( FormalParameters ) { AsyncFunctionBody } AsyncFunctionExpression : async function BindingIdentifieropt ( FormalParameters ) { AsyncFunctionBody }
  1. 返回 false
Note 1

依赖子结构的静态语义规则通常不会查看函数定义内部。

ClassTail : ClassHeritageopt { ClassBody }
  1. 如果 symbolClassBody,则返回 true
  2. 如果 symbolClassHeritage,则
    1. 如果 ClassHeritage 存在,则返回 true
    2. 返回 false
  3. 如果 ClassHeritage 存在,则
    1. 如果 ClassHeritage Contains symboltrue,则返回 true
  4. 返回 ClassBody 带实参 symbolComputedPropertyContains 的结果。
Note 2

依赖子结构的静态语义规则通常不会查看类体内部,除 PropertyName 外。

ClassStaticBlock : static { ClassStaticBlockBody }
  1. 返回 false
Note 3

依赖子结构的静态语义规则通常不会查看 static 初始化块内部。

ArrowFunction : ArrowParameters => ConciseBody
  1. 如果 symbol 不是 NewTargetSuperPropertySuperCallsuperthis 之一,则返回 false
  2. 如果 ArrowParameters Contains symboltrue,则返回 true
  3. 返回 ConciseBody Contains symbol
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
  1. formalsCoverParenthesizedExpressionAndArrowParameterList覆盖的 ArrowFormalParameters
  2. 返回 formals Contains symbol
AsyncArrowFunction : async AsyncArrowBindingIdentifier => AsyncConciseBody
  1. 如果 symbol 不是 NewTargetSuperPropertySuperCallsuperthis 之一,则返回 false
  2. 返回 AsyncConciseBody Contains symbol
AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody
  1. 如果 symbol 不是 NewTargetSuperPropertySuperCallsuperthis 之一,则返回 false
  2. headCoverCallExpressionAndAsyncArrowHead覆盖的 AsyncArrowHead
  3. 如果 head Contains symboltrue,则返回 true
  4. 返回 AsyncConciseBody Contains symbol
Note 4

Contains 用于检测 ArrowFunctionAsyncArrowFunction 中的 new.targetthissuper 用法。

PropertyDefinition : MethodDefinition
  1. 如果 symbolMethodDefinition,则返回 true
  2. 返回 MethodDefinition 带实参 symbolComputedPropertyContains 的结果。
LiteralPropertyName : IdentifierName
  1. 返回 false
MemberExpression : MemberExpression . IdentifierName
  1. 如果 MemberExpression Contains symboltrue,则返回 true
  2. 返回 false
SuperProperty : super . IdentifierName
  1. 如果 symbolReservedWord super,则返回 true
  2. 返回 false
CallExpression : CallExpression . IdentifierName
  1. 如果 CallExpression Contains symboltrue,则返回 true
  2. 返回 false
OptionalChain : ?. IdentifierName
  1. 返回 false
OptionalChain : OptionalChain . IdentifierName
  1. 如果 OptionalChain Contains symboltrue,则返回 true
  2. 返回 false

8.5.2 Static Semantics: ComputedPropertyContains

The syntax-directed operation ComputedPropertyContains takes argument symbol (a grammar symbol) and returns a Boolean. It is defined piecewise over the following productions:

ClassElementName : PrivateIdentifier PropertyName : LiteralPropertyName
  1. 返回 false
PropertyName : ComputedPropertyName
  1. 返回 ComputedPropertyName Contains symbol 的结果。
MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } get ClassElementName ( ) { FunctionBody } set ClassElementName ( PropertySetParameterList ) { FunctionBody }
  1. 返回 ClassElementName 带实参 symbolComputedPropertyContains 的结果。
GeneratorMethod : * ClassElementName ( UniqueFormalParameters ) { GeneratorBody }
  1. 返回 ClassElementName 带实参 symbolComputedPropertyContains 的结果。
AsyncGeneratorMethod : async * ClassElementName ( UniqueFormalParameters ) { AsyncGeneratorBody }
  1. 返回 ClassElementName 带实参 symbolComputedPropertyContains 的结果。
ClassElementList : ClassElementList ClassElement
  1. inListClassElementList 带实参 symbolComputedPropertyContains
  2. 如果 inListtrue,则返回 true
  3. 返回 ClassElement 带实参 symbolComputedPropertyContains 的结果。
ClassElement : ClassStaticBlock
  1. 返回 false
ClassElement : ;
  1. 返回 false
AsyncMethod : async ClassElementName ( UniqueFormalParameters ) { AsyncFunctionBody }
  1. 返回 ClassElementName 带实参 symbolComputedPropertyContains 的结果。
FieldDefinition : ClassElementName Initializeropt
  1. 返回 ClassElementName 带实参 symbolComputedPropertyContains 的结果。

8.6 杂项

这些操作在整个规范的多个地方使用。

8.6.1 Runtime Semantics: InstantiateFunctionObject

The syntax-directed operation InstantiateFunctionObject takes arguments envRecord (an Environment Record) and privateEnv (a PrivateEnvironment Record or null) and returns an ECMAScript function object. It is defined piecewise over the following productions:

FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } function ( FormalParameters ) { FunctionBody }
  1. 返回 FunctionDeclaration 带实参 envRecordprivateEnvInstantiateOrdinaryFunctionObject
GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } function * ( FormalParameters ) { GeneratorBody }
  1. 返回 GeneratorDeclaration 带实参 envRecordprivateEnvInstantiateGeneratorFunctionObject
AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } async function * ( FormalParameters ) { AsyncGeneratorBody }
  1. 返回 AsyncGeneratorDeclaration 带实参 envRecordprivateEnvInstantiateAsyncGeneratorFunctionObject
AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } async function ( FormalParameters ) { AsyncFunctionBody }
  1. 返回 AsyncFunctionDeclaration 带实参 envRecordprivateEnvInstantiateAsyncFunctionObject

8.6.2 Runtime Semantics: BindingInitialization

The syntax-directed operation BindingInitialization takes arguments value (an ECMAScript language value) and envRecord (an Environment Record or undefined) and returns either a normal completion containing unused or an abrupt completion.

Note

envRecord 传递 undefined 表示应使用 PutValue 操作来赋予初始化值。这适用于 var 语句和某些非严格函数的形式参数列表(参见 10.2.11)。在这些情况下,词法绑定会在其初始化器求值之前被提升并预初始化。

It is defined piecewise over the following productions:

BindingIdentifier : Identifier
  1. nameIdentifierStringValue
  2. 返回 ? InitializeBoundName(name, value, envRecord)。
BindingIdentifier : yield
  1. 返回 ? InitializeBoundName("yield", value, envRecord)。
BindingIdentifier : await
  1. 返回 ? InitializeBoundName("await", value, envRecord)。
BindingPattern : ObjectBindingPattern
  1. 执行 ? RequireObjectCoercible(value)。
  2. 返回 ? ObjectBindingPattern 带实参 valueenvRecordBindingInitialization
BindingPattern : ArrayBindingPattern
  1. iteratorRecord 为 ? GetIterator(value, sync)。
  2. resultCompletion(ArrayBindingPattern 带实参 iteratorRecordenvRecordIteratorBindingInitialization)。
  3. 如果 iteratorRecord.[[Done]]false,则返回 ? IteratorClose(iteratorRecord, result)。
  4. 返回 ? result
ObjectBindingPattern : { }
  1. 返回 unused
ObjectBindingPattern : { BindingPropertyList } { BindingPropertyList , }
  1. 执行 ? BindingPropertyList 带实参 valueenvRecordPropertyBindingInitialization
  2. 返回 unused
ObjectBindingPattern : { BindingRestProperty }
  1. excludedNames 为新的空 List
  2. 返回 ? BindingRestProperty 带实参 valueenvRecordexcludedNamesRestBindingInitialization
ObjectBindingPattern : { BindingPropertyList , BindingRestProperty }
  1. excludedNames 为 ? BindingPropertyList 带实参 valueenvRecordPropertyBindingInitialization
  2. 返回 ? BindingRestProperty 带实参 valueenvRecordexcludedNamesRestBindingInitialization

8.6.2.1 InitializeBoundName ( name, value, envRecord )

The abstract operation InitializeBoundName takes arguments name (a String), value (an ECMAScript language value), and envRecord (an Environment Record or undefined) and returns either a normal completion containing unused or an abrupt completion. It performs the following steps when called:

  1. 如果 envRecord 不是 undefined,则
    1. 执行 ! envRecord.InitializeBinding(name, value)。
    2. 返回 unused
  2. lhs 为 ? ResolveBinding(name)。
  3. 返回 ? PutValue(lhs, value)。

8.6.3 Runtime Semantics: IteratorBindingInitialization

The syntax-directed operation IteratorBindingInitialization takes arguments iteratorRecord (an Iterator Record) and envRecord (an Environment Record or undefined) and returns either a normal completion containing unused or an abrupt completion.

Note

当为 envRecord 传递 undefined 时,表示应使用 PutValue 操作来赋予初始化值。这适用于非严格函数的形式参数列表。在这种情况下,为了处理可能存在多个同名参数的情形,形式参数绑定会被预初始化。

It is defined piecewise over the following productions:

ArrayBindingPattern : [ ]
  1. 返回 unused
ArrayBindingPattern : [ Elision ]
  1. 返回 ? Elision 带实参 iteratorRecordIteratorDestructuringAssignmentEvaluation
ArrayBindingPattern : [ Elisionopt BindingRestElement ]
  1. 如果 Elision 存在,则
    1. 执行 ? Elision 带实参 iteratorRecordIteratorDestructuringAssignmentEvaluation
  2. 返回 ? BindingRestElement 带实参 iteratorRecordenvRecordIteratorBindingInitialization
ArrayBindingPattern : [ BindingElementList , Elision ]
  1. 执行 ? BindingElementList 带实参 iteratorRecordenvRecordIteratorBindingInitialization
  2. 返回 ? Elision 带实参 iteratorRecordIteratorDestructuringAssignmentEvaluation
ArrayBindingPattern : [ BindingElementList , Elisionopt BindingRestElement ]
  1. 执行 ? BindingElementList 带实参 iteratorRecordenvRecordIteratorBindingInitialization
  2. 如果 Elision 存在,则
    1. 执行 ? Elision 带实参 iteratorRecordIteratorDestructuringAssignmentEvaluation
  3. 返回 ? BindingRestElement 带实参 iteratorRecordenvRecordIteratorBindingInitialization
BindingElementList : BindingElementList , BindingElisionElement
  1. 执行 ? BindingElementList 带实参 iteratorRecordenvRecordIteratorBindingInitialization
  2. 返回 ? BindingElisionElement 带实参 iteratorRecordenvRecordIteratorBindingInitialization
BindingElisionElement : Elision BindingElement
  1. 执行 ? Elision 带实参 iteratorRecordIteratorDestructuringAssignmentEvaluation
  2. 返回 ? BindingElement 带实参 iteratorRecordenvRecordIteratorBindingInitialization
SingleNameBinding : BindingIdentifier Initializeropt
  1. bindingIdBindingIdentifierStringValue
  2. lhs 为 ? ResolveBinding(bindingId, envRecord)。
  3. vundefined
  4. 如果 iteratorRecord.[[Done]]false,则
    1. next 为 ? IteratorStepValue(iteratorRecord)。
    2. 如果 next 不是 done,则
      1. v 设置为 next
  5. 如果 Initializer 存在且 vundefined,则
    1. 如果 IsAnonymousFunctionDefinition(Initializer) 是 true,则
      1. v 设置为 ? Initializer 带实参 bindingIdNamedEvaluation
    2. 否则,
      1. defaultValue 为 ? InitializerEvaluation
      2. v 设置为 ? GetValue(defaultValue)。
  6. 如果 envRecordundefined,则返回 ? PutValue(lhs, v)。
  7. 返回 ? InitializeReferencedBinding(lhs, v)。
BindingElement : BindingPattern Initializeropt
  1. vundefined
  2. 如果 iteratorRecord.[[Done]]false,则
    1. next 为 ? IteratorStepValue(iteratorRecord)。
    2. 如果 next 不是 done,则
      1. v 设置为 next
  3. 如果 Initializer 存在且 vundefined,则
    1. defaultValue 为 ? InitializerEvaluation
    2. v 设置为 ? GetValue(defaultValue)。
  4. 返回 ? BindingPattern 带实参 venvRecordBindingInitialization
BindingRestElement : ... BindingIdentifier
  1. lhs 为 ? ResolveBinding(BindingIdentifierStringValue, envRecord)。
  2. array 为 ! ArrayCreate(0)。
  3. n 为 0。
  4. 重复,
    1. nextdone
    2. 如果 iteratorRecord.[[Done]]false,则
      1. next 设置为 ? IteratorStepValue(iteratorRecord)。
    3. 如果 nextdone,则
      1. 如果 envRecordundefined,则返回 ? PutValue(lhs, array)。
      2. 返回 ? InitializeReferencedBinding(lhs, array)。
    4. 执行 ! CreateDataPropertyOrThrow(array, ! ToString(𝔽(n)), next)。
    5. n 设置为 n + 1。
BindingRestElement : ... BindingPattern
  1. array 为 ! ArrayCreate(0)。
  2. n 为 0。
  3. 重复,
    1. nextdone
    2. 如果 iteratorRecord.[[Done]]false,则
      1. next 设置为 ? IteratorStepValue(iteratorRecord)。
    3. 如果 nextdone,则
      1. 返回 ? BindingPattern 带实参 arrayenvRecordBindingInitialization
    4. 执行 ! CreateDataPropertyOrThrow(array, ! ToString(𝔽(n)), next)。
    5. n 设置为 n + 1。
FormalParameters : [empty]
  1. 返回 unused
FormalParameters : FormalParameterList , FunctionRestParameter
  1. 执行 ? FormalParameterList 带实参 iteratorRecordenvRecordIteratorBindingInitialization
  2. 返回 ? FunctionRestParameter 带实参 iteratorRecordenvRecordIteratorBindingInitialization
FormalParameterList : FormalParameterList , FormalParameter
  1. 执行 ? FormalParameterList 带实参 iteratorRecordenvRecordIteratorBindingInitialization
  2. 返回 ? FormalParameter 带实参 iteratorRecordenvRecordIteratorBindingInitialization
ArrowParameters : BindingIdentifier
  1. vundefined
  2. 断言:iteratorRecord.[[Done]]false
  3. next 为 ? IteratorStepValue(iteratorRecord)。
  4. 如果 next 不是 done,则
    1. v 设置为 next
  5. 返回 ? BindingIdentifier 带实参 venvRecordBindingInitialization
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
  1. formalsCoverParenthesizedExpressionAndArrowParameterList覆盖的 ArrowFormalParameters
  2. 返回 ? formals 带实参 iteratorRecordenvRecordIteratorBindingInitialization
AsyncArrowBindingIdentifier : BindingIdentifier
  1. vundefined
  2. 断言:iteratorRecord.[[Done]]false
  3. next 为 ? IteratorStepValue(iteratorRecord)。
  4. 如果 next 不是 done,则
    1. v 设置为 next
  5. 返回 ? BindingIdentifier 带实参 venvRecordBindingInitialization

8.6.4 Static Semantics: AssignmentTargetType

The syntax-directed operation AssignmentTargetType takes no arguments and returns simple, web-compat, or invalid. It is defined piecewise over the following productions:

IdentifierReference : Identifier
  1. 如果 IsStrict(this IdentifierReference) 是 trueIdentifierStringValue"eval""arguments",则返回 invalid
  2. 返回 simple
IdentifierReference : yield await CallExpression : CallExpression [ Expression ] CallExpression . IdentifierName CallExpression . PrivateIdentifier MemberExpression : MemberExpression [ Expression ] MemberExpression . IdentifierName SuperProperty MemberExpression . PrivateIdentifier
  1. 返回 simple
PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. exprCoverParenthesizedExpressionAndArrowParameterList覆盖的 ParenthesizedExpression
  2. 返回 exprAssignmentTargetType
CallExpression : CoverCallExpressionAndAsyncArrowHead CallExpression Arguments
  1. 如果宿主是 Web 浏览器,或以其他方式支持 函数调用赋值目标的运行时错误,且 IsStrict(this CallExpression) 是 false,则
    1. 返回 web-compat
  2. 返回 invalid
PrimaryExpression : this Literal ArrayLiteral ObjectLiteral FunctionExpression ClassExpression GeneratorExpression AsyncFunctionExpression AsyncGeneratorExpression RegularExpressionLiteral TemplateLiteral CallExpression : SuperCall ImportCall 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 + UnaryExpression - UnaryExpression ~ UnaryExpression ! UnaryExpression CoverAwaitExpressionAndAwaitUsingDeclarationHead 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. 返回 invalid

8.6.5 Static Semantics: PropName

The syntax-directed operation PropName takes no arguments and returns a String or empty. It is defined piecewise over the following productions:

PropertyDefinition : IdentifierReference
  1. 返回 IdentifierReferenceStringValue
PropertyDefinition : ... AssignmentExpression
  1. 返回 empty
PropertyDefinition : PropertyName : AssignmentExpression
  1. 返回 PropertyNamePropName
LiteralPropertyName : IdentifierName AttributeKey : IdentifierName
  1. 返回 IdentifierNameStringValue
LiteralPropertyName : StringLiteral AttributeKey : StringLiteral
  1. 返回 StringLiteralSV
LiteralPropertyName : NumericLiteral
  1. numberNumericLiteralNumericValue
  2. 返回 ! ToString(number)。
ComputedPropertyName : [ AssignmentExpression ]
  1. 返回 empty
MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } get ClassElementName ( ) { FunctionBody } set ClassElementName ( PropertySetParameterList ) { FunctionBody }
  1. 返回 ClassElementNamePropName
GeneratorMethod : * ClassElementName ( UniqueFormalParameters ) { GeneratorBody }
  1. 返回 ClassElementNamePropName
AsyncGeneratorMethod : async * ClassElementName ( UniqueFormalParameters ) { AsyncGeneratorBody }
  1. 返回 ClassElementNamePropName
ClassElement : ClassStaticBlock
  1. 返回 empty
ClassElement : ;
  1. 返回 empty
AsyncMethod : async ClassElementName ( UniqueFormalParameters ) { AsyncFunctionBody }
  1. 返回 ClassElementNamePropName
FieldDefinition : ClassElementName Initializeropt
  1. 返回 ClassElementNamePropName
ClassElementName : PrivateIdentifier
  1. 返回 empty

8.6.6 Static Semantics: ContainsUsing

The syntax-directed operation ContainsUsing takes no arguments and returns Boolean. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. 如果派生的 StatementListContainsUsingtrue,则返回 true
  2. 如果 StatementListItemContainsUsingtrue,则返回 true
  3. 返回 false
StatementListItem : Statement
  1. 返回 false
StatementListItem : Declaration
  1. 如果 DeclarationIsUsingDeclarationtrue,则返回 true
  2. 如果 DeclarationIsAwaitUsingDeclarationtrue,则返回 true
  3. 返回 false