Skip to main content

Module printer

Module printer 

Source
Expand description

The printer: a CstDocument → its exact source bytes.

[print] walks the CST in source order and concatenates every token’s verbatim text. For an unmodified tree this reproduces the input byte-for-byte (round-trip identity, INV-2 / TR-003). Because [print] reads only token text — which the lexer captured verbatim and the parser never normalized — printing is also idempotent: print(parse(print(parse(x)))) == print(parse(x)) (TR-017 / INV-2).

Functions§

print
Print a CstDocument back to source text by concatenating all token text.
print_node
Print an arbitrary SyntaxNode subtree to text (concatenated token text).