Expand description
The expression/pattern/statement printer: renders a parsed AST fragment back to Bynk source text.
Moved here from bynk-fmt (crate-hygiene A3, design/archive/retired-tracks.md §5) so the
checker can quote an expression in a diagnostic without depending on the formatter. The
formatter and the checker both call it from here; the text is unchanged byte for byte.
Structs§
- Written
Forms - Scope guard installing
WRITTEN_SOURCE.
Enums§
- Lambda
Body Src - #2712: a lambda’s body as the author wrote it.
Functions§
- binop_
prec - call_
site_ actor_ src - v0.182 (#664): render a call-site actor clause —
by User("bob")or the unit-identityby Visitor. - else_
if_ tail - #2891: the
ifanelse ifdesugars to. The parser wraps it in a brace-less block with the same span as theifitself, which tells it apart from an explicitelse { if … }(whose block spans its braces). - escape_
string - expr_
to_ string - expr_
with_ prec - is_
pattern_ src - #2641: a pattern after
is. A record pattern there must be parenthesised — its{would otherwise read as the block that follows the condition — so a record, or an or-pattern with a record alternative, keeps the parentheses the parser dropped as transparent grouping. - lambda_
body_ src - #2712: the body a lambda with pattern parameters was written with. The
parser wraps it, one level per pattern parameter (first outermost), in
{ let __letElse = __lambdaArg; match __letElse { P => { <rest> } } }; this peels those back off. A lambda with no pattern parameter is untouched. - lambda_
param_ src - #2712: a lambda parameter as source — the author’s record pattern when it has one (its hidden binder never prints), else the name and any annotation.
- let_
else_ binding - #2010: the hidden binding a
let … elsedesugars into, ifsis one — with whether it was<-and the sugar’s own marker. - let_
pattern_ src - #2010: a
let … elsepattern as source. Afterlet, a bare name is a binding, not a pattern (let Missing | Late = pwould re-parse as a binding namedMissing), so a pattern whose text opens with a name not followed by(,.or{keeps the parentheses its author had to write.None,trueandfalseare keywords, not names, so they need none. - literal_
text - A literal as written if it has a special form, else canonically escaped.
- matches_
argument_ span - The span of a
Matches(…)predicate’s string argument. - omit_
unit_ tail - #981: whether a block’s
()tail should be omitted rather than printed. - pattern_
to_ string - refinement_
to_ string - type_
ref_ to_ string