Skip to content

feat: add dsl::toAscii, a console listing of a parsed graph - #19

Merged
psyinf merged 1 commit into
mainfrom
feature/to-ascii
Sep 19, 2026
Merged

psyinf merged 1 commit into
mainfrom
feature/to-ascii

Conversation

@psyinf

@psyinf psyinf commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Implements the first step of TODO item "dsl::toAscii: console rendering". Stacked on #18 (which is stacked on #17). Merge those first; this PR then retargets to main.

What

dsl::toAscii(program, style = AsciiStyle::plain) prints a parsed graph as an indented listing and needs no external tool:

in
`-> Parse -> msg
    +-> Validate -> valid
    |   `-> Summarize (merge, see below)
    `-> Summarize (merge, see below)

(msg, valid)
`-> Summarize -> out.stats
  • One tree per graph input (in, in.<key>). Each line is a stage in DSL syntax (Print(prefix="[tap] ")) followed by the edge it produces, or end.
  • Fan-out shows as siblings.
  • A merge appears as a reference in the trees of its inputs. Once all of its inputs have been shown, it gets a tree of its own, headed by its group (with slot names if the group names them: (name: proper, greeting: shouted)).
  • AsciiStyle::unicode draws with ├─► └─► │ ─► (UTF-8, written as byte escapes because the build has no /utf-8). A Windows console needs chcp 65001 to show them, which is why plain is the default.
  • An invalid program (a cycle, a missing producer) still prints every stage exactly once and terminates; a repeated stage shows as (see above).

Not in this PR

The 2D box layout (layered columns, crossing reduction, edge routing) stays in TODO.md as item 7, now scoped to just that, to be done only if the listing turns out not to be enough.

Docs / tests

README ("Visualizing" + feature list), EXAMPLE.md section 6 (listing of the section 3 graph), CHANGELOG. Four new cases compare the full output text: merge/fan-out, arguments/dead ends/both styles, invalid program, named group. All 114 tests pass (MSVC debug, ASan).

@psyinf
psyinf changed the base branch from feature/to-dot to main September 19, 2026 20:59
One tree per graph input: each line is a stage followed by the edge it
produces (or end), fan-out shows as siblings, and a merge appears as a
reference in its inputs' trees plus a tree of its own under its group.
AsciiStyle::plain (default) or AsciiStyle::unicode box drawing. Every stage
of an invalid program (a cycle, a missing producer) is still printed once.

TODO.md: the item shrinks to the 2D box layout that remains.
@psyinf
psyinf merged commit 625d6bf into main Sep 19, 2026
3 checks passed
@psyinf
psyinf deleted the feature/to-ascii branch September 19, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant