Expand description
AST → .polydat source pretty-printer.
The printer gives a compiled for body its source text for
diagnostics (pp_file), re-emits rewritten expressions in
module inlining and tile lowering (pp_expr), and prints
expressions in polydat explain. The runtime compiles from the
AST; the printer is a faithful AST → source round-trip beside it.
§Round-trip contract
For every Statement/Expr produced by the parser,
pp_statement / pp_expr produces source text that re-parses
into a semantically equivalent AST. “Semantically equivalent”
means same node types and identical inner data (modulo
Spans, which capture parser position and are not preserved
across re-parse).
§Precedence and parens
BinOp expressions are emitted with parens around the whole
expression. This is uniformly safe — re-parsing produces the
same tree structure — at the cost of extra parens. The output
is the canonical spelling; the parens are uniform for round-trip
safety.
Functions§
- pp_expr
- Pretty-print an expression. Always emits parens around
BinOpfor round-trip safety. - pp_file
- Pretty-print a full file: every statement, separated by newlines.
- pp_
statement - Pretty-print a top-level statement.