freeze: macro platform complete; default ON with profiles; env consolidation; docs + smokes\n\n- Profiles: --profile {lite|dev|ci|strict} (dev-like default for macros)\n- Macro paths: prefer NYASH_MACRO_PATHS (legacy envs deprecated with warnings)\n- Selfhost pre-expand: auto mode, PyVM-only, add smokes (array/map)\n- Docs: user-macros updated; new macro-profiles guide; AGENTS freeze note; CURRENT_TASK freeze\n- Compat: non-breaking; legacy envs print deprecation notices\n

This commit is contained in:
Selfhosting Dev
2025-09-19 22:27:59 +09:00
parent 811e3eb3f8
commit da32455afc
192 changed files with 6454 additions and 2973 deletions

View File

@ -0,0 +1,46 @@
// array_prepend_zero_macro.nyash
// MacroBoxSpec.expand: prepend 0 to every Array elements list in AST JSON v0
// Contract: expand(json: string) -> string (AST JSON v0)
static box MacroBoxSpec {
expand(json) {
local s, out, i, pat, plen, ins
s = json
out = ""
i = 0
pat = "\"kind\":\"Array\",\"elements\":["
plen = pat.length()
ins = "{\"kind\":\"Literal\",\"value\":{\"type\":\"int\",\"value\":0}}"
loop(i < s.length()) {
if i + plen <= s.length() && s.substring(i, i + plen) == pat {
// Copy the Array header
out = out + pat
// Look ahead: if next is ']' it's empty array; otherwise add comma after inserted element
if i + plen < s.length() && s.substring(i + plen, i + plen + 1) != "]" {
out = out + ins + ","
} else {
out = out + ins
}
i = i + plen
continue
}
// Also support reversed key order: ..."elements":[ ... ],"kind":"Array"
if i + 12 <= s.length() && s.substring(i, i + 12) == "\"elements\":[" {
// We will inject blindly here assuming this 'elements' belongs to Array (per schema it does)
out = out + "\"elements\":["
if i + 12 < s.length() && s.substring(i + 12, i + 13) != "]" {
out = out + ins + ","
} else {
out = out + ins
}
i = i + 12
continue
}
// Copy-through
out = out + s.substring(i, i + 1)
i = i + 1
}
return out
}
}