diff --git a/doc/langref.html.in b/doc/langref.html.in index 9265b41fe3bff1fa02c032a5dd11cfc50a653bbf..959afdbf374e4eec44c150afa97616c564622dcc 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -1907,35 +1907,7 @@ and or = *= *%= *|= /= %= += +%= +|= -= -%= -|= <<= <<|= >>= &= ^= |={#endsyntax#} {#header_close#} -

- However, understanding the full ambiguity rules are not necessary for reading or writing code. Instead, having an understanding of the unambiguous cases for the operators, you're using is more practical. To that end, some simplified versions, of the precedence table are provided below, tailored to understanding particular groups of operator groups. The operators that have ambiguous precedence with the given operators in question have been omitted, as have operators with higher precedence. The operators colored orange have ambiguous precedence with other operators on the same line. - For arithmetic and error set operators, the simplfied precedence table would look like this. -

- -
* / *% *| || %
-+ - ++ +% -% +| -|
-== != < > <= >=
-and or
-= *= *%= *|= /= %= += +%= +|= -= -%= -|= <<= <<|= >>= &= ^= |=
- -

- For bitwise operators, it would look like this: -

- -
<< <<| >> & ^ |
-== != < > <= >=
-and or
-= *= *%= *|= /= %= += +%= +|= -= -%= -|= <<= <<|= >>= &= ^= |=
- -

- For null and error recovery, it would look like this: -

- -
catch orelse
-= *= *%= *|= /= %= += +%= +|= -= -%= -|= <<= <<|= >>= &= ^= |=
- - {#header_close#} {#header_close#} {#header_open|Arrays#} @@ -7909,6 +7881,42 @@ fn readU32Be() u32 {} {#header_open|Appendix#} {#header_open|Grammar#} {#grammar#} + {#header_open|Operator Precedence Flowchart#} +

+ To help understand the grammar, this flowchart is provided for the operator precedence. + The bottom represents any location where an expression may occur and the topmost row represents + a parenthesized expression. An operator will have a higher precedence (and therefore be the parent) to + another node if it is strictly lower on the tree (having a directed path from one to another). This is inverted from classical precedence, but + is closer to how a recursive descent parser views the grammar. +

+

+                     ┏━━━━━━━━━━━━━━━━━━━┓   
+                     ┃(expr)             ┃                  
+                     ┃x() x[] x.y x.* x.?┃                  
+                     ┃E!T                ┃                  
+                     ┃x{}                ┃                  
+                     ┃!x -x -%x ~x &x ?x ┃                  
+                     ┗━━━━━━━━━▲━━━━━━━━━┛                  
+          ┌─────────────┬──────┴───────┬───────┬──┬──┬─┐         
+          │             │              │       │  │  │ │         
+   ┏━━━━━━┷━━━━━┓╭Non╌Chaining╮ ╭Non╌Chaining╮┏┷┓┏┷┓┏┷┓│         
+   ┃* *% *| / ||┃╎      %     ╎ ╎ << <<|  >> ╎┃&┃┃^┃┃|┃│         
+   ┗━━━━━━▲━━━━━┛╰╌╌╌╌╌╌▲╌╌╌╌╌╯ ╰╌╌╌╌╌╌▲╌╌╌╌╌╯┗▲┛┗▲┛┗▲┛│         
+       ┏━━┷━━━━━━━━━━━━━┷━┓       ┌────┴───────┴──┴──┘ │         
+       ┃+ - +% -% +| -| ++┃       │                    │         
+       ┗━━━━━━━━━━━▲━━━━━━┛       │                    │         
+                  ╭┴╌Non-Chaining╌┴╮                   │         
+                  ╎== !=  < <= >= >╎                   │         
+                  ╰╌╌╌▲╌╌╌╌▲╌╌╌╌╌╌╌╯      ┌──────┬─────┘                
+                    ┏━┷━┓┏━┷━┓        ┏━━━┷━━┓┏━━┷━━┓                  
+                    ┃and┃┃or ┃        ┃orelse┃┃catch┃                  
+                    ┗━▲━┛┗━▲━┛        ┗━━━▲━━┛┗━━▲━━┛                  
+                   ╭╌╌┴╌╌╌╌┴╌╌╌╌╌╌╌╌╌╌╌╌╌╌┴╌╌╌╌╌╌┴╌╮ 
+                   ╎    Any expression location    ╎ 
+                   ╰╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╯ 
+                                                              
+      
+ {#header_close#} {#header_close#} {#header_open|Zen#}