Lexicon
The reserved words, the operator tokens and the precedence table, from
spec/lexicon.json (format: spec/lexicon.md), which tools/gen-lexicon.mjs
checks against spec/grammar.md and spec/SPEC.md §5 before rendering — the
prose there defines them; this page lists them. Every host's lexer and parser
are built from the same table.
Reserved words
TRUE FALSE NULL AND OR NOT XOR EQL IN BAND BOR BXOR
Reserved words are case-insensitive, like every identifier, and cannot name a variable.
Operator tokens
Longest match first:
??? $== $!= $<= $>= .> ?? == != <= >= $< $> += -= *= /= %= &= [ - * / % + & < > = , ; ( ) ]
Precedence
Tightest first. Binding power is the number the parsers climb by (higher binds tighter).
| # | Binding power | Operators | Associativity | Family |
|---|---|---|---|---|
| 1 | 17 | [ .> |
postfix | Indexing and forward pipeline (§5.10) |
| 2 | 16 | - |
prefix | Arithmetic (§5.1) |
| 3 | 15 | * / % |
left | Arithmetic (§5.1) |
| 4 | 14 | + - |
left | Arithmetic (§5.1) |
| 5 | 13 | & |
left | Concatenation (§5.2) |
| 6 | 12 | BAND |
left | Bitwise (§5.6) |
| 7 | 11 | BXOR |
left | Bitwise (§5.6) |
| 8 | 10 | BOR |
left | Bitwise (§5.6) |
| 9 | 9 | ?? ??? |
right | Coalescing (§5.5) |
| 10 | 8 | == != < <= > >= $== $!= $< $<= $> $>= EQL IN |
none | Numeric comparison (§4.5), Text comparison (bytewise) (§5.3), Deep comparison (§5.4) |
| 11 | 7 | NOT |
prefix | Logic (§5.6) |
| 12 | 6 | AND |
left | Logic (§5.6) |
| 13 | 5 | XOR |
left | Logic (§5.6) |
| 14 | 4 | OR |
left | Logic (§5.6) |
| 15 | 3 | = += -= *= /= %= &= |
right | Assignment (§5.7) |
| 16 | 2 | , |
left | List building (§5.9) |
| 17 | 1 | ; |
left | Sequence (§5.8) |
Operators
| Operator | Fixity | Family | Comparison | Notes |
|---|---|---|---|---|
[ |
postfix | postfix | ||
.> |
postfix | postfix | ||
- |
prefix | arith | parse-tree name NEG |
|
* |
infix | arith | ||
/ |
infix | arith | ||
% |
infix | arith | ||
+ |
infix | arith | ||
- |
infix | arith | ||
& |
infix | concat | ||
BAND |
infix | bitwise | ||
BXOR |
infix | bitwise | ||
BOR |
infix | bitwise | ||
?? |
infix | coalesce | short-circuit: the right operand may not run | |
??? |
infix | coalesce | short-circuit: the right operand may not run | |
== |
infix | compare | eq | |
!= |
infix | compare | ne | |
< |
infix | compare | lt | |
<= |
infix | compare | le | |
> |
infix | compare | gt | |
>= |
infix | compare | ge | |
$== |
infix | text-compare | eq | |
$!= |
infix | text-compare | ne | |
$< |
infix | text-compare | lt | |
$<= |
infix | text-compare | le | |
$> |
infix | text-compare | gt | |
$>= |
infix | text-compare | ge | |
EQL |
infix | deep-compare | ||
IN |
infix | deep-compare | ||
NOT |
prefix | logic | parse-tree name NOT |
|
AND |
infix | logic | short-circuit: the right operand may not run | |
XOR |
infix | logic | ||
OR |
infix | logic | short-circuit: the right operand may not run | |
= |
infix | assign | ||
+= |
infix | assign | applies + |
|
-= |
infix | assign | applies - |
|
*= |
infix | assign | applies * |
|
/= |
infix | assign | applies / |
|
%= |
infix | assign | applies % |
|
&= |
infix | assign | applies & |
|
, |
infix | list | ||
; |
infix | sequence |
41 operators on 17 levels; 12 reserved words; 34 symbol tokens.