tree-sitter.tree-sitter/lib/binding_kotoba/scripts/bundle.sh
Cursor Agent 3fad8cb4e0
Add Kotoba binding for node types and fixture tree walk
Kotoba cannot FFI libtree-sitter. This adds lib/binding_kotoba as a
host-facing node/tree/cursor API plus EDN node-types and a vendored CST
fixture that compiles to Wasm with kotoba v0.7.2.

Co-authored-by: Jun Kawasaki <04.feasts_minded@icloud.com>
2026-08-28 09:35:17 +00:00

14 lines
601 B
Bash
Executable file

#!/bin/sh
# Concatenate tree_sitter.kotoba with a guest file. Kotoba admits one ns per
# unit and has no require, so examples/tests are guests appended to the library.
set -eu
root=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
out=${1:?"usage: bundle.sh <output.kotoba> <guest.kotoba>"}
guest=${2:?"usage: bundle.sh <output.kotoba> <guest.kotoba>"}
extra=$(grep -E '^\(defn ' "$guest" | sed -E 's/^\(defn ([^ ]+).*/\1/' | tr '\n' ' ' | sed 's/[[:space:]]*$//')
{
sed -E "s/\\(:export \\[/(:export [${extra} /" "$root/src/tree_sitter.kotoba"
printf '\n;; ---- guest ----\n'
cat "$guest"
} >"$out"