restore(lang): full lang tree from ff3ef452 (306 files) — compiler, vm, shared, runner, c-abi, etc.\n\n- Restores lang/ directory (files≈306, dirs≈64) as per historical branch with selfhost sources\n- Keeps our recent parser index changes in compiler/* (merged clean by checkout)\n- Unblocks selfhost development and documentation references

This commit is contained in:
nyash-codex
2025-10-31 20:45:46 +09:00
parent dbc285f2b1
commit e5f697eb22
244 changed files with 16915 additions and 47 deletions

View File

@ -0,0 +1,24 @@
// Mini-VM library (function-based) with a tiny JSON extractor
// Safe MVP: no real JSON parsing; string scan for first int literal only
using "lang/src/shared/common/string_helpers.hako" as StringHelpers
static box MiniVm {
// Read consecutive digits starting at pos (delegated)
read_digits(json, pos) { return StringHelpers.read_digits(json, pos) }
// 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.size()
return me.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
}
}