Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::PrettyPrinter Class Reference

A formatter for Bond parse trees. More...

#include <bond/tools/prettyprinter.h>

Public Types

enum  Verbosity { VERBOSITY_NORMAL , VERBOSITY_MINIMAL }
 Controls whitespace and layout verbosity in pretty-printed output. More...
enum  ConstantFolding { CONSTANT_FOLDING_OFF , CONSTANT_FOLDING_ON }
 Controls whether constant expressions are folded before printing. More...

Public Member Functions

void Print (const ParseNode *parseNode, OutputStream &stream, Verbosity verbosity=VERBOSITY_NORMAL, ConstantFolding folding=CONSTANT_FOLDING_OFF) const
 Prints Bond source code for a parse tree rooted at a single parse node.
void PrintList (const ListParseNode *listNode, OutputStream &stream, Verbosity verbosity=VERBOSITY_NORMAL, ConstantFolding folding=CONSTANT_FOLDING_OFF) const
 Prints Bond source code for a parse tree represented as a list of parse nodes.

Detailed Description

A formatter for Bond parse trees.

PrettyPrinter converts parse trees back into Bond source code using consistent formatting rules. It can optionally emit minimal formatting and fold constant expressions.

See also
ParseNode, ListParseNode, OutputStream

Member Enumeration Documentation

◆ ConstantFolding

Controls whether constant expressions are folded before printing.

Enumerator
CONSTANT_FOLDING_OFF 

Print expressions without constant folding.

CONSTANT_FOLDING_ON 

Fold constant expressions and print their literal values.

◆ Verbosity

Controls whitespace and layout verbosity in pretty-printed output.

Enumerator
VERBOSITY_NORMAL 

Full formatting with standard whitespace and line breaks.

VERBOSITY_MINIMAL 

Compact formatting with minimal whitespace.

Member Function Documentation

◆ Print()

void Bond::PrettyPrinter::Print ( const ParseNode * parseNode,
OutputStream & stream,
Verbosity verbosity = VERBOSITY_NORMAL,
ConstantFolding folding = CONSTANT_FOLDING_OFF ) const

Prints Bond source code for a parse tree rooted at a single parse node.

Parameters
parseNodeRoot parse node to print.
streamOutput stream receiving the formatted Bond source.
verbosityControls output spacing and compactness.
foldingControls whether constant expressions are folded before printing.

◆ PrintList()

void Bond::PrettyPrinter::PrintList ( const ListParseNode * listNode,
OutputStream & stream,
Verbosity verbosity = VERBOSITY_NORMAL,
ConstantFolding folding = CONSTANT_FOLDING_OFF ) const

Prints Bond source code for a parse tree represented as a list of parse nodes.

Parameters
listNodeHead of the parse node list to print.
streamOutput stream receiving the formatted Bond source.
verbosityControls output spacing and compactness.
foldingControls whether constant expressions are folded before printing.

The documentation for this class was generated from the following file:
  • include/bond/tools/prettyprinter.h