什么是EcmaScript语法中的[Yield,Await,In,Return] [英] What are [Yield, Await, In, Return] in EcmaScript grammar

查看:375
本文介绍了什么是EcmaScript语法中的[Yield,Await,In,Return]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

EcmaScript中的许多作品都带有以下修饰符:

Many productions in EcmaScript are given with the following "modifiers":

[Yield, Await, In, Return]

以下是一些例子:

ArrayLiteral[Yield, Await]:
  ...

ElementList[Yield, Await]:
 ... AssignmentExpression[+In, ?Yield, ?Await]

我在规范中搜索了解释,特别是语法符号部分,但找不到它。应该在那里。有人可以请我指出相关段落并提供一个简短的解释吗?

I've searched through the spec for the explanation, specifically Grammar Notation section, but can't find it. It should be there. Can someone please point me to the relevant paragraph and maybe provide a short explanation?

推荐答案

第5.1.5节:语法符号 -


可以通过[parameters]形式的下标注释来参数化生产,该注释可以显示为生产定义的非终结符号的后缀。 参数可以是单个名称,也可以是逗号分隔的名称列表。参数化生产是一组生产的简写,这些生产定义参数名称的所有组合,前面带有下划线,附加到参数化的非终结符号。这意味着:

A production may be parameterized by a subscripted annotation of the form "[parameters]", which may appear as a suffix to the nonterminal symbol defined by the production. "parameters" may be either a single name or a comma separated list of names. A parameterized production is shorthand for a set of productions defining all combinations of the parameter names, preceded by an underscore, appended to the parameterized nonterminal symbol. This means that:


StatementList[Return]:
   ReturnStatement
   ExpressionStatement

是一个方便的缩写:


StatementList:
   ReturnStatement
   ExpressionStatement
StatementList_Return:
   ReturnStatement
   ExpressionStatement

and that:


StatementList[Return, In]:
   ReturnStatement
   ExpressionStatement

是以下缩写:


StatementList:
   ReturnStatement
   ExpressionStatement
StatementList_Return:
   ReturnStatement
   ExpressionStatement
StatementList_In:
   ReturnStatement
   ExpressionStatement
StatementList_Return_In:
   ReturnStatement
   ExpressionStatement

多个参数会产生多个组合的制作,而不是所有的制作h必须用完整的语法引用。

Multiple parameters produce a combinatory number of productions, not all of which are necessarily referenced in a complete grammar.

从那里开始讨论参数化右侧,添加opt等等。

It continues from there talking about parameterizing right-hand sides, adding "opt", etc.

(搜索时,不要只查找 [返回] 等等,特别是通常会出现在 [收益率,等待,返回] 等组中?[?收益率,?Await,?返回] Block 的语法。)

(When searching, don't just look for [Return] and such specifically, as they can and usually do appear in groups like [Yield, Await, Return] and [?Yield, ?Await, ?Return] as in the syntax for Block.)

第12.1.1节:标识符 - 静态语义:早期错误 -


如果此产品具有[ Identifier的Yield]参数和StringValue是yield。

It is a Syntax Error if this production has a [Yield] parameter and StringValue of Identifier is "yield".

如果此生产具有[Await]参数且Identifier的StringValue为await,则为语法错误。

It is a Syntax Error if this production has an [Await] parameter and StringValue of Identifier is "await".

第12.10节:关系运算符 -


需要[In]语法参数以避免混淆运算符在运算符中的运算符,运算符在中为声明。

The [In] grammar parameter is needed to avoid confusing the in operator in a relational expression with the in operator in a for statement.

这篇关于什么是EcmaScript语法中的[Yield,Await,In,Return]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆