New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too sparse production-rules for AssignmentExpression? #344

Closed
RaoulSchaffranek opened this Issue Feb 1, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@RaoulSchaffranek

RaoulSchaffranek commented Feb 1, 2016

Hi everybody,
i just tried to derive the simple expression (x => x) from EcmaScript2015/16 syntax rules, what i thought should be an easy excercise. There is also a test case that covers a similar construct. However, if i'm not overseeing something crucial, then i must conclude that these expressions cannot be derieved from the official production rules. So, here is my naive approach:

PrimaryExpression →
CoverParenthesizedExpressionAndArrowParameterList →
(Expression) →
(AssignmentExpression) →
(ArrowFunction) →
(ArrowParameters => ConciseBody) →
(ArrowParameters => AssignmentExpression) → ???

The problem here is that i cannot derive an IdentifierReference from an AssignmentExpression. The only production rules i could take from here, are:

AssignmentExpression[In, Yield]:
  ConditionalExpression[?In, ?Yield]
  [+Yield]YieldExpression[?In]
  ArrowFunction[?In, ?Yield]
  LeftHandSideExpression[?Yield] = AssignmentExpression[?In, ?Yield]
  LeftHandSideExpression[?Yield] AssignmentOperator AssignmentExpression[?In, ?Yield]

I'm filing this here, becuase i think that this dilemma has even more implications. For example, even x = 42 is not a valid AssignmentExpression, which does'nt seem to capture the correct idea.

@zenparsing

This comment has been minimized.

Show comment
Hide comment
@zenparsing

zenparsing Feb 1, 2016

Contributor

Looks like the rule PostfixExpression : LeftHandSideExpression is missing from the grammar summary section. Is this a problem with emu-prodref?

Contributor

zenparsing commented Feb 1, 2016

Looks like the rule PostfixExpression : LeftHandSideExpression is missing from the grammar summary section. Is this a problem with emu-prodref?

@zenparsing

This comment has been minimized.

Show comment
Hide comment
@zenparsing

zenparsing Feb 1, 2016

Contributor

Same issue for YieldExpression in the grammar summary. It's linking to the first occurrence of YieldExpression which happens to be in the "restricted grammar rules" section (and where it's only showing the NLTH rules).

Contributor

zenparsing commented Feb 1, 2016

Same issue for YieldExpression in the grammar summary. It's linking to the first occurrence of YieldExpression which happens to be in the "restricted grammar rules" section (and where it's only showing the NLTH rules).

@RaoulSchaffranek

This comment has been minimized.

Show comment
Hide comment
@RaoulSchaffranek

RaoulSchaffranek Feb 1, 2016

Indeed, with PostfixExpression : LeftHandSideExpression it becomes possible to derive (x => x) with the following sequence:

PrimaryExpression →
CoverParenthesizedExpressionAndArrowParameterList →
(Expression) →
(AssignmentExpression) →
(ArrowFunction) →
(ArrowParameters => ConciseBody) →
(ArrowParameters => AssignmentExpression)  →
(ArrowParameters => ConditionalExpression)  →
(ArrowParameters => LogicalORExpression)  →
(ArrowParameters => LogicalANDExpression) →
(ArrowParameters => BitwiseORExpression) →
(ArrowParameters => BitwiseXORExpression) →
(ArrowParameters => BitwiseANDExpression) →
(ArrowParameters => EqualityExpression) →
(ArrowParameters => RelationalExpression) →
(ArrowParameters => ShiftExpression) →
(ArrowParameters => AdditiveExpression) →
(ArrowParameters => MultiplicativeExpression) →
(ArrowParameters => UnaryExpression) →
(ArrowParameters => PostfixExpression) →
(ArrowParameters => LeftHandSideExpression) →
(ArrowParameters => NewExpression) →
(ArrowParameters => MemberExpression) →
(ArrowParameters => PrimaryExpression) →
(ArrowParameters => IdentifierReference) →
(ArrowParameters => Identifier) →
(ArrowParameters => IdentifierName) →
(ArrowParameters => IdentifierStart) →
(ArrowParameters => UnicodeIDStart) →
(ArrowParameters => x) →
(BindingIdentifier => x) →
(Identifier => x) →
(IdentifierName => x) →
(IdentifierStart => x) →
(UnicodeIDStart => x) →
(x => x)

Awkwardly verbose, but it works.
Thanks @zenparsing

RaoulSchaffranek commented Feb 1, 2016

Indeed, with PostfixExpression : LeftHandSideExpression it becomes possible to derive (x => x) with the following sequence:

PrimaryExpression →
CoverParenthesizedExpressionAndArrowParameterList →
(Expression) →
(AssignmentExpression) →
(ArrowFunction) →
(ArrowParameters => ConciseBody) →
(ArrowParameters => AssignmentExpression)  →
(ArrowParameters => ConditionalExpression)  →
(ArrowParameters => LogicalORExpression)  →
(ArrowParameters => LogicalANDExpression) →
(ArrowParameters => BitwiseORExpression) →
(ArrowParameters => BitwiseXORExpression) →
(ArrowParameters => BitwiseANDExpression) →
(ArrowParameters => EqualityExpression) →
(ArrowParameters => RelationalExpression) →
(ArrowParameters => ShiftExpression) →
(ArrowParameters => AdditiveExpression) →
(ArrowParameters => MultiplicativeExpression) →
(ArrowParameters => UnaryExpression) →
(ArrowParameters => PostfixExpression) →
(ArrowParameters => LeftHandSideExpression) →
(ArrowParameters => NewExpression) →
(ArrowParameters => MemberExpression) →
(ArrowParameters => PrimaryExpression) →
(ArrowParameters => IdentifierReference) →
(ArrowParameters => Identifier) →
(ArrowParameters => IdentifierName) →
(ArrowParameters => IdentifierStart) →
(ArrowParameters => UnicodeIDStart) →
(ArrowParameters => x) →
(BindingIdentifier => x) →
(Identifier => x) →
(IdentifierName => x) →
(IdentifierStart => x) →
(UnicodeIDStart => x) →
(x => x)

Awkwardly verbose, but it works.
Thanks @zenparsing

@bterlson bterlson closed this Feb 18, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment