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:
24
lang/src/vm/mini_vm_lib.hako
Normal file
24
lang/src/vm/mini_vm_lib.hako
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user