Expand the function-declaration keyword to the full word across the whole
language and toolchain:
fn name(...) -> T { ... } -> function name(...) -> T { ... }
Done as a self-hosting migration: teach the parser both spellings, reseed,
rewrite every .ludic definition to `function`, then drop `fn`. The compiler
now rejects `fn`. Touches the parser, all selfhost/tools/runtime/example/test
sources, the grammars (TextMate shared+vscode, ludic_syntax.h, JetBrains
LudicTokens.kt), the LSP and formatter, the Python doc/vocab tools
(check-impl, check-docs, validate, palette, test-lsp), and the docs
(fences, prose, kw-fn -> kw-function).
Reseeded; C-free bootstrap fixpoint holds. All suites green (45 regression,
24 self-host, 29 tool); the docs site generates and check.py passes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
1 KiB
Text
33 lines
1 KiB
Text
# str.ludic — the string handling a compiler lives on: comparison, copying,
|
|
# slicing out substrings, and integer<->text. All over raw NUL-terminated
|
|
# byte buffers reached with peek8/poke8.
|
|
|
|
# a fresh NUL-terminated copy of src[start .. start+n]
|
|
|
|
function char_is_digit(c: int) -> bool { return c >= 48 and c <= 57 }
|
|
function char_is_alpha(c: int) -> bool {
|
|
if c >= 65 and c <= 90 { return true }
|
|
if c >= 97 and c <= 122 { return true }
|
|
return c == 95
|
|
}
|
|
function char_is_alnum(c: int) -> bool { return char_is_alpha(c) or char_is_digit(c) }
|
|
|
|
# integer -> fresh decimal string
|
|
function itoa(v: int) -> ptr {
|
|
if v == 0 { let z = bytes(2); z[0] = 48; z[1] = 0; return z }
|
|
var neg = false
|
|
var x = v
|
|
if x < 0 { neg = true; x = 0 - x }
|
|
let tmp = bytes(16)
|
|
var n = 0
|
|
while x > 0 { tmp[n] = 48 + x % 10; x = x / 10; n = n + 1 }
|
|
var total = n
|
|
if neg { total = total + 1 }
|
|
let out = bytes(total + 1)
|
|
var k = 0
|
|
if neg { out[0] = 45; k = 1 }
|
|
var i = 0
|
|
while i < n { out[k + i] = tmp[n - 1 - i]; i = i + 1 }
|
|
out[total] = 0
|
|
return out
|
|
}
|