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], I can see that `x = y` is an [*AssignmentExpression*] matching the second-to-last bullet:
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*] and I can follow through [*NewExpression*] to [*MemberExpression*] to [*PrimaryExpression*] to [*IdentifierReference*].
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.
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).
> On Tue, May 22, 2018 at 11:03 AM, Oriol _ <[hidden email]>
>> 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
> -- T.J. Crowder
> es-discuss mailing list
> [hidden email] > https://mail.mozilla.org/listinfo/es-discuss >
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. ;-)