tastrepr.nim 861 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. discard """
  2. output: '''
  3. var data = @[(1, "one"), (2, "two")]
  4. for (i, d) in pairs(data):
  5. discard
  6. for i, d in pairs(data):
  7. discard
  8. for i, (x, y) in pairs(data):
  9. discard
  10. var
  11. a = 1
  12. b = 2
  13. var data = @[(1, "one"), (2, "two")]
  14. for (i, d) in pairs(data):
  15. discard
  16. for i, d in pairs(data):
  17. discard
  18. for i, (x, y) in pairs(data):
  19. discard
  20. var (a, b) = (1, 2)
  21. '''
  22. """
  23. import macros
  24. macro echoTypedRepr(arg: typed) =
  25. result = newCall(ident"echo", newLit(arg.repr))
  26. macro echoUntypedRepr(arg: untyped) =
  27. result = newCall(ident"echo", newLit(arg.repr))
  28. template echoTypedAndUntypedRepr(arg: untyped) =
  29. echoTypedRepr(arg)
  30. echoUntypedRepr(arg)
  31. echoTypedAndUntypedRepr:
  32. var data = @[(1,"one"), (2,"two")]
  33. for (i, d) in pairs(data):
  34. discard
  35. for i, d in pairs(data):
  36. discard
  37. for i, (x,y) in pairs(data):
  38. discard
  39. var (a,b) = (1,2)