class
#include <slang/syntax/SyntaxPrinter.h>
SyntaxPrinter Provides support for printing tokens, trivia, or whole syntax trees back to source code.
Public static functions
- static auto printFile(const SyntaxTree& tree) -> std::string
Public functions
- auto append(std::string_view text) -> SyntaxPrinter&
-
auto print(parsing::
Trivia trivia) -> SyntaxPrinter& -
auto print(parsing::
Token token) -> SyntaxPrinter& - auto print(const SyntaxNode& node) -> SyntaxPrinter&
- auto print(const SyntaxTree& tree) -> SyntaxPrinter&
- auto setIncludeTrivia(bool include) -> SyntaxPrinter&
- auto setIncludeMissing(bool include) -> SyntaxPrinter&
- auto setIncludeSkipped(bool include) -> SyntaxPrinter&
- auto setIncludeDirectives(bool include) -> SyntaxPrinter&
- auto setIncludePreprocessed(bool include) -> SyntaxPrinter&
- auto setIncludeComments(bool include) -> SyntaxPrinter&
- auto setSquashNewlines(bool include) -> SyntaxPrinter&
- auto str() const -> std::string
Function documentation
static std::string slang:: syntax:: SyntaxPrinter:: printFile(const SyntaxTree& tree)
A helper method that assists in printing an entire syntax tree back to source text. A SyntaxPrinter with useful defaults is constructed, the tree is printed, and the resulting text is returned.
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: append(std::string_view text)
Returns | a reference to this object, to allow chaining additional method calls. |
---|
Append raw text to the buffer.
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: print(parsing:: Trivia trivia)
Returns | a reference to this object, to allow chaining additional method calls. |
---|
Print the provided trivia to the internal buffer.
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: print(parsing:: Token token)
Returns | a reference to this object, to allow chaining additional method calls. |
---|
Print the provided token to the internal buffer.
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: print(const SyntaxNode& node)
Returns | a reference to this object, to allow chaining additional method calls. |
---|
Print the provided node to the internal buffer.
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: print(const SyntaxTree& tree)
Returns | a reference to this object, to allow chaining additional method calls. |
---|
Print the provided tree to the internal buffer.
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setIncludeTrivia(bool include)
Returns | a reference to this object, to allow chaining additional method calls. |
---|
Sets whether to include trivia when printing syntax.
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setIncludeMissing(bool include)
Returns | a reference to this object, to allow chaining additional method calls. |
---|
Sets whether to include missing (automatically inserted) nodes when printing syntax.
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setIncludeSkipped(bool include)
Returns | a reference to this object, to allow chaining additional method calls. |
---|
Sets whether to include skipped (due to some sort of error) nodes when printing syntax.
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setIncludeDirectives(bool include)
Returns | a reference to this object, to allow chaining additional method calls. |
---|
Sets whether to include preprocessor directives when printing syntax.
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setIncludePreprocessed(bool include)
Returns | a reference to this object, to allow chaining additional method calls. |
---|
Sets whether to include preprocessor-expanded tokens when printing syntax.
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setIncludeComments(bool include)
Returns | a reference to this object, to allow chaining additional method calls. |
---|
Sets whether to include comments when printing syntax.
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setSquashNewlines(bool include)
Returns | a reference to this object, to allow chaining additional method calls. |
---|
Sets whether to squash adjacent newlines down into one when printing syntax.
std::string slang:: syntax:: SyntaxPrinter:: str() const
Returns | a copy of the internal text buffer. |
---|