The formatter turns a Syntax
tree into a Format
object, inserting both mandatory whitespace (to separate adjacent
tokens) as well as "pretty" optional whitespace.
The basic approach works much like the parenthesizer: A right-to-left traversal over the syntax tree, driven by parser-specific handlers registered via attributes. The traversal is right-to-left so that when emitting a token, we already know the text following it and can decide whether or not whitespace between the two is necessary.
- options : Lean.Options
- table : Lean.Parser.TokenTable
- stxTrav : Lean.Syntax.Traverser
- leadWord : String
- isUngrouped : Bool
- mustBeGrouped : Bool
- stack : Array Lean.Format
Equations
- Lean.PrettyPrinter.FormatterM.orElse p₁ p₂ = do let s ← get Lean.catchInternalId Lean.PrettyPrinter.backtrackExceptionId p₁ fun x => do set s p₂ ()
Equations
- Lean.PrettyPrinter.instOrElseFormatterM = { orElse := Lean.PrettyPrinter.FormatterM.orElse }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.PrettyPrinter.Formatter.throwBacktrack = throw (Lean.Exception.internal Lean.PrettyPrinter.backtrackExceptionId)
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.PrettyPrinter.Formatter.getStack = do let st ← get pure st.stack
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Execute x
at the right-most child of the current node, if any, then advance to the left.
Equations
- One or more equations did not get rendered due to their size.
Execute x
, pass array of generated Format objects to fn
, and push result.
Equations
- One or more equations did not get rendered due to their size.
Execute x
and concatenate generated Format objects.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
If pos?
has a position, run x
and tag its results with that position,
if they are not already tagged. Otherwise just run x
.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.PrettyPrinter.Formatter.orelse.formatter p1 p2 = HOrElse.hOrElse p1 fun x => p2
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
Equations
- Lean.PrettyPrinter.Formatter.andthen.formatter p1 p2 = SeqRight.seqRight p2 fun x => p1
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.PrettyPrinter.Formatter.setExpected.formatter _expected p = p
Equations
- Lean.PrettyPrinter.Formatter.evalInsideQuot.formatter _declName p = p
Equations
- Lean.PrettyPrinter.Formatter.checkWsBefore.formatter = do let st ← get if (st.leadWord != "") = true then Lean.PrettyPrinter.Formatter.pushLine else pure PUnit.unit
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.PrettyPrinter.Formatter.pushNone.formatter = Lean.Syntax.MonadTraverser.goLeft
Equations
- One or more equations did not get rendered due to their size.
Equations
Equations
- Lean.PrettyPrinter.Formatter.ite c t e = if c then t else e
Equations
Equations
- Lean.PrettyPrinter.Formatter.instCoeFormatterFormatterAliasValue = { coe := Lean.Parser.AliasValue.const }
Equations
- Lean.PrettyPrinter.Formatter.instCoeForAllFormatterFormatterAliasValue = { coe := Lean.Parser.AliasValue.unary }
Equations
- Lean.PrettyPrinter.Formatter.instCoeForAllFormatterFormatterAliasValue_1 = { coe := Lean.Parser.AliasValue.binary }
Equations
- One or more equations did not get rendered due to their size.