📚 Phase 12: Nyashスクリプトプラグインシステム設計と埋め込みVM構想
## 主な成果 - Nyashスクリプトでプラグイン作成可能という革命的発見 - C ABI制約の分析と埋め込みVMによる解決策 - MIR/VM/JIT層での箱引数サポートの詳細分析 ## ドキュメント作成 - Phase 12基本構想(README.md) - Gemini/Codex先生の技術分析 - C ABIとの整合性問題と解決策 - 埋め込みVM実装ロードマップ - 箱引数サポートの技術詳細 ## 重要な洞察 - 制約は「リンク時にC ABI必要」のみ - 埋め込みVMでMIRバイトコード実行により解決可能 - Nyashスクリプト→C ABIプラグイン変換が実現可能 Everything is Box → Everything is Plugin → Everything is Possible!
This commit is contained in:
32
tools/pyc/PythonParserNy.nyash
Normal file
32
tools/pyc/PythonParserNy.nyash
Normal file
@ -0,0 +1,32 @@
|
||||
// Nyash-only Python parser using PyRuntimeBox (no Rust build)
|
||||
static box PythonParserNy {
|
||||
parse(code) {
|
||||
local src
|
||||
if (code == null || code.toString() == "") {
|
||||
// Fallback: read from env via Python os.getenv
|
||||
local os, getenv
|
||||
local py = new PyRuntimeBox()
|
||||
os = py.import("os")
|
||||
getenv = os.getattr("getenv")
|
||||
src = getenv.call("NYASH_PY_CODE").toString()
|
||||
} else {
|
||||
src = code.toString()
|
||||
}
|
||||
|
||||
// ast.dump(ast.parse(src))
|
||||
local ast, parsef, dumpf, tree, dump, dump_str
|
||||
local py2 = new PyRuntimeBox()
|
||||
ast = py2.import("ast")
|
||||
parsef = ast.getattr("parse")
|
||||
tree = parsef.call(src)
|
||||
dumpf = ast.getattr("dump")
|
||||
dump = dumpf.call(tree)
|
||||
dump_str = dump.str()
|
||||
|
||||
// Minimal JSON (escape quotes minimally by replacing \" -> \\\" )
|
||||
// Note: for robust escaping, prefer Python json.dumps in a later pass
|
||||
local esc
|
||||
esc = dump_str.replace("\"", "\\\"")
|
||||
return new StringBox("{\"ast\":\"Module\",\"dump\":\"" + esc + "\"}")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user