Embarrassingly Simple Spec Question

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Embarrassingly Simple Spec Question

T.J. Crowder-2
Hi all,

Embarrassingly, I'm struggling to follow the spec through a simple assignment expression. :-) If someone would bear with me and explain the below, I'd be very grateful.

I'm looking at a simple assignment: `x = y`. I have no trouble with the runtime semantics, but I'm having trouble with the syntax productions, specifically how `y` matches *AssignmentExpression*. Details of what (I think) I know and where I've gotten lost:

In [Assignment Operators][1], I can see that `x = y` is an [*AssignmentExpression*][2] matching the second-to-last bullet:

> *AssignmentExpression*:
>
> * *ConditionalExpression*
> * *YieldExpression*
> * *ArrowFunction*
> * *AsyncArrowFunction*
> * *LeftHandSideExpression* = *AssignmentExpression*
> * *LeftHandSideExpression* *AssignmentOperator* *AssignmentExpression*

So far so good. `x` would be the *LeftHandSideExpression* and `y` would be the *AssignmentExpression* in that production.

And I'm fine with `x`. `x` is a [*LeftHandSideExpression*][3] and I can follow through [*NewExpression*][4] to [*MemberExpression*][5] to [*PrimaryExpression*][6] to [*IdentifierReference*][7].

But looking at the syntax for *AssignmentExpression* above, I can't see how `y` matches it. `y` is an *IdentifierReference*, right? Starting from the six productions above, I can't get to *IdentifierReference*, or to any other production that seems to me to match `y`. It seems like *PrimaryExpression* should be on that list. But it isn't, and I'm sure it isn't for a reason.

It's a dead simple thing, clearly (and embarrassingly) there's just some fundamental point or concept I'm missing.

Thanks in advance,

-- T.J. Crowder


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Embarrassingly Simple Spec Question

Oriol _

I think it's


  1. AssignmentExpression (https://tc39.github.io/ecma262/#prod-AssignmentExpression)
  2. ConditionalExpression (https://tc39.github.io/ecma262/#prod-ConditionalExpression)
  3. LogicalORExpression (https://tc39.github.io/ecma262/#prod-LogicalORExpression)
  4. LogicalANDExpression (https://tc39.github.io/ecma262/#prod-LogicalANDExpression)
  5. BitwiseORExpression (https://tc39.github.io/ecma262/#prod-BitwiseORExpression)
  6. BitwiseXORExpression (https://tc39.github.io/ecma262/#prod-BitwiseXORExpression)
  7. BitwiseANDExpression (https://tc39.github.io/ecma262/#prod-BitwiseANDExpression)
  8. EqualityExpression (https://tc39.github.io/ecma262/#prod-EqualityExpression)
  9. RelationalExpression (https://tc39.github.io/ecma262/#prod-RelationalExpression)
  10. ShiftExpression (https://tc39.github.io/ecma262/#prod-ShiftExpression)
  11. AdditiveExpression (https://tc39.github.io/ecma262/#prod-AdditiveExpression)
  12. MultiplicativeExpression (https://tc39.github.io/ecma262/#prod-MultiplicativeExpression)
  13. ExponentiationExpression (https://tc39.github.io/ecma262/#prod-ExponentiationExpression)
  14. UnaryExpression (https://tc39.github.io/ecma262/#prod-UnaryExpression)
  15. UpdateExpression (https://tc39.github.io/ecma262/#prod-UpdateExpression)
  16. LeftHandSideExpression (https://tc39.github.io/ecma262/#prod-LeftHandSideExpression)
  17. NewExpression (https://tc39.github.io/ecma262/#prod-NewExpression)
  18. MemberExpression (https://tc39.github.io/ecma262/#prod-MemberExpression)
  19. PrimaryExpression (https://tc39.github.io/ecma262/#prod-PrimaryExpression)
  20. IdentifierReference (https://tc39.github.io/ecma262/#prod-IdentifierReference)
  21. Identifier (https://tc39.github.io/ecma262/#prod-Identifier)

Very obscure indeed.

-- Oriol

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Embarrassingly Simple Spec Question

T.J. Crowder-2
On Tue, May 22, 2018 at 11:03 AM, Oriol _ <[hidden email]> wrote:
> I think it's

Crikey. I started down that path but gave up after about seven steps on the assumption I *had* to be going down a blind alley. Teach me not to stick it out. I guess there must be some good reason not to include *PrimaryExpression* in *AssignmentExpression* directly (ambiguity or some such).

**Thanks!!**

-- T.J. Crowder

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Embarrassingly Simple Spec Question

Isiah Meadows-2
That's the usual means of specifying precedence in anything remotely
like BNF. ;-)

(IIUC It *could* be duplicated in *PrimaryExpression*, but it'd just
get unruly real quick if you were to try to expand everything.)

-----

Isiah Meadows
[hidden email]
www.isiahmeadows.com


On Tue, May 22, 2018 at 7:09 AM, T.J. Crowder
<[hidden email]> wrote:

> On Tue, May 22, 2018 at 11:03 AM, Oriol _ <[hidden email]>
> wrote:
>> I think it's
>
> Crikey. I started down that path but gave up after about seven steps on the
> assumption I *had* to be going down a blind alley. Teach me not to stick it
> out. I guess there must be some good reason not to include
> *PrimaryExpression* in *AssignmentExpression* directly (ambiguity or some
> such).
>
> **Thanks!!**
>
> -- T.J. Crowder
>
> _______________________________________________
> es-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Embarrassingly Simple Spec Question

T.J. Crowder-2
On Wed, May 23, 2018 at 1:29 PM, Isiah Meadows <[hidden email]> wrote:
> That's the usual means of specifying precedence in anything remotely
> like BNF. ;-)
>
> (IIUC It *could* be duplicated in *PrimaryExpression*, but it'd just
> get unruly real quick if you were to try to expand everything.)

Yeah, this is just a weak area for me. Apologies all. I should have just kept clicking, but when I got to *BitwiseXORExpression* I figured I *had* to be off-piste. ;-)

-- T.J. Crowder

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss