indent
Indents a new line, if at the start of a line, otherwise does nothing.
mutating func indent()
This function updates internal state.
Indents a new line, if at the start of a line, otherwise does nothing.
mutating func indent()
This function updates internal state.
import _RegexParser
struct PrettyPrinter
State used when to pretty-printing regex ASTs.
init(maxTopDownLevels: Int? = nil, minBottomUpLevels: Int? = nil)
var depth: Int { get }
var indentWidth: Int
The number of spaces used for indentation.
var inlineMatchingOptions: [([AST.MatchingOption], Bool)]
var maxTopDownLevels: Int?
The maximum number number of levels, from the root of the tree, at which to perform pattern conversion.
var minBottomUpLevels: Int?
The maximum number number of levels, from the leaf nodes of the tree, at which to perform pattern conversion.
var quantificationBehavior: AST.Quantification.Kind
mutating func finish() -> String
mutating func output(_ s: String)
Outputs a string directly, without termination or indentation, and without updating any internal state.
mutating func popMatchingOptions() -> ([AST.MatchingOption], Bool)
Pops the most recent list of matching options from the printer and decreases the indentation level by 1.
mutating func print(_ s: String)
Print out a new entry.
mutating func printAsCanonical(_ ast: AST, delimiters: Bool = false, terminateLine terminate: Bool = true)
Outputs a regular expression abstract syntax tree in canonical form, indenting and terminating the line, and updating its internal state.
mutating func printBlock(_ header: String, startDelimiter: String = "{", endDelimiter: String = "}", _ f: (inout PrettyPrinter) -> ())
Executes f
inside an indented block, which has a header and delimiters.
mutating func printIndented(_ f: (inout PrettyPrinter) -> ())
Executes f
at one increased level of indentation.
mutating func printLine(_ f: () -> String?)
Prints out a new entry by invoking f
until it returns nil
.
mutating func pushMatchingOptions(_ options: [AST.MatchingOption], isAdded: Bool)
Pushes the list of matching options to the current stack of other matching options and increases the indentation level by 1.
mutating func terminateLine()
Terminates a line, updating any relevant state.