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
|
|
@ -175,12 +175,6 @@ static const LBuiltin LUDIC_INTRINSICS[] = {
|
|||
{"write_byte","write_byte(b: int)","Write one byte to stdout."},
|
||||
{"print_str","print_str(s: str)","Write a string to stdout."},
|
||||
{"str_len","str_len(s: str) -> int","Length of a string in bytes."},
|
||||
{"shl","shl(v: int, n: int) -> int","Shift left."},
|
||||
{"shr","shr(v: int, n: int) -> int","Logical shift right."},
|
||||
{"band","band(a: int, b: int) -> int","Bitwise and."},
|
||||
{"bor","bor(a: int, b: int) -> int","Bitwise or."},
|
||||
{"bxor","bxor(a: int, b: int) -> int","Bitwise xor."},
|
||||
{"bnot","bnot(a: int) -> int","Bitwise not."},
|
||||
{"os_exit","os_exit(code: int)","Terminate the process."},
|
||||
{"os_time","os_time() -> int","Seconds since the epoch."},
|
||||
{"is_windowed","is_windowed() -> bool","True when the build has a window."},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue