What's a valid left-hand-side expression in JavaScript grammar?

前端 未结 2 1101
挽巷
挽巷 2020-11-29 23:31

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

2条回答
  •  悲哀的现实
    2020-11-30 00:03

    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.

提交回复
热议问题