1.5 KiB
1.5 KiB
Include-only Dependency Tree (Phase 0)
Goal
- Build a dependency tree using only Ny (no Array/Map), scanning source text for
include "...", and output stable JSON.
Scope (Phase 0)
- Only
includeis supported.using/module/importare out of scope. - Runner bridge:
NYASH_DEPS_JSON=<path>is read and logged only (no behavior change).
Tool
apps/selfhost/tools/dep_tree_min_string.hako- Recursively reads source files, scans for
include "path"outside of strings and comments. - Comments:
//and#(line comments) are ignored. - Strings:
"..."with\"escapes are honored. - Cycles: detected via a simple stack string; when detected, the child appears as a leaf node with empty
includes/children.
- Recursively reads source files, scans for
Output format
{ "version": 1,
"root_path": "<entry>",
"tree": {
"path": "<file>", "includes": ["..."], "children": [ <node> ]
}
}
Acceptance criteria
- Running
make dep-treeproducestmp/deps.jsonwhose first non-empty line starts with{and conforms to the format above. - The scanner does not pick includes inside strings or comments.
- Cycles do not crash or loop; the repeated node is represented as a leaf.
Examples
- Root:
apps/selfhost/smokes/dep_smoke_root.hako(includesdep_smoke_child.hako) - Cycle:
apps/selfhost/smokes/dep_smoke_cycle_a.hako↔dep_smoke_cycle_b.hako
Validation (examples)
echo apps/selfhost/smokes/dep_smoke_root.hako | ./target/release/nyash --backend vm apps/selfhost/tools/dep_tree_min_string.hakomake dep-tree