No description
Find a file
2023-11-08 19:51:14 +08:00
.gitignore init 2023-10-31 17:57:48 +08:00
astiife.nim init 2023-10-31 17:57:48 +08:00
astiife.nimble init 2023-10-31 17:57:48 +08:00
LICENSE init 2023-10-31 17:57:48 +08:00
readme.md docs: update readme.md 2023-11-08 19:51:14 +08:00
test.nim init 2023-10-31 17:57:48 +08:00

ASTIIFE

AST IIFE for nim. Generate code with AST.

Example:

import astiife

ast:
  result = newStmtList()
  for i in ["", "8", "16", "32", "64"]:
    for j in ["int", "uint"]:
      let t = ident(j & i)
      let s = newLit(j & i)
      result.add:
        quote do:
          proc echoIntType(it: `t`) {.used.} =
            echo `s`

Why to make this

I know this provides a very basic feature, but I really see many macros that are used at once to generate some definitions.

macro foo(x: untyped): untyped =
  # Many lines...

foo()

This is not that graceful, is it? So I made this. I know maybe IIFE isn't a very proper name for macros, as IIFE contains a "function" in it. But it's intuitive enough, isn't it?