有人能解释一下为什么 for, while, do-while 语句的语法定义 header 中的条件部分是 "Expression"
can someone explain me why the grammar of for, while, do-while statement define that the condition part within the header is an "Expression"
谁能给我解释一下为什么 for, while, do-while statement's define that the condition part within the header is an "Expression" 的语法,谁能给我解释一下下面的东西是什么意思
Expression[In, Yield, Await] :
AssignmentExpression[?In, ?Yield, ?Await]
Expression[?In, ?Yield, ?Await] , AssignmentExpression[?In, ?Yield, ?Await]
如您所见,for-statement, while-statement, do-while statement
的 header 中没有 Literal at the right hand side after the non-terminal Expression[In, Yield, Await] :
but still it's possible to write literals
for (var i = 0; null; i ++) {
/* ^^^^ */
/* null */
}
while (null) {
/* ^^^^ */
/* null */
}
do {} while (null) ;
/* ^^^^ */
/* null */
也可以写 function expressions within the header of those statement's even though FunctionExpression 不存在于 non-terminal Expression[In, Yield, Await] :
的右侧
for (var i = 0; function () {}; i ++) ;
/* ^^^^^^^^^^^^^^ */
/* functionExpr */
while (function () {}) ;
/* ^^^^^^^^^^^^^^ */
/* functionExpr */
do ; while (function () {}) ;
/* ^^^^^^^^^^^^^^ */
/* functionExpr */
我在文档中进行了一些搜索,但我发现的是(总结):
Expression:
AssignmentExpression
然后,除其他外:
AssignmentExpression:
LeftHandSideExpression
所以我们可以深入嵌套:
LeftHandSideExpression:
NewExpression
NewExpression:
MemberExpression
MemberExpression:
PrimaryExpression
并发现 PrimaryExpression 包含许多其他项,还有 Literal 和 FunctionExpression:
PrimaryExpression[Yield, Await]:
this
IdentifierReference[?Yield, ?Await]
Literal
ArrayLiteral[?Yield, ?Await]
ObjectLiteral[?Yield, ?Await]
FunctionExpression
ClassExpression[?Yield, ?Await]
GeneratorExpression
AsyncFunctionExpression
AsyncGeneratorExpression
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
希望我的回答够清楚,能解开你的疑惑
谁能给我解释一下为什么 for, while, do-while statement's define that the condition part within the header is an "Expression" 的语法,谁能给我解释一下下面的东西是什么意思
Expression[In, Yield, Await] :
AssignmentExpression[?In, ?Yield, ?Await]
Expression[?In, ?Yield, ?Await] , AssignmentExpression[?In, ?Yield, ?Await]
如您所见,for-statement, while-statement, do-while statement
Expression[In, Yield, Await] :
but still it's possible to write literals
for (var i = 0; null; i ++) {
/* ^^^^ */
/* null */
}
while (null) {
/* ^^^^ */
/* null */
}
do {} while (null) ;
/* ^^^^ */
/* null */
也可以写 function expressions within the header of those statement's even though FunctionExpression 不存在于 non-terminal Expression[In, Yield, Await] :
的右侧
for (var i = 0; function () {}; i ++) ;
/* ^^^^^^^^^^^^^^ */
/* functionExpr */
while (function () {}) ;
/* ^^^^^^^^^^^^^^ */
/* functionExpr */
do ; while (function () {}) ;
/* ^^^^^^^^^^^^^^ */
/* functionExpr */
我在文档中进行了一些搜索,但我发现的是(总结):
Expression:
AssignmentExpression
然后,除其他外:
AssignmentExpression:
LeftHandSideExpression
所以我们可以深入嵌套:
LeftHandSideExpression:
NewExpression
NewExpression:
MemberExpression
MemberExpression:
PrimaryExpression
并发现 PrimaryExpression 包含许多其他项,还有 Literal 和 FunctionExpression:
PrimaryExpression[Yield, Await]:
this
IdentifierReference[?Yield, ?Await]
Literal
ArrayLiteral[?Yield, ?Await]
ObjectLiteral[?Yield, ?Await]
FunctionExpression
ClassExpression[?Yield, ?Await]
GeneratorExpression
AsyncFunctionExpression
AsyncGeneratorExpression
RegularExpressionLiteral
TemplateLiteral[?Yield, ?Await, ~Tagged]
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
希望我的回答够清楚,能解开你的疑惑