tools(hako-check): add lightweight script checker (parse→MIR verify) + README; uses nyash --backend mir --verify
This commit is contained in:
22
tools/hako-check/README.md
Normal file
22
tools/hako-check/README.md
Normal 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 non‑zero; 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.
|
||||||
|
|
||||||
26
tools/hako-check/hako-check.sh
Normal file
26
tools/hako-check/hako-check.sh
Normal 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"
|
||||||
|
|
||||||
Reference in New Issue
Block a user