Skip to content

Commit b76c048

Browse files
authored
Merge pull request #13138 from ethereum/cheatsheet-shared-operator-list
Operator precedence table shared between Cheatsheet and Operators
2 parents f2eada1 + 1ab84bb commit b76c048

File tree

3 files changed

+59
-59
lines changed

3 files changed

+59
-59
lines changed

docs/cheatsheet.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ Cheatsheet
66

77
Order of Precedence of Operators
88
================================
9-
10-
:ref:`order`
9+
.. include:: types/operator-precedence-table.rst
1110

1211
.. index:: assert, block, coinbase, difficulty, number, block;number, timestamp, block;timestamp, msg, data, gas, sender, value, gas price, origin, revert, require, keccak256, ripemd160, sha256, ecrecover, addmod, mulmod, cryptography, this, super, selfdestruct, balance, codehash, send
1312

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
The following is the order of precedence for operators, listed in order of evaluation.
2+
3+
+------------+-------------------------------------+--------------------------------------------+
4+
| Precedence | Description | Operator |
5+
+============+=====================================+============================================+
6+
| *1* | Postfix increment and decrement | ``++``, ``--`` |
7+
+ +-------------------------------------+--------------------------------------------+
8+
| | New expression | ``new <typename>`` |
9+
+ +-------------------------------------+--------------------------------------------+
10+
| | Array subscripting | ``<array>[<index>]`` |
11+
+ +-------------------------------------+--------------------------------------------+
12+
| | Member access | ``<object>.<member>`` |
13+
+ +-------------------------------------+--------------------------------------------+
14+
| | Function-like call | ``<func>(<args...>)`` |
15+
+ +-------------------------------------+--------------------------------------------+
16+
| | Parentheses | ``(<statement>)`` |
17+
+------------+-------------------------------------+--------------------------------------------+
18+
| *2* | Prefix increment and decrement | ``++``, ``--`` |
19+
+ +-------------------------------------+--------------------------------------------+
20+
| | Unary minus | ``-`` |
21+
+ +-------------------------------------+--------------------------------------------+
22+
| | Unary operations | ``delete`` |
23+
+ +-------------------------------------+--------------------------------------------+
24+
| | Logical NOT | ``!`` |
25+
+ +-------------------------------------+--------------------------------------------+
26+
| | Bitwise NOT | ``~`` |
27+
+------------+-------------------------------------+--------------------------------------------+
28+
| *3* | Exponentiation | ``**`` |
29+
+------------+-------------------------------------+--------------------------------------------+
30+
| *4* | Multiplication, division and modulo | ``*``, ``/``, ``%`` |
31+
+------------+-------------------------------------+--------------------------------------------+
32+
| *5* | Addition and subtraction | ``+``, ``-`` |
33+
+------------+-------------------------------------+--------------------------------------------+
34+
| *6* | Bitwise shift operators | ``<<``, ``>>`` |
35+
+------------+-------------------------------------+--------------------------------------------+
36+
| *7* | Bitwise AND | ``&`` |
37+
+------------+-------------------------------------+--------------------------------------------+
38+
| *8* | Bitwise XOR | ``^`` |
39+
+------------+-------------------------------------+--------------------------------------------+
40+
| *9* | Bitwise OR | ``|`` |
41+
+------------+-------------------------------------+--------------------------------------------+
42+
| *10* | Inequality operators | ``<``, ``>``, ``<=``, ``>=`` |
43+
+------------+-------------------------------------+--------------------------------------------+
44+
| *11* | Equality operators | ``==``, ``!=`` |
45+
+------------+-------------------------------------+--------------------------------------------+
46+
| *12* | Logical AND | ``&&`` |
47+
+------------+-------------------------------------+--------------------------------------------+
48+
| *13* | Logical OR | ``||`` |
49+
+------------+-------------------------------------+--------------------------------------------+
50+
| *14* | Ternary operator | ``<conditional> ? <if-true> : <if-false>`` |
51+
+ +-------------------------------------+--------------------------------------------+
52+
| | Assignment operators | ``=``, ``|=``, ``^=``, ``&=``, ``<<=``, |
53+
| | | ``>>=``, ``+=``, ``-=``, ``*=``, ``/=``, |
54+
| | | ``%=`` |
55+
+------------+-------------------------------------+--------------------------------------------+
56+
| *15* | Comma operator | ``,`` |
57+
+------------+-------------------------------------+--------------------------------------------+

docs/types/operators.rst

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -115,60 +115,4 @@ value it referred to previously.
115115
Order of Precedence of Operators
116116
--------------------------------
117117

118-
The following is the order of precedence for operators, listed in order of evaluation.
119-
120-
+------------+-------------------------------------+--------------------------------------------+
121-
| Precedence | Description | Operator |
122-
+============+=====================================+============================================+
123-
| *1* | Postfix increment and decrement | ``++``, ``--`` |
124-
+ +-------------------------------------+--------------------------------------------+
125-
| | New expression | ``new <typename>`` |
126-
+ +-------------------------------------+--------------------------------------------+
127-
| | Array subscripting | ``<array>[<index>]`` |
128-
+ +-------------------------------------+--------------------------------------------+
129-
| | Member access | ``<object>.<member>`` |
130-
+ +-------------------------------------+--------------------------------------------+
131-
| | Function-like call | ``<func>(<args...>)`` |
132-
+ +-------------------------------------+--------------------------------------------+
133-
| | Parentheses | ``(<statement>)`` |
134-
+------------+-------------------------------------+--------------------------------------------+
135-
| *2* | Prefix increment and decrement | ``++``, ``--`` |
136-
+ +-------------------------------------+--------------------------------------------+
137-
| | Unary minus | ``-`` |
138-
+ +-------------------------------------+--------------------------------------------+
139-
| | Unary operations | ``delete`` |
140-
+ +-------------------------------------+--------------------------------------------+
141-
| | Logical NOT | ``!`` |
142-
+ +-------------------------------------+--------------------------------------------+
143-
| | Bitwise NOT | ``~`` |
144-
+------------+-------------------------------------+--------------------------------------------+
145-
| *3* | Exponentiation | ``**`` |
146-
+------------+-------------------------------------+--------------------------------------------+
147-
| *4* | Multiplication, division and modulo | ``*``, ``/``, ``%`` |
148-
+------------+-------------------------------------+--------------------------------------------+
149-
| *5* | Addition and subtraction | ``+``, ``-`` |
150-
+------------+-------------------------------------+--------------------------------------------+
151-
| *6* | Bitwise shift operators | ``<<``, ``>>`` |
152-
+------------+-------------------------------------+--------------------------------------------+
153-
| *7* | Bitwise AND | ``&`` |
154-
+------------+-------------------------------------+--------------------------------------------+
155-
| *8* | Bitwise XOR | ``^`` |
156-
+------------+-------------------------------------+--------------------------------------------+
157-
| *9* | Bitwise OR | ``|`` |
158-
+------------+-------------------------------------+--------------------------------------------+
159-
| *10* | Inequality operators | ``<``, ``>``, ``<=``, ``>=`` |
160-
+------------+-------------------------------------+--------------------------------------------+
161-
| *11* | Equality operators | ``==``, ``!=`` |
162-
+------------+-------------------------------------+--------------------------------------------+
163-
| *12* | Logical AND | ``&&`` |
164-
+------------+-------------------------------------+--------------------------------------------+
165-
| *13* | Logical OR | ``||`` |
166-
+------------+-------------------------------------+--------------------------------------------+
167-
| *14* | Ternary operator | ``<conditional> ? <if-true> : <if-false>`` |
168-
+ +-------------------------------------+--------------------------------------------+
169-
| | Assignment operators | ``=``, ``|=``, ``^=``, ``&=``, ``<<=``, |
170-
| | | ``>>=``, ``+=``, ``-=``, ``*=``, ``/=``, |
171-
| | | ``%=`` |
172-
+------------+-------------------------------------+--------------------------------------------+
173-
| *15* | Comma operator | ``,`` |
174-
+------------+-------------------------------------+--------------------------------------------+
118+
.. include:: types/operator-precedence-table.rst

0 commit comments

Comments
 (0)