Add set pretty printer

This commit is contained in:
Florian Schroedl
2022-01-20 17:00:00 +01:00
parent 3df4a68e71
commit dd62925e61

View File

@@ -70,6 +70,23 @@ proc `$`*(x: Parser): string =
tokens: {indentKey($x.tokens, 2)},
)"""
proc prettyExpectedSet(x: set[char]): string =
case x:
of AllChars:
"AllChars {'\x00'..'\xFF'}"
of Digits:
"Digits {'0'..'9'}"
of HexDigits:
"HexDigits {'0'..'9', 'A'..'F', 'a'..'f'}"
of Letters:
"Letters {'A'..'Z', 'a'..'z'}"
of Newlines:
"Newlines {'\r', '\n'}"
of Whitespace:
"Whitespace {' ', '\t', '\v', '\r', '\n', '\f'}"
else:
$x
proc `$`*(x: ParserError): string =
case x:
of charMismatchErr(expected: @expected, parser: @parser, index: @index, unexpected: @unexpected):