tools(hako-check): add lightweight script checker (parse→MIR verify) + README; uses nyash --backend mir --verify

This commit is contained in:
nyash-codex
2025-10-31 19:16:05 +09:00
parent 712b370013
commit 8596bea1ee
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,22 @@
Hakorune Script Checker (MVP)
Purpose
- Quickly validate Hakorune source files by parsing → MIR build → MIR verify without executing.
- Useful while Python/llvmlite migration is in-flight to keep scripts healthy.
Usage
- Build nyash:
- cargo build --release
- Run checker:
- tools/hako-check/hako-check.sh path/to/file.hako
Behavior
- Runs: nyash --backend mir --verify <file>
- Exit codes:
- 0: OK
- 2+: Parse/MIR verify failure (nyash returns nonzero; checker forwards)
Notes
- This MVP only checks a single file and depends on the Rust parser.
- Extend with flags (parser selection, JSON emit) as migration progresses.

View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -lt 1 ]]; then
echo "usage: tools/hako-check/hako-check.sh <file.hako>" >&2
exit 1
fi
ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
BIN="$ROOT_DIR/target/release/nyash"
FILE="$1"
if [[ ! -x "$BIN" ]]; then
echo "[info] building nyash (release) ..." >&2
cargo build --release -q
fi
if [[ ! -f "$FILE" ]]; then
echo "error: file not found: $FILE" >&2
exit 2
fi
# Parse → MIR build → verify (no execute)
"$BIN" --backend mir --verify "$FILE"
echo "OK: $FILE"