Phase 10.7/10.5c: include cycle detection (VM/Interpreter), minimal pyc IR→Nyash, String unification bridge (VM partial), add core plugins: RegexBox/EncodingBox/TOMLBox/PathBox + examples; wire nyash.toml; begin String interop for internal vs plugin boxes; update CURRENT_TASK.md

This commit is contained in:
Moe Charm
2025-08-30 23:47:08 +09:00
parent c13d9c045e
commit 4ae92cfb56
39 changed files with 3217 additions and 69 deletions

9
examples/cycle_a.nyash Normal file
View File

@ -0,0 +1,9 @@
// Cycle test A -> B -> A
include "examples/cycle_b.nyash"
static box A {
main() {
return 0
}
}

9
examples/cycle_b.nyash Normal file
View File

@ -0,0 +1,9 @@
// Cycle test B -> A
include "examples/cycle_a.nyash"
static box B {
main() {
return 0
}
}

View File

@ -0,0 +1,8 @@
static box Main {
main() {
local e = new EncodingBox()
local b64 = e.base64Encode("hello")
// quick check: "hello" -> aGVsbG8=
return b64.length() == 8
}
}

8
examples/path_min.nyash Normal file
View File

@ -0,0 +1,8 @@
static box Main {
main() {
local p = new PathBox()
local j = p.join("/usr", "bin")
local b = p.basename(j)
return b
}
}

View File

@ -0,0 +1,35 @@
// プラグインBoxが箱を引数に取る例のデモ
// HttpServer/Request/Responseの例
local server = new HttpServerBox()
server.start(8080)
// acceptはHttpRequestBoxを返す
local request = server.accept() // returns box
// HttpResponseBoxを作成
local response = new HttpResponseBox()
response.setStatus(200)
response.setHeader("Content-Type", "text/plain")
response.write("Hello from Nyash!")
// ★ HttpRequestBox.respond()はHttpResponseBox別の箱を引数に取る
request.respond(response) // Box引数の実例
// 他の例ArrayBoxにプラグインBoxを格納
local array = new ArrayBox()
local file1 = new FileBox()
local file2 = new FileBox()
// ArrayBoxは任意のBoxを引数に取れる
array.push(file1) // FileBoxプラグインBoxを引数に
array.push(file2) // 別のFileBoxインスタンスも
// MapBoxでも同様
local map = new MapBox()
local net = new HttpClientBox()
// MapBoxも任意のBoxを値として設定できる
map.set("client", net) // HttpClientBoxプラグインBoxを引数に
print("Plugin boxes can take other boxes as arguments!")

8
examples/regex_min.nyash Normal file
View File

@ -0,0 +1,8 @@
static box Main {
main() {
local r = new RegexBox()
r.compile("a+")
return r.isMatch("caaab")
}
}

8
examples/toml_min.nyash Normal file
View File

@ -0,0 +1,8 @@
static box Main {
main() {
local t = new TOMLBox()
t.parse("[a]\nvalue=42\n")
local j = t.toJson()
return j
}
}