mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-10-28 10:45:48 +08:00
langref: simplify precedence tables
The details about which operators are ambiguous with which other operators are superfluous and get in the way of what these tables are meant to convey.
This commit is contained in:
1 parent
f98866c02c
commit
a071b0e6d2
1 file changed
+7
-28
+7
-28
@@ -1923,49 +1923,28 @@ x{}
|
||||
as have the operators with higher precedence (those shown above).
|
||||
</p>
|
||||
|
||||
<details style="display:none;" id="ambig-details">
|
||||
<summary style="cursor:pointer;">Toggle operator precedence ambiguity details</summary>
|
||||
<p>
|
||||
The operators that look <span class="ambig-chain">like this</span> have ambiguous precedence with the other operators
|
||||
on the same line. Those that look <span class="ambig-nonchain">like this</span> also have ambiguous
|
||||
precedence with themselves (they cannot be chained).
|
||||
</p>
|
||||
</details>
|
||||
|
||||
<script>
|
||||
let ambig_details = document.getElementById("ambig-details");
|
||||
ambig_details.style.display = 'block';
|
||||
ambig_details.addEventListener("toggle", (event) => {
|
||||
document.querySelectorAll('.ambig-chain').forEach(e => { e.classList.toggle('tok-number'); });
|
||||
document.querySelectorAll('.ambig-nonchain').forEach(e => {
|
||||
e.classList.toggle('tok-number');
|
||||
e.style.borderBottom = ambig_details.open ? '1px dotted' : '';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>
|
||||
For arithmetic operators:
|
||||
</p>
|
||||
|
||||
<pre><code>* / *% *| <span class="ambig-nonchain">%</span>
|
||||
<pre>{#syntax#}* / *% *| %
|
||||
+ - +% -% +| -|
|
||||
<span class="ambig-nonchain">==</span> <span class="ambig-nonchain">!=</span> <span class="ambig-nonchain"><</span> <span class="ambig-nonchain">></span> <span class="ambig-nonchain"><=</span> <span class="ambig-nonchain">>=</span>
|
||||
<span class="ambig-chain">and or</span></code></pre>
|
||||
== != < > <= >=
|
||||
and or{#endsyntax#}</pre>
|
||||
|
||||
<p>
|
||||
For bitwise operators:
|
||||
</p>
|
||||
|
||||
<pre><code><span class="ambig-nonchain"><<</span> <span class="ambig-nonchain"><<|</span> <span class="ambig-nonchain">>></span> <span class="ambig-chain">& ^ |</span>
|
||||
<span class="ambig-nonchain">==</span> <span class="ambig-nonchain">!=</span> <span class="ambig-nonchain"><</span> <span class="ambig-nonchain">></span> <span class="ambig-nonchain"><=</span> <span class="ambig-nonchain">>=</span>
|
||||
<span class="ambig-chain">and or</span></code></pre>
|
||||
<pre>{#syntax#}<< <<| >> & ^ |
|
||||
== != < > <= >=
|
||||
and or{#endsyntax#}</pre>
|
||||
|
||||
<p>
|
||||
For null and error recovery operators:
|
||||
</p>
|
||||
|
||||
<pre><code><span class="ambig-chain">catch orelse</span></code></pre>
|
||||
<pre>{#syntax#}catch orelse{#endsyntax#}</pre>
|
||||
|
||||
<p>
|
||||
For error set operators:
|
||||
|
||||
Reference in new issue
Block a user