More readable but not perfect parser token pprint
This commit is contained in:
@@ -330,10 +330,14 @@ proc foldBuilder*[T, T2](
|
|||||||
|
|
||||||
# -- Stringifiers
|
# -- Stringifiers
|
||||||
|
|
||||||
proc `$`*(x: ParserToken): string =
|
func pprint*(x: ParserToken): string =
|
||||||
&"""ParserToken(
|
let str = tokenStringValue(x)
|
||||||
value: {tokenStringValue(x)},
|
let escapedChar = if str == "\n": "\\n"
|
||||||
)"""
|
else: str
|
||||||
|
&"""ParserToken("{escapedChar}")
|
||||||
|
"""
|
||||||
|
|
||||||
|
func `$`*(x: ParserToken): string = pprint(x)
|
||||||
|
|
||||||
const LEFT_HIGHLIGHT_CHAR = ">>"
|
const LEFT_HIGHLIGHT_CHAR = ">>"
|
||||||
const RIGHT_HIGHLIGHT_CHAR = "<<"
|
const RIGHT_HIGHLIGHT_CHAR = "<<"
|
||||||
|
|||||||
Reference in New Issue
Block a user