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 /lib/core | |
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 'lib/core')
-rw-r--r-- | lib/core/macros.nim | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index ed9c304fe..d09f5f933 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -678,7 +678,7 @@ proc astGenRepr*(n: NimNode): string {.compileTime, benign.} = ## See also `repr`, `treeRepr`, and `lispRepr`. const - NodeKinds = {nnkEmpty, nnkNilLit, nnkIdent, nnkSym, nnkNone} + NodeKinds = {nnkEmpty, nnkNilLit, nnkIdent, nnkSym, nnkNone, nnkCommentStmt} LitKinds = {nnkCharLit..nnkInt64Lit, nnkFloatLit..nnkFloat64Lit, nnkStrLit..nnkTripleStrLit} proc escape(s: string, prefix = "\"", suffix = "\""): string {.noSideEffect.} = @@ -723,7 +723,7 @@ proc astGenRepr*(n: NimNode): string {.compileTime, benign.} = of nnkCharLit: res.add("'" & $chr(n.intVal) & "'") of nnkIntLit..nnkInt64Lit: res.add($n.intVal) of nnkFloatLit..nnkFloat64Lit: res.add($n.floatVal) - of nnkStrLit..nnkTripleStrLit: res.add($n.strVal.escape()) + of nnkStrLit..nnkTripleStrLit, nnkCommentStmt: res.add($n.strVal.escape()) of nnkIdent: res.add(($n.ident).escape()) of nnkSym: res.add(($n.symbol).escape()) of nnkNone: assert false |