Skip to content
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

instanceof-subject and instanceof-type-designator cannot be expression #202

Closed
Hywan opened this issue Sep 17, 2017 · 3 comments
Closed

Comments

@Hywan
Copy link
Contributor

Hywan commented Sep 17, 2017

If I read the grammar correctly, instanceof is defined as follow:

instanceof-expression:
   unary-expression
   instanceof-subject   instanceof   instanceof-type-designator

instanceof-subject:
   expression

instanceof-type-designator:
   qualified-name
   expression

But expression is defined as:

expression:
   yield-expression
   include-expression
   include-once-expression
   require-expression
   require-once-expression

So it does not make sense. Maybe instace of expression we should use primary-expression (but even not really) or assignment (or thinner):

  instanceof-subject:
-    expression
+    assignment

  instanceof-type-designator:
     qualified-name
-    expression
+    assignement

Thoughts?

@nikic
Copy link
Member

nikic commented Sep 17, 2017

There is no assignment production, did you mean variable? That would be better than what we have right now, though it's not entirely correct. The RHS of instanceof is a "new variable", which is a slightly restricted form of "variable", which is currently not the grammar :/

@mattacosta
Copy link

mattacosta commented Sep 18, 2017

If I remember PHP's grammar correctly, "new variable" was actually very restricted. To the point where it is basically just something like:

instanceof-type-designator:
  qualified-name
  new-variable

new-variable
  simple-variable
  qualified-name :: simple-variable
  new-variable [ expression<sub>opt</sub> ]
  new-variable { expression }
  new-variable -> member-name
  new-variable :: simple-variable

@Hywan
Copy link
Contributor Author

Hywan commented Sep 19, 2017

It sounds a little bit complicated… The PHP grammar has so much different nodes…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants