Expand description
Rendering the F# CST. Spec §5.
One style: four spaces, F#’s offside rule doing the indentation’s own
job, /// for a documentation comment and // for a plain one. F#
has no canonical formatter shipped with the compiler the way zig fmt is one, so unlike crate::zig there is no external tool this
module’s layout is checked against; the generated file’s own
indentation is the only contract, and it is four spaces throughout
because F#’s indentation is significant and a generated file that
mixed widths would not parse.
Nothing is decided here. An F# type reads left to right and carries
its own optionality and dimensionality, so — as in
crate::zig and unlike crate::c — there
is no declarator to split around a name: a property is a name, a
colon, and a type.
§Two things F#’s grammar puts here and nowhere else in this arc
module rec.file()always writes therec; the module documentation ofzerodds_lang_cst::fsharpsays why one word replaces a forward-declaration pass.- The loop-break exception.
Stmt::Untilopens atryaround thewhileit renders and closes it withwith :? ZdWire.LoopBreak -> ();Stmt::Leaveis theraiseinside it. Neither statement carries a name for the other to agree on — the exception type is the coordination, and it is the runtime’s, not this renderer’s invention.Stmt::GuardedandStmt::GiveBackare the same pair onetryfurther out, for areturnthe shared walk writes inside a loop body: a filter matches on the exception’s type, soZdWire.GiveBackpasses straight throughwith :? ZdWire.LoopBreak -> ().
Functions§
- decl
- Render one declaration, for a caller that has only one.
- expr
- Render one expression, for a caller — a generator’s harness — that
builds a
Exprtree and needs its text to splice into a larger, hand-assembled program fragment. - file
- Render a whole file.
- ident
- The identifier a name renders as, for a caller assembling one.
- string_
text - Escape a string for an F# string literal.
- type_
- Render one type, for a caller that has only one.