php / php-langspec

PHP Language Specification
http://www.php.net
Other
2.3k stars 271 forks source link

Confused by `clone-expression` definition #261

Closed ramsey closed 8 months ago

ramsey commented 8 months ago

The clone-expression is defined as:

clone-expression:
   primary-expression
   clone   primary-expression

I don't understand how to read this. A clone-expression can be primary-expression or 'clone' primary-expression?

Is this a mistake? Should it be the following instead (note the use of recursively using clone-expression)?

clone-expression:
   primary-expression
   clone   clone-expression
ramsey commented 8 months ago

Or maybe it's meant to save space by collapsing a few things, since I see clone-expression is also used in exponentiation-expression:

exponentiation-expression:
   clone-expression
   clone-expression   **   exponentiation-expression

Is it trying to express this in a more compact way?

clone-expression:
   clone   primary-expression

exponentiation-expression:
   primary_expression
   clone_expression
   primary_expression   **   exponentiation-expression
   clone_expression   **   exponentiation-expression
nikic commented 8 months ago

This is how operator precedence is specified.