phase: 20.49 COMPLETE; 20.50 Flow+String minimal reps; 20.51 selfhost v0/v1 minimal (Option A/B); hv1-inline binop/unop/copy; docs + run_all + CURRENT_TASK -> 21.0

This commit is contained in:
nyash-codex
2025-11-06 15:41:52 +09:00
parent 2dc370223d
commit 77d4fd72b3
1658 changed files with 6288 additions and 2612 deletions

View File

@ -0,0 +1,33 @@
// Mini-VM library (function-based) with a tiny JSON extractor
// Safe MVP: no real JSON parsing; string scan for first int literal only
static box MiniVm {
_is_digit(ch) { return ch == "0" || ch == "1" || ch == "2" || ch == "3" || ch == "4" || ch == "5" || ch == "6" || ch == "7" || ch == "8" || ch == "9" }
// Read consecutive digits starting at pos
read_digits(json, pos) {
@out = ""
loop (true) {
@s = json.substring(pos, pos+1)
if s == "" { break }
if _is_digit(s) { out = out + s pos = pos + 1 } else { break }
}
return out
}
// Extract the first integer literal from our AST JSON v0 subset
parse_first_int(json) {
@key = "\"value\":{\"type\":\"int\",\"value\":"
@idx = json.lastIndexOf(key)
if idx < 0 { return "0" }
@start = idx + key.length()
return read_digits(json, start)
}
// Execute a minimal program: print the extracted integer and exit code 0
run(json) {
@n = parse_first_int(json)
print(n)
return 0
}
}