Why specify a separate production for the assignment operator with `=` literal instead of the symbol `AssignmentOperator`

The EcmaScript grammar for AssignmentExpression states the following:

AssignmentExpression :
    ConditionalExpression
    YieldExpression
    ArrowFunction
    AsyncArrowFunction
    LeftHandSideExpression = AssignmentExpression                     <-------------- here
    LeftHandSideExpression AssignmentOperator AssignmentExpression

AssignmentOperator : one of
    *= /= %= += -= <<= >>= >>>= &= ^= |= **=

I wonder what is the point of defining it LeftHandSideExpression = AssignmentExpressionas a separate production instead of just including it =in AssignmentOperator?

+4
source share
1 answer

The grammar will be completely equivalent if the two derivatives were combined.

, -. , " " , " ", = production.

, , , , , "LeftHandSideExpression AssignmentOperator AssignmentExpression, AssignmentOperator =".

, , , , .

+4

Source: https://habr.com/ru/post/1687483/


All Articles