Why not try it? Here's example implementation:
import std/[macros]
macro foo(): untyped =
result = newStmtList(
infix(
newLit(1),
"*",
infix(
newLit(2),
"+",
newLit(3)
)
)
)
echo result.repr # this line will print the code generated by a macro at
compile time
echo foo()
Run
Here's the code generated by the macro:
1 * (2 + 3)
Run
Output is obviously - `5`
I hope this answers your question.
