问题描述
我试图证明一个简单的函数调用,例如
I'm trying to prove that a simple function call such as
window.alert();
是有效的EcmaScript 2016(第7版)语法.往后看,期望这是一个 ExpressionStatement ,我发现它符合 MemberExpression Arguments 模式,即 CallExpression .并且, 12.3 部分将 LeftHandSideExpression 定义为 CallExpression .现在,我的问题是, 12.15 部分 AssignmentExpression 似乎要求 LeftHandSideExpression 后跟 AssignmentExpression 或 AssignmentOperator 和 AssignmentExpression 不能为;
is valid EcmaScript 2016 (7th Edition) grammar. Working backward, with the expectation this is an ExpressionStatement, I see that it fits the pattern MemberExpression Arguments which is a CallExpression. And, section 12.3 defines LeftHandSideExpression as possibly a CallExpression. Now, my problem is that section 12.15 AssignmentExpression seems to require that LeftHandSideExpression be followed by either an AssignmentExpression or an AssignmentOperator and AssignmentExpression cannot be ;
我可能缺少一些简单的东西.方向将不胜感激.
I'm probably missing something simple. Direction will be greatly appreciated.
推荐答案
一个 AssignmentExpression 不一定需要是一个赋值,它仅表示一个赋值可以站在这里".它也可以只包含一个 ConditionalExpression .现在,我们需要深入整个关联性规则链:
ConditionalExpression 可以包含一个三元运算符,或仅由 LogicalORExpression 组成. LogicalORExpression 可以包含一个 |||
运算符或仅由 LogicalANDExpression 组成.依此类推: LogicalANDExpression 只能由 BitwiseORExpression 只能由 BitwiseXORExpression 组成只能由 BitwiseANDExpression 只能由 EqualityExpression组成 只能由 RelationalExpression 可以仅由 ShiftExpression 可以仅由 AdditiveExpression 可以仅包含一个 MultiplicativeExpression 可以包括仅 ExponentiationExpression 即可仅由 UnaryExpression 组成它只能由 UpdateExpression 组成.
An AssignmentExpression does not necessarily need to be an assignment, it only means "an assignment could stand here". It can also consist of solely a ConditionalExpression. And now we need to go down the whole chain of associativity rules:
A ConditionalExpression can contain a ternary operator or consist solely of a LogicalORExpression. A LogicalORExpression can contain an ||
operator or consist solely of a LogicalANDExpression. And so on: A LogicalANDExpression can consist solely of a BitwiseORExpression which can consist of solely a BitwiseXORExpression which can consist of solely a BitwiseANDExpression which can consist of solely an EqualityExpression which can consist of solely a RelationalExpression which can consist of solely a ShiftExpression which can consist of solely an AdditiveExpression which can consist of solely a MultiplicativeExpression which can consist of solely an ExponentiationExpression which can consist of solely a UnaryExpression which can consist of solely an UpdateExpression.
最终可以包含 LeftHandSideExpression 我们正在照顾.
Which finally can consist of the LeftHandSideExpression that we were looking after.
这篇关于JavaScript函数是否调用了LeftHandSideExpression,从而调用了ExpressionStatement?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!