Okay, we all know what the valid left-hand-side expressions are. Kind of.*
But, looking at the definition from the ECMA-Script standard, I\'m very c
This is an alternative JavaScript grammar which only will match valid LeftHandSideExpressions, that is, LeftHandSideExpressions that are actually assignable.
NewExpression :
PrimaryExpression
new NewExpressionQualifier Arguments
new NewExpressionQualifier
NewExpressionQualifier :
NewExpressionQualifier Qualifier
NewExpression
CallExpression :
NewExpression
CallExpressionQualifier Arguments
CallExpressionQualifier :
CallExpression
CallExpressionQualifier Qualifier
LeftHandSideExpression :
LeftHandSideExpression Qualifier
CallExpression Qualifier
Identifier
( LeftHandSideExpression )
( Expression , LeftHandSideExpression )
Qualifier :
. IdentifierName
[ Expression ]
Each Arguments for which the choice of associated new or call expression is ambiguous shall be associated with the nearest possible new expression that would otherwise have no corresponding Arguments. I think this is one of the reasons why there is both a NewExpression and a MemberExpression nonterminal in the JavaScript grammar.