texponential_eval.nim 761 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # bug #1940
  2. discard """
  3. nimout: '''
  4. ===
  5. merge (A) with (B)
  6. merge (A B) with (C)
  7. merge (A B C) with (D)
  8. merge (A B C D) with (E)
  9. merge (A B C D E) with (F)
  10. ===
  11. '''
  12. output: "A B C D E F"
  13. """
  14. type SqlStmt = tuple
  15. sql: string
  16. parts: int
  17. proc sql(q: string): SqlStmt =
  18. result.sql = q
  19. result.parts = 1
  20. template `&%%`(x, y: SqlStmt): SqlStmt =
  21. const a = x
  22. const b = y
  23. static:
  24. #echo "some merge"
  25. echo "merge (", a.sql, ") with (", b.sql, ")"
  26. const newSql = a.sql & " " & b.sql
  27. const newParts = a.parts + b.parts
  28. SqlStmt((sql: newSql, parts: newParts))
  29. static:
  30. echo "==="
  31. let c =(sql("A") &%%
  32. sql("B")) &%%
  33. sql("C") &%%
  34. sql("D") &%%
  35. sql("E") &%%
  36. sql("F")
  37. echo c.sql
  38. static:
  39. echo "==="