Re: Incorrect definition of expressions in grammar

From: Date: Fri, 19 Sep 2014 21:37:39 +0000
Subject: Re: Incorrect definition of expressions in grammar
References: 1  Groups: php.standards 
Request: Send a blank email to standards-+get-454@lists.php.net to get a copy of this message
ken Koch wrote: > Looking through the grammar spec and expressions definitions i noticed > a naming inconsistency that causes some problems in the grammar. > > The problem is around the expression for instance: > > primary-expression: > variable-name > qualified-name > literal > const-expression > intrinsic > anonymous-function-creation-expression > ( expression ) > $this > > The definition of the expression production is given later > under > "script inclusion operators": > > expression: > yield-expression > include-expression > include-once-expression > require-expression > require-once-expression > > My suggestion is that the expression symbol under "script > inclusion > operators" be renamed to script-inclusion-expression and > all > references to expression in the context of primary expressions > be > renamed to primary-expression. > > Not sure if i am misinterpreting it there but it seems to make much > more sense to me that way. I wanted to get the lists opinion before > putting it together in a PR. Replacing "expression" in "primary-expression" with "primary-expression" would be wrong -- at least it would make PHP pretty useless. As it is now, the grammar seems to be correct, but I agree that it it somewhat confusing to define | yield-expression: | logical-inc-OR-expression-2 | yield array-element-initializer especially considering the specified semantics: | Any function containing a yield-expression is a generator function. That makes nearly every function a generator function. It might be better to define expression: logical-inc-OR-expression-2 yield-expression include-expression include-once-expression require-expression require-once-expression yield-expression: yield array-element-initializer BTW: the following[1] | Except for the difference in precedence, operator and has exactly the ^^^ | same semantics as operator ||. should be Except for the difference in precedence, operator or has exactly the ^^ same semantics as operator ||. [1] <https://github.com/php/php-langspec/blob/master/spec/10-expressions.md#user-content-logical-inclusive-or-operator-form-2> -- Christoph M. Becker

« previous php.standards (#454) next »