com php-langspec: Fix precedence of instanceof/logical not: spec/00-specification-for-php.md spec/10-expressions.md spec/19-grammar.md

From: Date: Tue, 19 Sep 2017 07:31:35 +0000
Subject: com php-langspec: Fix precedence of instanceof/logical not: spec/00-specification-for-php.md spec/10-expressions.md spec/19-grammar.md
Groups: php.standards.cvs 
Request: Send a blank email to standards--cvs+get-393@lists.php.net to get a copy of this message
Commit: 714f68927038ece7e8f5f0a2bbce04a8c600eb25 Author: Nikita Popov <nikic@php.net> Tue, 19 Sep 2017 09:31:35 +0200 Parents: 7d6ae475928a67c706aeaec8c131bed9567aafed Branches: master Link: http://git.php.net/?p=php-langspec.git;a=commitdiff;h=714f68927038ece7e8f5f0a2bbce04a8c600eb25 Log: Fix precedence of instanceof/logical not Fixes #189. Bugs: https://bugs.php.net/189 Changed paths: M spec/00-specification-for-php.md M spec/10-expressions.md M spec/19-grammar.md Diff: diff --git a/spec/00-specification-for-php.md b/spec/00-specification-for-php.md index fb7fe9b..3fb4db0 100644 --- a/spec/00-specification-for-php.md +++ b/spec/00-specification-for-php.md @@ -134,6 +134,7 @@ is distributed without any warranty. - [Shell Command Operator](10-expressions.md#shell-command-operator) - [Cast Operator](10-expressions.md#cast-operator) - [instanceof Operator](10-expressions.md#instanceof-operator) + - [Logical NOT Operator](10-expressions.md#logical-not-operator) - [Multiplicative Operators](10-expressions.md#multiplicative-operators) - [Additive Operators](10-expressions.md#additive-operators) - [Bitwise Shift Operators](10-expressions.md#bitwise-shift-operators) diff --git a/spec/10-expressions..md b/spec/10-expressions.md index cfae203..f854436 100644 --- a/spec/10-expressions.md +++ b/spec/10-expressions.md @@ -1993,7 +1993,7 @@ unary-op-expression: unary-operator unary-expression unary-operator: one of - '+' '-' '!' '~' + '+' '-' '~' --> <pre> @@ -2001,7 +2001,7 @@ unary-operator: one of <i><a href="#grammar-unary-operator">unary-operator</a></i> <i><a href="#grammar-unary-expression">unary-expression</a></i> <i id="grammar-unary-operator">unary-operator: one of</i> - + - ! ~ + + - ~ </pre> **Constraints** @@ -2013,10 +2013,6 @@ an object supporting ~. **Semantics** -For a unary ! operator the type of the result is bool. -The value of the operand is [converted to type bool](08-conversions.md#converting-to-boolean-type) -and if it is TRUE then the of the operator result is FALSE, and the result is TRUE otherwise. - *Arithmetic Operands* For a unary + operator used with an arithmetic operand, the type and @@ -2073,8 +2069,6 @@ and for + and - the object is [converted to int](08-conversions.md#convert ```PHP $v = +10; if ($v1 > -5) // ... -$t = TRUE; -if (!$t) // ... $v = ~0b1010101; $s = "\x86\x97"; $s = ~$s; // $s is "yh" ``` @@ -2300,24 +2294,50 @@ $e2 = new E1; var_dump($e2 instanceof $e1); // TRUE ``` +## Logical NOT Operator + +<!-- GRAMMAR +logical-NOT-expression: + instanceof-expression + '!' instanceof-expression +--> + +<pre> +<i id="grammar-logical-NOT-expression">logical-NOT-expression:</i> + <i><a href="#grammar-instanceof-expression">instanceof-expression</a></i> + ! <i><a href="#grammar-instanceof-expression">instanceof-expression</a></i> +</pre> + +**Semantics** + +The value of the operand is [converted to type bool](08-conversions.md#converting-to-boolean-type) +and if it is TRUE then the result of the operator is FALSE. The result is TRUE otherwise. + +**Examples** + +```PHP +$t = TRUE; +if (!$t) // ... +``` + ## Multiplicative Operators **Syntax** <!-- GRAMMAR multiplicative-expression: - instanceof-expression - multiplicative-expression '*' instanceof-expression - multiplicative-expression '/' instanceof-expression - multiplicative-expression '%' instanceof-expression + logical-NOT-expression + multiplicative-expression '*' logical-NOT-expression + multiplicative-expression '/' logical-NOT-expression + multiplicative-expression '%' logical-NOT-expression --> <pre> <i id="grammar-multiplicative-expression">multiplicative-expression:</i> - <i><a href="#grammar-instanceof-expression">instanceof-expression</a></i> - <i><a href="#grammar-multiplicative-expression">multiplicative-expression</a></i> * <i><a href="#grammar-instanceof-expression">instanceof-expression</a></i> - <i><a href="#grammar-multiplicative-expression">multiplicative-expression</a></i> / <i><a href="#grammar-instanceof-expression">instanceof-expression</a></i> - <i><a href="#grammar-multiplicative-expression">multiplicative-expression</a></i> % <i><a href="#grammar-instanceof-expression">instanceof-expression</a></i> + <i><a href="#grammar-logical-NOT-expression">logical-NOT-expression</a></i> + <i><a href="#grammar-multiplicative-expression">multiplicative-expression</a></i> * <i><a href="#grammar-logical-NOT-expression">logical-NOT-expression</a></i> + <i><a href="#grammar-multiplicative-expression">multiplicative-expression</a></i> / <i><a href="#grammar-logical-NOT-expression">logical-NOT-expression</a></i> + <i><a href="#grammar-multiplicative-expression">multiplicative-expression</a></i> % <i><a href="#grammar-logical-NOT-expression">logical-NOT-expression</a></i> </pre> **Constraints** diff --git a/spec/19-grammar.md b/spec/19-grammar.md index 08f7ac3..06fcb02 100644 --- a/spec/19-grammar.md +++ b/spec/19-grammar.md @@ -583,7 +583,7 @@ The grammar notation is described in [Grammars section](09-lexical-structure.md# <i><a href="#grammar-unary-operator">unary-operator</a></i> <i><a href="#grammar-unary-expression">unary-expression</a></i> <i id="grammar-unary-operator">unary-operator: one of</i> - + - ! ~ + + - ~ <i id="grammar-error-control-expression">error-control-expression:</i> @ <i><a href="#grammar-expression">expression</a></i> @@ -605,11 +605,15 @@ The grammar notation is described in [Grammars section](09-lexical-structure.md# <i id="grammar-instanceof-subject">instanceof-subject:</i> <i><a href="#grammar-expression">expression</a></i> -<i id="grammar-multiplicative-expression">multiplicative-expression:</i> +<i id="grammar-logical-NOT-expression">logical-NOT-expression:</i> <i><a href="#grammar-instanceof-expression">instanceof-expression</a></i> - <i><a href="#grammar-multiplicative-expression">multiplicative-expression</a></i> * <i><a href="#grammar-instanceof-expression">instanceof-expression</a></i> - <i><a href="#grammar-multiplicative-expression">multiplicative-expression</a></i> / <i><a href="#grammar-instanceof-expression">instanceof-expression</a></i> - <i><a href="#grammar-multiplicative-expression">multiplicative-expression</a></i> % <i><a href="#grammar-instanceof-expression">instanceof-expression</a></i> + ! <i><a href="#grammar-instanceof-expression">instanceof-expression</a></i> + +<i id="grammar-multiplicative-expression">multiplicative-expression:</i> + <i><a href="#grammar-logical-NOT-expression">logical-NOT-expression</a></i> + <i><a href="#grammar-multiplicative-expression">multiplicative-expression</a></i> * <i><a href="#grammar-logical-NOT-expression">logical-NOT-expression</a></i> + <i><a href="#grammar-multiplicative-expression">multiplicative-expression</a></i> / <i><a href="#grammar-logical-NOT-expression">logical-NOT-expression</a></i> + <i><a href="#grammar-multiplicative-expression">multiplicative-expression</a></i> % <i><a href="#grammar-logical-NOT-expression">logical-NOT-expression</a></i> <i id="grammar-additive-expression">additive-expression:</i> <i><a href="#grammar-multiplicative-expression">multiplicative-expression</a></i>

« previous php.standards.cvs (#393) next »