Nim/tests/macros/tdumpastgen.nim
PMunch a9f21cffdf Add CommentStmt to astGenRepr (#7313)
* Added codeRepr and dumpCode to the macros module.

This allows those writing macros to write examples, get the code to generate the AST for that example, and then modify that code to be dynamic with the macro function.
2018-03-16 15:57:40 +01:00

45 lines
839 B
Nim

discard """
msg: '''nnkStmtList.newTree(
nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("x"),
newEmptyNode(),
nnkCall.newTree(
nnkDotExpr.newTree(
newIdentNode("baz"),
newIdentNode("create")
),
newLit(56)
)
)
),
nnkProcDef.newTree(
newIdentNode("foo"),
newEmptyNode(),
newEmptyNode(),
nnkFormalParams.newTree(
newEmptyNode()
),
newEmptyNode(),
newEmptyNode(),
nnkStmtList.newTree(
newCommentStmtNode("This is a docstring"),
nnkCommand.newTree(
newIdentNode("echo"),
newLit("bar")
)
)
)
)'''
"""
# disabled; can't work as the output is done by the compiler
import macros
dumpAstGen:
var x = baz.create(56)
proc foo() =
## This is a docstring
echo "bar"