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.
This commit is contained in:
parent
d56ca42b1a
commit
a9f21cffdf
2 changed files with 26 additions and 6 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue