CIRCT 20.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
circt::pretty::TokenBuilder< PPTy > Class Template Reference

Add convenience methods for generating pretty-printing tokens. More...

#include <PrettyPrinterHelpers.h>

Inheritance diagram for circt::pretty::TokenBuilder< PPTy >:
Inheritance graph
[legend]
Collaboration diagram for circt::pretty::TokenBuilder< PPTy >:
Collaboration graph
[legend]

Public Member Functions

 TokenBuilder (PPTy &pp)
 
template<typename T , typename... Args>
std::enable_if_t< std::is_base_of_v< Token, T > > add (Args &&...args)
 Add new token.
 
void addToken (Token t)
 
void eof ()
 End of a stream.
 
void literal (StringRef str)
 Add a literal (with external storage).
 
void nbsp ()
 Add a non-breaking space.
 
void nbsp (unsigned n)
 Add multiple non-breaking spaces as a single token.
 
void neverbreak ()
 Add a 'neverbreak' break. Always 'fits'.
 
void newline ()
 Add a newline (break too wide to fit, always breaks).
 
void spaces (uint32_t n)
 Add breakable spaces.
 
void space ()
 Add a breakable space.
 
void zerobreak ()
 Add a break that is zero-wide if not broken.
 
void bbox (int32_t offset=0, Breaks breaks=Breaks::Consistent)
 Start a IndentStyle::Block group with specified offset.
 
void cbox (int32_t offset=0, IndentStyle style=IndentStyle::Visual)
 Start a consistent group with specified offset.
 
void ibox (int32_t offset=0, IndentStyle style=IndentStyle::Visual)
 Start an inconsistent group with specified offset.
 
void neverbox ()
 Start a group that cannot break, including nested groups.
 
void end ()
 End a group.
 

Private Attributes

PPTy & pp
 

Detailed Description

template<typename PPTy = PrettyPrinter>
class circt::pretty::TokenBuilder< PPTy >

Add convenience methods for generating pretty-printing tokens.

Definition at line 80 of file PrettyPrinterHelpers.h.

Constructor & Destructor Documentation

◆ TokenBuilder()

template<typename PPTy = PrettyPrinter>
circt::pretty::TokenBuilder< PPTy >::TokenBuilder ( PPTy &  pp)
inline

Definition at line 84 of file PrettyPrinterHelpers.h.

Member Function Documentation

◆ add()

template<typename PPTy = PrettyPrinter>
template<typename T , typename... Args>
std::enable_if_t< std::is_base_of_v< Token, T > > circt::pretty::TokenBuilder< PPTy >::add ( Args &&...  args)
inline

Add new token.

Definition at line 90 of file PrettyPrinterHelpers.h.

References circt::pretty::TokenBuilder< PPTy >::pp.

◆ addToken()

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::addToken ( Token  t)
inline

◆ bbox()

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::bbox ( int32_t  offset = 0,
Breaks  breaks = Breaks::Consistent 
)
inline

Start a IndentStyle::Block group with specified offset.

Definition at line 131 of file PrettyPrinterHelpers.h.

References circt::pretty::Block.

◆ cbox()

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::cbox ( int32_t  offset = 0,
IndentStyle  style = IndentStyle::Visual 
)
inline

Start a consistent group with specified offset.

Definition at line 136 of file PrettyPrinterHelpers.h.

References circt::pretty::Consistent.

◆ end()

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::end ( )
inline

End a group.

Definition at line 150 of file PrettyPrinterHelpers.h.

◆ eof()

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::eof ( )
inline

End of a stream.

Definition at line 96 of file PrettyPrinterHelpers.h.

References circt::pretty::TokenBuilder< PPTy >::pp.

◆ ibox()

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::ibox ( int32_t  offset = 0,
IndentStyle  style = IndentStyle::Visual 
)
inline

Start an inconsistent group with specified offset.

Definition at line 141 of file PrettyPrinterHelpers.h.

References circt::pretty::Inconsistent.

◆ literal()

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::literal ( StringRef  str)
inline

Add a literal (with external storage).

Definition at line 101 of file PrettyPrinterHelpers.h.

Referenced by circt::pretty::TokenBuilder< PPTy >::nbsp().

◆ nbsp() [1/2]

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::nbsp ( )
inline

Add a non-breaking space.

Definition at line 104 of file PrettyPrinterHelpers.h.

References circt::pretty::TokenBuilder< PPTy >::literal().

◆ nbsp() [2/2]

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::nbsp ( unsigned  n)
inline

Add multiple non-breaking spaces as a single token.

Definition at line 107 of file PrettyPrinterHelpers.h.

References circt::pretty::TokenBuilder< PPTy >::addToken(), and circt::pretty::detail::emitNBSP().

◆ neverbox()

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::neverbox ( )
inline

Start a group that cannot break, including nested groups.

Use sparingly.

Definition at line 147 of file PrettyPrinterHelpers.h.

References circt::pretty::Never.

◆ neverbreak()

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::neverbreak ( )
inline

Add a 'neverbreak' break. Always 'fits'.

Definition at line 114 of file PrettyPrinterHelpers.h.

◆ newline()

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::newline ( )
inline

Add a newline (break too wide to fit, always breaks).

Definition at line 117 of file PrettyPrinterHelpers.h.

References circt::pretty::PrettyPrinter::kInfinity.

◆ space()

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::space ( )
inline

Add a breakable space.

Definition at line 123 of file PrettyPrinterHelpers.h.

References circt::pretty::TokenBuilder< PPTy >::spaces().

◆ spaces()

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::spaces ( uint32_t  n)
inline

Add breakable spaces.

Definition at line 120 of file PrettyPrinterHelpers.h.

Referenced by circt::pretty::TokenBuilder< PPTy >::space().

◆ zerobreak()

template<typename PPTy = PrettyPrinter>
void circt::pretty::TokenBuilder< PPTy >::zerobreak ( )
inline

Add a break that is zero-wide if not broken.

Definition at line 126 of file PrettyPrinterHelpers.h.

Member Data Documentation

◆ pp

template<typename PPTy = PrettyPrinter>
PPTy& circt::pretty::TokenBuilder< PPTy >::pp
private

The documentation for this class was generated from the following file: