refactor(lang): rename the fn keyword to function
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>
This commit is contained in:
parent
2f19c8d8e2
commit
4c48077d68
86 changed files with 793 additions and 793 deletions
|
|
@ -3,7 +3,7 @@
|
|||
# contains/index_of/to_int) allocate nothing; slice/from_int/equals/concat reuse
|
||||
# the string preludes that the `+`, `s[a..b]` and str(int) operators emit.
|
||||
|
||||
fn is_text_ns(meth: ptr) -> bool {
|
||||
function is_text_ns(meth: ptr) -> bool {
|
||||
if (meth == "length") or (meth == "char_at") or (meth == "slice") { return true }
|
||||
if (meth == "equals") or (meth == "concat") or (meth == "to_int") or (meth == "from_int") { return true }
|
||||
if (meth == "starts_with") or (meth == "ends_with") { return true }
|
||||
|
|
@ -14,7 +14,7 @@ fn is_text_ns(meth: ptr) -> bool {
|
|||
return false
|
||||
}
|
||||
|
||||
fn emit_text_ns(meth: ptr, e: Node) -> Val {
|
||||
function emit_text_ns(meth: ptr, e: Node) -> Val {
|
||||
if (meth == "from_int") { # int -> str, same as str(n)
|
||||
let n = emit_expr(e.kids[0])
|
||||
g_uses_intstr = true
|
||||
|
|
@ -138,7 +138,7 @@ fn emit_text_ns(meth: ptr, e: Node) -> Val {
|
|||
# emit_text_prelude — string builders that allocate: upper/lower/trim/
|
||||
# repeat/pad. Emitted once per program that uses them (g_uses_textrt). Plain
|
||||
# libc (strlen/malloc/memcpy), deterministic, C-string in and out.
|
||||
fn emit_text_prelude() -> void {
|
||||
function emit_text_prelude() -> void {
|
||||
emith("define ptr @fn_str_upper(ptr %s) {\n")
|
||||
emith("entry:\n")
|
||||
emith(" %n = call i64 @strlen(ptr %s)\n")
|
||||
|
|
@ -343,7 +343,7 @@ fn emit_text_prelude() -> void {
|
|||
# replace, join (over a []str), split (returns a []str). Emitted once per
|
||||
# program that uses them (g_uses_textrt2). Slices are the {data,len,cap}
|
||||
# %LSlice with str (ptr) elements.
|
||||
fn emit_text2_prelude() -> void {
|
||||
function emit_text2_prelude() -> void {
|
||||
emith("define ptr @fn_str_replace(ptr %s, ptr %from, ptr %to) {\n")
|
||||
emith("entry:\n")
|
||||
emith(" %lf = call i64 @strlen(ptr %from)\n")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue