Phase 7a: bitwise operators & | ^ << >> ~ (retire band/bor/shl/…)
First step of the "stop feeling like C" pass. Bitwise ops were functions (`band(x, MASK)`, `shl(a, 3)`); they are now real operators: band -> & bor -> | bxor -> ^ shl -> << shr -> >> bnot -> ~ Precedence is Go-style so the C footgun is gone: `<<`/`>>`/`&` bind like `*`, `|`/`^` like `+`, both tighter than comparison — `flags & MASK == 0` parses as `(flags & MASK) == 0`. `>>` is logical (lshr), matching the old `shr`. Mechanics: lexer tokenizes `<< >> & | ^ ~`; p_mul takes `<< >> &`, p_add takes `| ^`, p_unary takes `~`; emit_bin routes them through the existing int arith path (arith_code gains and/or/xor/shl/lshr) and E_UN handles `~`. The six intrinsics are deleted. Delivered as two reseeds: (A) add the operators keeping the intrinsics, (B) migrate every call site to operator form (85 lines across compiler + runtime, via a balanced-paren call->operator script; two multi-line big-endian reads in image/truetype done by hand) and delete the intrinsics. Vocabulary drops the six from LUDIC_INTRINSICS (ludic_syntax.h, grammar, LudicTokens.kt) and the grammar gains a bitwise-operator rule. LANGUAGE.md precedence table rewritten. Reseeded (21724 lines); C-free fixpoint holds; goldens byte-identical (the PNG and TrueType decoders lean on these ops); 17/17; vocab + doc-fences clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
0e0c58519d
commit
fcada23eba
18 changed files with 3417 additions and 3403 deletions
19
LANGUAGE.md
19
LANGUAGE.md
|
|
@ -571,14 +571,17 @@ whose battle menus dispatch on `KnightAct`/`MageAct` instead of `0..3`.
|
|||
|
||||
## Expressions
|
||||
|
||||
Precedence: `or → and → compar(< <= > >= == !=) → + - → * / % → unary(- not) →
|
||||
postfix(. () )`. Operators are built-in only (no overloading). The boolean
|
||||
operators are spelled **`and` / `or` / `not`**; `&&` and `||` are not Ludic operators
|
||||
and `!` are rejected with a diagnostic naming the fix (`!=` is unaffected). Bitwise operations are
|
||||
functions (`band`, `bor`, `bxor`, `bnot`, `shl`, `shr`), so the symbols are free
|
||||
— which is why there is only one spelling to remember. `expr with { field: … }` is not implemented; records appear
|
||||
only in `spawn`. Char literals (`'w'`) are `int` code points; colors are hex
|
||||
ints (`0xff8800`).
|
||||
Precedence (high to low): `postfix(. [] ()) → unary(- ~ not) →
|
||||
* / % << >> & → + - | ^ → compar(< <= > >= == !=) → and → or`.
|
||||
The bitwise operators bind **tighter than comparison** (Go-style), so
|
||||
`flags & MASK == 0` means `(flags & MASK) == 0` — no parentheses needed.
|
||||
|
||||
Operators are built-in only (no overloading). The boolean operators are spelled
|
||||
**`and` / `or` / `not`**; `&&` and `||` are not Ludic operators, and a bare `!` is
|
||||
rejected with a diagnostic naming the fix (`!=` is unaffected). Bitwise operators
|
||||
are **`& | ^ << >> ~`** (`>>` is a logical/unsigned shift). `expr with { field: … }`
|
||||
is not implemented; records appear only in `spawn`. Char literals (`'w'`) are
|
||||
`int` code points; colors are hex ints (`0xff8800`).
|
||||
|
||||
## Builtins (the standard library / runtime surface)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue