2025-11-08 15:49:25 +09:00
|
|
|
// tools/hako_parser/cli.hako - HakoParserBox CLI (MVP skeleton)
|
2025-11-08 00:46:34 +09:00
|
|
|
using tools.hako_parser.parser_core as HakoParserCoreBox
|
|
|
|
|
using tools.hako_parser.ast_emit as HakoAstEmitBox
|
2025-11-07 19:32:44 +09:00
|
|
|
|
|
|
|
|
static box HakoParserBox {
|
|
|
|
|
run(args) {
|
|
|
|
|
if args == null || args.size() < 1 { print("[parser/error] missing path"); return 2 }
|
|
|
|
|
local path = args.get(0)
|
|
|
|
|
local f = new FileBox(); if f.open(path) == 0 { print("[parser/error] open fail: " + path); return 2 }
|
|
|
|
|
local text = f.read(); f.close()
|
|
|
|
|
local ast = HakoParserCoreBox.parse(text)
|
|
|
|
|
local json = HakoAstEmitBox.to_json(ast)
|
|
|
|
|
print(json)
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static box HakoParserCliMain { method main(args) { return HakoParserBox.run(args) } }
|