quote tags in printing if they're not identifiers
This commit is contained in:
parent
f2272da4b4
commit
958bc2f8b8
2 changed files with 31 additions and 13 deletions
|
@ -115,10 +115,20 @@ prettyCase pi elim r ret arms = do
|
|||
arms <- prettyArms arms
|
||||
pure $ asep [caseD <++> elim, returnD <++> ret, ofD <++> arms]
|
||||
|
||||
export
|
||||
escapeString : String -> String
|
||||
escapeString = concatMap esc1 . unpack where
|
||||
esc1 : Char -> String
|
||||
esc1 '"' = #"\""#
|
||||
esc1 '\\' = #"\\"#
|
||||
esc1 '\n' = #"\n"#
|
||||
esc1 c = singleton c
|
||||
|
||||
export
|
||||
quoteTag : TagVal -> Doc HL
|
||||
quoteTag tag =
|
||||
if isName tag then fromString tag else hcat ["\"", fromString tag, "\""]
|
||||
if isName tag then fromString tag else
|
||||
hcat ["\"", fromString $ escapeString tag, "\""]
|
||||
|
||||
export
|
||||
prettyTag : TagVal -> Doc HL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue