diff options
author | PMunch <peterme@peterme.net> | 2018-03-16 15:57:40 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-03-16 15:57:40 +0100 |
commit | a9f21cffdf7304272b5bbabeabec4a3e659819fa (patch) | |
tree | 86e857eb5f46d142ccf71a3df02bfc1aa1fd652c /tests/macros | |
parent | d56ca42b1ae06814077003e0f8fbb8f6d99c8afe (diff) | |
download | Nim-a9f21cffdf7304272b5bbabeabec4a3e659819fa.tar.gz |
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.
Diffstat (limited to 'tests/macros')
-rw-r--r-- | tests/macros/tdumpastgen.nim | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/tests/macros/tdumpastgen.nim b/tests/macros/tdumpastgen.nim index faed77225..0a1836886 100644 --- a/tests/macros/tdumpastgen.nim +++ b/tests/macros/tdumpastgen.nim @@ -2,16 +2,33 @@ discard """ msg: '''nnkStmtList.newTree( nnkVarSection.newTree( nnkIdentDefs.newTree( - newIdentNode(!"x"), + newIdentNode("x"), newEmptyNode(), nnkCall.newTree( nnkDotExpr.newTree( - newIdentNode(!"foo"), - newIdentNode(!"create") + 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") + ) + ) ) )''' """ @@ -21,5 +38,8 @@ msg: '''nnkStmtList.newTree( import macros dumpAstGen: - var x = foo.create(56) + var x = baz.create(56) + proc foo() = + ## This is a docstring + echo "bar" |