|
CIRCT 22.0.0git
|
Wrap a PrettyPrinter with TokenBuilder features as well as operator<<'s. More...
#include <PrettyPrinterHelpers.h>


Public Member Functions | |
| TokenStream (PPTy &pp, TokenStringSaver &saver) | |
| Create a TokenStream using the specified PrettyPrinter and StringSaver storage. | |
| TokenStream & | operator<< (const char *s) |
| Add a string literal (external storage). | |
| TokenStream & | operator<< (StringRef s) |
| Add a string token (saved to storage). | |
| TokenStream & | operator<< (const PPExtString &str) |
| String has external storage. | |
| TokenStream & | operator<< (const PPSaveString &str) |
| String must be saved. | |
| TokenStream & | operator<< (PP s) |
| Convenience for inline streaming of builder methods. | |
| TokenStream & | operator<< (Token t) |
| Stream support for user-created Token's. | |
| template<typename T > | |
| TokenStream & | addAsString (T &&t) |
| General-purpose "format this" helper, for types not supported by operator<< yet. | |
| template<typename Callable , unsigned BufferLen = 128> | |
| auto | invokeWithStringOS (Callable &&c) |
| Helper to invoke code with a llvm::raw_ostream argument for compatibility. | |
| TokenStream & | writeEscaped (StringRef str, bool useHexEscapes=false) |
| Write escaped versions of the string, saved in storage. | |
| TokenStream & | writeQuotedEscaped (StringRef str, bool useHexEscapes=false, StringRef left="\"", StringRef right="\"") |
| template<typename T , typename Callable > | |
| auto | scopedBox (T &&t, Callable &&c, Token close=EndToken()) |
| Open a box, invoke the lambda, and close it after. | |
Public Member Functions inherited from circt::pretty::TokenBuilder< PPTy > | |
| 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. | |
Protected Attributes | |
| TokenStringSaver & | saver |
Private Types | |
| using | Base = TokenBuilder< PPTy > |
Wrap a PrettyPrinter with TokenBuilder features as well as operator<<'s.
String behavior: Strings streamed as const char * are assumed to have external storage, and StringRef's are saved until no longer needed. Use PPExtString() and PPSaveString() wrappers to specify/override behavior.
Definition at line 241 of file PrettyPrinterHelpers.h.
|
private |
Definition at line 242 of file PrettyPrinterHelpers.h.
|
inline |
Create a TokenStream using the specified PrettyPrinter and StringSaver storage.
Strings are saved in saver, which is generally the listener in the PrettyPrinter, but may not be (e.g., using BufferingPP).
Definition at line 251 of file PrettyPrinterHelpers.h.
|
inline |
General-purpose "format this" helper, for types not supported by operator<< yet.
Definition at line 331 of file PrettyPrinterHelpers.h.
References circt::pretty::TokenStream< PPTy >::invokeWithStringOS().
|
inline |
Helper to invoke code with a llvm::raw_ostream argument for compatibility.
All data is gathered into a single string token.
Definition at line 339 of file PrettyPrinterHelpers.h.
Referenced by circt::pretty::TokenStream< PPTy >::addAsString(), and circt::pretty::TokenStream< PPTy >::writeQuotedEscaped().
|
inline |
Add a string literal (external storage).
Definition at line 254 of file PrettyPrinterHelpers.h.
|
inline |
String has external storage.
Definition at line 265 of file PrettyPrinterHelpers.h.
References circt::pretty::PPExtString::str.
|
inline |
String must be saved.
Definition at line 271 of file PrettyPrinterHelpers.h.
References circt::pretty::TokenStringSaver::save(), circt::pretty::TokenStream< PPTy >::saver, and circt::pretty::PPSaveString::str.
|
inline |
Convenience for inline streaming of builder methods.
Definition at line 277 of file PrettyPrinterHelpers.h.
References circt::pretty::bbox2, circt::pretty::cbox0, circt::pretty::cbox2, circt::pretty::end, circt::pretty::eof, circt::pretty::ibox0, circt::pretty::ibox2, circt::pretty::nbsp, circt::pretty::neverbox, circt::pretty::neverbreak, circt::pretty::newline, circt::pretty::space, and circt::pretty::zerobreak.
|
inline |
Add a string token (saved to storage).
Definition at line 259 of file PrettyPrinterHelpers.h.
References circt::pretty::TokenStringSaver::save(), and circt::pretty::TokenStream< PPTy >::saver.
|
inline |
Stream support for user-created Token's.
Definition at line 323 of file PrettyPrinterHelpers.h.
|
inline |
Open a box, invoke the lambda, and close it after.
Definition at line 367 of file PrettyPrinterHelpers.h.
|
inline |
Write escaped versions of the string, saved in storage.
Definition at line 350 of file PrettyPrinterHelpers.h.
References circt::pretty::TokenStream< PPTy >::writeQuotedEscaped().
|
inline |
Definition at line 353 of file PrettyPrinterHelpers.h.
References circt::pretty::TokenStream< PPTy >::invokeWithStringOS().
Referenced by circt::pretty::TokenStream< PPTy >::writeEscaped().
|
protected |
Definition at line 245 of file PrettyPrinterHelpers.h.
Referenced by circt::pretty::TokenStream< PPTy >::operator<<(), and circt::pretty::TokenStream< PPTy >::operator<<().