Phase 7h: string slicing s[a..b] (retire substr)
`s[a..b]` is a fresh substring of the bytes [a, b) — the modern, end-based form of the C-style `substr(s, start, count)`: substr(src, start, i - start) -> src[start..i] substr(t, 2, len(t) - 2) -> t[2..len(t)] substr(src, i, 2) -> src[i..i + 2] Mechanics: a new E_SLICE postfix (`base[lo..hi]`, distinct from `base[i]` indexing) lowers to a @fn_str_slice prelude (malloc + copy + terminate), emitted once into any program that slices. Two reseeds: add the syntax + prelude, then migrate the 22 substr calls and delete substr. The migrator recognises the common `count == end - start` shape and emits the clean `s[start..end]` rather than `s[start..start + (end - start)]`. examples/strings.ludic gains slicing (now prints 1..9). Reseeded (22673 lines); C-free fixpoint holds; goldens identical; 18/18; vocab + doc-fences clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
0efa06dca2
commit
1b9789630a
14 changed files with 4049 additions and 3914 deletions
4
test.sh
4
test.sh
|
|
@ -68,8 +68,8 @@ if ./selfhost/game-build.sh build/ludicc examples/toggle.ludic "/tmp/ludic_tog"
|
|||
else bad "toggle: $(tail -1 /tmp/tog.out)"; fi
|
||||
# String operators: ==/!= compare by content, + concatenates (str_* prelude).
|
||||
if ./selfhost/game-build.sh build/ludicc examples/strings.ludic "/tmp/ludic_str" >/tmp/str.out 2>&1 \
|
||||
&& [ "$(/tmp/ludic_str </dev/null | tr '\n' ' ')" = "1 2 3 4 5 6 7 " ]; then
|
||||
ok "strings.ludic (str ==/!=/+ and `interpolation`)"
|
||||
&& [ "$(/tmp/ludic_str </dev/null | tr '\n' ' ')" = "1 2 3 4 5 6 7 8 9 " ]; then
|
||||
ok "strings.ludic (str ops, interpolation, slicing)"
|
||||
else bad "strings: $(tail -1 /tmp/str.out)"; fi
|
||||
# --- Toolchain-agent CLI smoke tests append below this line ---
|
||||
echo "== self-hosted front-end binaries (ludicc / ludic) =="
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue