Files
hakorune/docs/tools/nyfmt/NYFMT_POC_ROADMAP.md

36 lines
1.4 KiB
Markdown
Raw Normal View History

# nyfmt Reversible Formatter PoC Roadmap
Status: Proposal (docs only)
Goal: A reversible code formatter for Nyash that enables roundtrip transforms (format → parse → print → original) for ANCP/Phase 12.7 sugar while preserving developer intent.
## PoC Scope (Phase 1)
- Define reversible AST surface subset (no semantics changes).
- Implement prettyprinter prototype in Rust or script (out of tree), constrained to subset.
- Add examples demonstrating roundtrip invariants and failure modes.
Roundtrip invariants (subset)
- Pipeline: `lhs |> f(a)``f(lhs,a)`
- Safe Access: `a?.b``peek a { null => null, else => a.b }`
- Default: `x ?? y``peek x { null => y, else => x }`
- Range: `a .. b``Range(a,b)`
- Compound Assign: `x += y``x = x + y` (var/field target)
## VSCode Extension Idea
- Commands:
- "Nyfmt: Format (reversible subset)"
- "Nyfmt: Verify RoundTrip"
- Onsave optional gate with env flag `NYFMT_POC=1`.
- Diagnostics panel lists nonreversible constructs.
## Examples and Smokes
- Place minimal examples under `apps/nyfmt-poc/`.
- Add a smoke script `tools/nyfmt_smoke.sh` that:
- echoes `NYFMT_POC` and current subset level
- prints instructions and links to `ANCP-Reversible-Mapping-v1.md`
- shows Before/Canonical/RoundTrip triads from examples
## NonGoals
- Changing Nyash runtime/semantics.
- Enforcing formatting in CI (PoC is optin).