chore: pretty printer: tolerate missing better

This commit is contained in:
Sebastian Ullrich 2021-05-05 14:46:05 +02:00
parent 76c66fc4d4
commit 456264bf31
2 changed files with 11 additions and 2 deletions

View file

@ -159,7 +159,12 @@ constant mkAntiquot.formatter' (name : String) (kind : Option SyntaxNodeKind) (a
constant interpretParserDescr' : ParserDescr → CoreM Formatter
unsafe def formatterForKindUnsafe (k : SyntaxNodeKind) : Formatter := do
(← liftM $ runForNodeKind formatterAttribute k interpretParserDescr')
if k == `missing then
push "<missing>"
goLeft
else
let f ← runForNodeKind formatterAttribute k interpretParserDescr'
f
@[implementedBy formatterForKindUnsafe]
constant formatterForKind (k : SyntaxNodeKind) : Formatter

View file

@ -269,7 +269,11 @@ constant mkAntiquot.parenthesizer' (name : String) (kind : Option SyntaxNodeKind
constant interpretParserDescr' : ParserDescr → CoreM Parenthesizer
unsafe def parenthesizerForKindUnsafe (k : SyntaxNodeKind) : Parenthesizer := do
(← liftM $ runForNodeKind parenthesizerAttribute k interpretParserDescr')
if k == `missing then
pure ()
else
let p ← runForNodeKind parenthesizerAttribute k interpretParserDescr'
p
@[implementedBy parenthesizerForKindUnsafe]
constant parenthesizerForKind (k : SyntaxNodeKind) : Parenthesizer