fix: parenthesizer: take minimum of successive precedence checks for contPrec as well
Otherwise, we would parenthesize `1 + 2 + 3` as `(1 + 2) + 3` since in ``` @[builtinTermParser] def add := tparser! infixL " + " 65 ``` there is an additional `checkPrec 1024` implied by `tparser!`. Now `contPrec` of this parser is (min 1024 65 = 65).
This commit is contained in:
parent
c2fbb3d307
commit
95742ca17b
1 changed files with 1 additions and 1 deletions
|
|
@ -167,7 +167,7 @@ instance ParenthesizerM.monadTraverser : Syntax.MonadTraverser ParenthesizerM :=
|
|||
open Syntax.MonadTraverser
|
||||
|
||||
def addPrecCheck (prec : Nat) : ParenthesizerM Unit :=
|
||||
modify $ fun st => { st with contPrec := prec, minPrec := Nat.min (st.minPrec.getD prec) prec }
|
||||
modify $ fun st => { st with contPrec := Nat.min (st.contPrec.getD prec) prec, minPrec := Nat.min (st.minPrec.getD prec) prec }
|
||||
|
||||
/-- Execute `x` at the right-most child of the current node, if any, then advance to the left. -/
|
||||
def visitArgs (x : ParenthesizerM Unit) : ParenthesizerM Unit := do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue