This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std/[ macros, strformat ] | |
proc parseParts(x: NimNode): seq[NimNode] | |
proc parseDotExpr(x: NimNode): seq[NimNode] = | |
result.add parseParts(x[0]) | |
result.add x | |
proc parseBracketExpr(x: NimNode): seq[NimNode] = | |
result.add parseParts(x[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std/macros | |
# calls debugEcho with the lineInfo | |
macro here*(x: varargs[typed, `$`]):untyped {.noSideEffect.} = | |
{.cast(noSideEffect), warning[Deprecated]:off.}: # callsite is deprecated, there's no alternative: https://github.com/nim-lang/RFCs/issues/387 | |
result = newTree(nnkCommand, ident "debugEcho") | |
result.add newStrLitNode("--- " & x[0].lineInfo & " ---\n") | |
result.add newStrLitNode(" " & callsite().toStrLit().strVal & " -> \n") | |
for c in x: | |
result.add c |
OlderNewer