diff --git a/src/parser/parser_types.nim b/src/parser/parser_types.nim index 78392b2..02bf697 100644 --- a/src/parser/parser_types.nim +++ b/src/parser/parser_types.nim @@ -330,10 +330,14 @@ proc foldBuilder*[T, T2]( # -- Stringifiers -proc `$`*(x: ParserToken): string = - &"""ParserToken( - value: {tokenStringValue(x)}, -)""" +func pprint*(x: ParserToken): string = + let str = tokenStringValue(x) + let escapedChar = if str == "\n": "\\n" + else: str + &"""ParserToken("{escapedChar}") +""" + +func `$`*(x: ParserToken): string = pprint(x) const LEFT_HIGHLIGHT_CHAR = ">>" const RIGHT_HIGHLIGHT_CHAR = "<<"