I should explain exactly what I'm trying to do:
I'm trying to make macros. In my macros, I'd like to start with a base AST,
then modify it according to passed-in arguments. I'm having trouble making that
base AST.
There's `dumpAstGen` which makes it easy to print out the AST-generating code.
For example:
dumpAstGen:
echo something
# produces:
# nnkStmtList.newTree(
# nnkCommand.newTree(
# newIdentNode("echo"),
# newIdentNode("something")
# )
# )
Run
I've had success copying and pasting that output back into my source. But it's
cumbersome to copy and paste a bunch of trees.
So I tried using `quote`. But `quote` produces `newSymNode` in places where
`dumpAstGen` produces `newIdentNode`:
macro usingQuote(): untyped =
var x = quote do:
echo something
echo x.astGenRepr()
usingQuote
# produces:
# nnkCommand.newTree(
# newSymNode("echo"),
# newIdentNode("something")
# )
Run
Unfortunately, `newSymNode` breaks where `newIdentNode` didn't. (I haven't yet
been able to make a small, reproducible example for this breakage).
And that's why I tried making my own kind of `quote` substitute in that first
post. But I can't figure out how to evaluate a string as produced by
`astGenRepr`