More readable but not perfect parser token pprint
This commit is contained in:
@@ -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 = "<<"
|
||||
|
||||
Reference in New Issue
Block a user