-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
import macros, strutils
const separator = repeat("=", 60)
macro foobar(arg: untyped): untyped =
echo separator
for x in arg:
echo x.repr
echo x.lispRepr
echo x.treeRepr
echo x.astGenRepr
echo separator
foobar:
" \n \r \t \\ "
" \x0A \x0D \x09 \\ "
" \L \c \t \\ "
""" \n \r \t \\ """
r" \n \r \t \\ "this is the output:
============================================================
" \L \c \t \\ "
StrLit(
\ )
StrLit
\
newLit(" \x0A \x0D \x09 \\ ")
============================================================
" \L \c \t \\ "
StrLit(
\ )
StrLit
\
newLit(" \x0A \x0D \x09 \\ ")
============================================================
" \L \c \t \\ "
StrLit(
\ )
StrLit
\
newLit(" \x0A \x0D \x09 \\ ")
============================================================
""" \n \r \t \\ """
TripleStrLit( \n \r \t \\ )
TripleStrLit \n \r \t \\
newLit(" \\n \\r \\t \\\\ ")
============================================================
r" \n \r \t \\ "
RStrLit( \n \r \t \\ )
RStrLit \n \r \t \\
newLit(" \\n \\r \\t \\\\ ")
============================================================
In my opinion the escaping works unnecessarily complicated. This looks like the escaping is implemented in several different locations in the source with code duplication, and then it diverged over time.
Metadata
Metadata
Assignees
Labels
No labels