Parser accepts:
- Unicode tree line-art (
tree -Fstyle). - ASCII tree line-art (
|,+,-,\\branch styles). - Indent-only outlines (spaces/tabs only).
- Strip inline comments only when marker is preceded by whitespace.
- Supported markers:
#,//,/*,;. - Ignore blank/comment-only lines.
- Normalize tabs to 4 spaces.
- Compute
depth = floor(prefix_visual_columns / 4)where prefix includes whitespace + connector glyphs. - Accept mixed connector/indent prefixes.
- Remove leading connector/prefix tokens.
- Preserve interior path characters and whitespace in names.
- Ignore empty entries and
./...
Per parsed node:
name/=> directory (explicit).name@=> symlink placeholder entry (explicit).name*=> file (explicit executable marker).- If next node is deeper, treat as directory (structural inference).
name.extis not automatically treated as file when marker-style input is detected.- Marker-style input detection: if any explicit file marker (
*or@) appears in the input, undecorated dotted leaves are treated as directories unless structural depth proves otherwise. - Otherwise (non-marker-style input), undecorated dotted leaves default to file.
- Use stack-by-depth to resolve parent path.
- Always ensure parent directories exist before file creation.
- Directory:
mkdir -p/ recursive equivalent. - File: create empty file if missing; overwrite behavior is implementation-defined but should be documented.
- Executable marker: set user-executable bit where supported.
- Symlink marker: for now create placeholder file (no target info in source text).
- Continue processing after per-entry errors.
- Return/report summary: created dirs, created files, error count, first error.
| Capability | Bash | Python | Go | VS Code TS |
|---|---|---|---|---|
| Unicode line-art | Y | Y | Y | Y |
| ASCII line-art | Y | Y | Y | Y |
| Indent-only hierarchy | Y | Y | Y | Y |
Inline comments # // /* ; |
Y | Y | Y | Y |
| Tabs in indentation | Y | Y | Y | Y |
/ directory marker |
Y | Y | Y | Y |
* executable marker parse |
Y | Y | Y | Y |
@ symlink marker parse |
Y | Y | Y | Y |
| Lookahead directory inference | Y | Y | Y | Y |
| Continue-on-error summaries | Y | Y | Y | Y |
Verification notes:
- Python, Bash, and VS Code TS were executed against both fixture styles and produced equivalent trees.
- Go was runtime-verified with
go run retree-go/main.goagainst both fixture styles and produced equivalent trees. - DOS
treefull dialect parsing remains out of scope; current behavior is generic prefix/indent parsing only.
- True symlink target reconstruction from tree output (target path is absent in plain tree text).
- Round-tripping metadata (owner/perms/timestamps).
- Full DOS
treeparser with every switch variant. - CP437 byte-level decoding guarantees across all locales.
- Optional strict mode to reject ambiguous entries instead of inferring.
- Path traversal guardrails (
.., absolute paths) for safer default behavior. - Conflict policy: skip/overwrite/prompt on existing files.
- Shared cross-language golden test fixtures to prevent drift.
- Optional explicit mode switch (strict marker-style vs permissive extension heuristic).