Archive Rust bootstrap — El compiler is now self-hosting

This commit is contained in:
Will Anderson
2026-04-29 22:21:31 -05:00
parent 9a0747aa13
commit 4f3543b068
139 changed files with 8980 additions and 1778 deletions
+27
View File
@@ -17,3 +17,30 @@ fn compile(source: String) -> String {
let stmts: [Map<String, Any>] = parse(tokens)
codegen(stmts, source)
}
// main CLI entry point for self-hosted compilation.
//
// Called by: elvm el-compiler.elc <source.el> <output.elc>
//
// Reads pre-resolved El source from args()[0], compiles it to JSON bytecode,
// and writes the result to args()[1]. The output is raw JSON (accepted by
// both elvm and el exec without an ELVM container header).
fn main() -> Void {
let argv: [String] = args()
let argc: Int = native_list_len(argv)
if argc < 2 {
println("el-compiler: usage: elvm el-compiler.elc <source.el> <output.elc>")
exit(1)
}
let src_path: String = native_list_get(argv, 0)
let out_path: String = native_list_get(argv, 1)
let source: String = fs_read(src_path)
let bytecode_json: String = compile(source)
let ok: Bool = fs_write(out_path, bytecode_json)
if ok {
exit(0)
} else {
println("el-compiler: failed to write output")
exit(1)
}
}