2025-08-30 22:52:16 +09:00
|
|
|
// Nyash Python Compiler entry (Phase 10.7 workbench)
|
|
|
|
|
// Nyash-only pipeline: Parser/Compiler are implemented in Nyash using PyRuntimeBox
|
|
|
|
|
// Usage:
|
2025-12-10 00:01:53 +09:00
|
|
|
// NYASH_PY_CODE=$'def main():\n return 0' ./target/release/hakorune --backend vm tools/pyc/pyc.hako
|
2025-08-30 22:52:16 +09:00
|
|
|
|
|
|
|
|
static box Main {
|
|
|
|
|
main() {
|
|
|
|
|
// Load modules via include (returns module boxes)
|
2025-11-06 15:41:52 +09:00
|
|
|
using "tools/pyc/PyIR.hako" as PyIR
|
|
|
|
|
using "tools/pyc/PythonParserNy.hako" as Parser
|
|
|
|
|
using "tools/pyc/PyCompiler.hako" as Compiler
|
2025-08-30 22:52:16 +09:00
|
|
|
|
|
|
|
|
local json, ir, src
|
|
|
|
|
|
|
|
|
|
// Skip echo of source to avoid plugin toString issues
|
|
|
|
|
|
2025-08-30 23:47:08 +09:00
|
|
|
json = new StringBox("{}")
|
|
|
|
|
// Build minimal IR from Python AST (env: NYASH_PY_CODE)
|
2025-08-30 22:52:16 +09:00
|
|
|
ir = Compiler.buildIRFromParse(json)
|
2025-08-30 23:47:08 +09:00
|
|
|
// Emit generated Nyash source (reflect return/if/assign when present)
|
2025-08-30 22:52:16 +09:00
|
|
|
src = Compiler.irToNyashSource(ir)
|
2025-08-30 23:47:08 +09:00
|
|
|
print(src)
|
2025-08-30 22:52:16 +09:00
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|