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 std::
string printFile(const SyntaxTree& tree) - A helper method that assists in printing an entire syntax tree back to source text.
Public functions
-
SyntaxPrinter& append(std::
string_view text) - Append raw text to the buffer.
-
SyntaxPrinter& print(parsing::
Trivia trivia) - Print the provided trivia to the internal buffer.
-
SyntaxPrinter& print(parsing::
Token token) - Print the provided token to the internal buffer.
- SyntaxPrinter& print(const SyntaxNode& node)
- Print the provided node to the internal buffer.
- SyntaxPrinter& print(const SyntaxTree& tree)
- Print the provided tree to the internal buffer.
- SyntaxPrinter& setIncludeTrivia(bool include)
- Sets whether to include trivia when printing syntax.
- SyntaxPrinter& setIncludeMissing(bool include)
- Sets whether to include missing (automatically inserted) nodes when printing syntax.
- SyntaxPrinter& setIncludeSkipped(bool include)
- Sets whether to include skipped (due to some sort of error) nodes when printing syntax.
- SyntaxPrinter& setIncludeDirectives(bool include)
- Sets whether to include preprocessor directives when printing syntax.
- SyntaxPrinter& setExpandIncludes(bool expand)
- Sets whether to expand include directives when printing syntax.
- SyntaxPrinter& setExpandMacros(bool expand)
- Sets whether to expand macro directives when printing syntax.
- SyntaxPrinter& setIncludeComments(bool include)
- Sets whether to include comments when printing syntax.
- SyntaxPrinter& setSquashNewlines(bool include)
- Sets whether to squash adjacent newlines down into one when printing syntax.
-
std::
string str() const
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)
Append raw text to the buffer.
Returns | a reference to this object, to allow chaining additional method calls. |
---|
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: print(parsing:: Trivia trivia)
Print the provided trivia to the internal buffer.
Returns | a reference to this object, to allow chaining additional method calls. |
---|
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: print(parsing:: Token token)
Print the provided token to the internal buffer.
Returns | a reference to this object, to allow chaining additional method calls. |
---|
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: print(const SyntaxNode& node)
Print the provided node to the internal buffer.
Returns | a reference to this object, to allow chaining additional method calls. |
---|
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: print(const SyntaxTree& tree)
Print the provided tree to the internal buffer.
Returns | a reference to this object, to allow chaining additional method calls. |
---|
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setIncludeTrivia(bool include)
Sets whether to include trivia when printing syntax.
Returns | a reference to this object, to allow chaining additional method calls. |
---|
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setIncludeMissing(bool include)
Sets whether to include missing (automatically inserted) nodes when printing syntax.
Returns | a reference to this object, to allow chaining additional method calls. |
---|
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setIncludeSkipped(bool include)
Sets whether to include skipped (due to some sort of error) nodes when printing syntax.
Returns | a reference to this object, to allow chaining additional method calls. |
---|
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setIncludeDirectives(bool include)
Sets whether to include preprocessor directives when printing syntax.
Returns | a reference to this object, to allow chaining additional method calls. |
---|
For controlling expansion of macros and includes, use setExpandIncludes
and setExpandMacros
.
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setExpandIncludes(bool expand)
Sets whether to expand include directives when printing syntax.
Returns | a reference to this object, to allow chaining additional method calls. |
---|
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setExpandMacros(bool expand)
Sets whether to expand macro directives when printing syntax.
Returns | a reference to this object, to allow chaining additional method calls. |
---|
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setIncludeComments(bool include)
Sets whether to include comments when printing syntax.
Returns | a reference to this object, to allow chaining additional method calls. |
---|
SyntaxPrinter& slang:: syntax:: SyntaxPrinter:: setSquashNewlines(bool include)
Sets whether to squash adjacent newlines down into one when printing syntax.
Returns | a reference to this object, to allow chaining additional method calls. |
---|
std:: string slang:: syntax:: SyntaxPrinter:: str() const
Returns | a copy of the internal text buffer. |
---|