feat: formatter: use hard space after opening structure instance brace
This commit is contained in:
parent
519eda2459
commit
68568e78d3
4 changed files with 5 additions and 3 deletions
|
|
@ -1687,6 +1687,8 @@ withAntiquot (mkAntiquot "fieldIdx" `fieldIdx)
|
|||
{ fn := fun c s => s,
|
||||
info := epsilonInfo }
|
||||
|
||||
/-- No-op parser that advises the pretty printer to emit a non-breaking space. -/
|
||||
@[inline] def ppHardSpace : Parser := skip
|
||||
/-- No-op parser that advises the pretty printer to emit a space/soft line break. -/
|
||||
@[inline] def ppSpace : Parser := skip
|
||||
/-- No-op parser that advises the pretty printer to emit a hard line break. -/
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ def sufficesDecl := optIdent >> termParser >> fromTerm
|
|||
def structInstArrayRef := parser! "[" >> termParser >>"]"
|
||||
def structInstLVal := (ident <|> fieldIdx <|> structInstArrayRef) >> many (group ("." >> (ident <|> fieldIdx)) <|> structInstArrayRef)
|
||||
def structInstField := ppGroup $ parser! structInstLVal >> " := " >> termParser
|
||||
@[builtinTermParser] def structInst := parser! "{ " >> optional (try (termParser >> " with ")) >> sepBy structInstField ", " true >> optional ".." >> optional (" : " >> termParser) >> " }"
|
||||
@[builtinTermParser] def structInst := parser! "{" >> ppHardSpace >> optional (try (termParser >> " with ")) >> sepBy structInstField ", " true >> optional ".." >> optional (" : " >> termParser) >> " }"
|
||||
def typeSpec := parser! " : " >> termParser
|
||||
def optType : Parser := optional typeSpec
|
||||
@[builtinTermParser] def subtype := parser! "{ " >> ident >> optType >> " // " >> termParser >> " }"
|
||||
|
|
|
|||
|
|
@ -387,6 +387,7 @@ pushLine
|
|||
@[combinatorFormatter Lean.Parser.checkOutsideQuot] def checkOutsideQuot.formatter : Formatter := pure ()
|
||||
@[combinatorFormatter Lean.Parser.skip] def skip.formatter : Formatter := pure ()
|
||||
|
||||
@[combinatorFormatter Lean.Parser.ppHardSpace] def ppHardSpace.formatter : Formatter := push " "
|
||||
@[combinatorFormatter Lean.Parser.ppSpace] def ppSpace.formatter : Formatter := pushLine
|
||||
@[combinatorFormatter Lean.Parser.ppLine] def ppLine.formatter : Formatter := push "\n"
|
||||
@[combinatorFormatter Lean.Parser.ppGroup] def ppGroup.formatter (p : Formatter) : Formatter := p *> indentTop *> groupTop
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ Type → Type → Type
|
|||
1
|
||||
42
|
||||
"hi"
|
||||
{
|
||||
type := Nat,
|
||||
{ type := Nat,
|
||||
val := 0 :
|
||||
PointedType }
|
||||
(1, 2, 3)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue