CIRCT  20.0.0git
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. More...
 
void addToken (Token t)
 
void eof ()
 End of a stream. More...
 
void literal (StringRef str)
 Add a literal (with external storage). More...
 
void nbsp ()
 Add a non-breaking space. More...
 
void nbsp (unsigned n)
 Add multiple non-breaking spaces as a single token. More...
 
void neverbreak ()
 Add a 'neverbreak' break. Always 'fits'. More...
 
void newline ()
 Add a newline (break too wide to fit, always breaks). More...
 
void spaces (uint32_t n)
 Add breakable spaces. More...
 
void space ()
 Add a breakable space. More...
 
void zerobreak ()
 Add a break that is zero-wide if not broken. More...
 
void bbox (int32_t offset=0, Breaks breaks=Breaks::Consistent)
 Start a IndentStyle::Block group with specified offset. More...
 
void cbox (int32_t offset=0, IndentStyle style=IndentStyle::Visual)
 Start a consistent group with specified offset. More...
 
void ibox (int32_t offset=0, IndentStyle style=IndentStyle::Visual)
 Start an inconsistent group with specified offset. More...
 
void neverbox ()
 Start a group that cannot break, including nested groups. More...
 
void end ()
 End a group. More...
 

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.

Referenced by circt::pretty::TokenStream< PPTy >::operator<<().

◆ 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.

Referenced by circt::pretty::TokenStream< PPTy >::operator<<().

◆ end()

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

End a group.

Definition at line 150 of file PrettyPrinterHelpers.h.

Referenced by circt::pretty::TokenStream< PPTy >::operator<<().

◆ 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.

Referenced by circt::pretty::TokenStream< PPTy >::operator<<().

◆ 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.

Referenced by circt::pretty::TokenStream< PPTy >::operator<<().

◆ 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(), and circt::pretty::TokenStream< PPTy >::operator<<().

◆ 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().

Referenced by circt::pretty::TokenStream< PPTy >::operator<<().

◆ 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.

Referenced by circt::pretty::TokenStream< PPTy >::operator<<().

◆ 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.

Referenced by circt::pretty::TokenStream< PPTy >::operator<<().

◆ 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.

Referenced by circt::pretty::TokenStream< PPTy >::operator<<().

◆ 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().

Referenced by circt::pretty::TokenStream< PPTy >::operator<<().

◆ 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.

Referenced by circt::pretty::TokenStream< PPTy >::operator<<().

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: