breeze
A dsl for writing macros in Nim
Summary
| Latest Version | Unknown |
|---|---|
| License | MIT |
| CI Status | Passing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:24 |
Tags
Installation
nimble install breeze
choosenim install breeze
git clone https://github.com/alehander42/breeze
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| breeze | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Source
| Repository | https://github.com/alehander42/breeze |
|---|---|
| Homepage | https://github.com/alehander42/breeze |
| Documentation | View Documentation |
| Registry Source | nimble_official |
README
breeze
A dsl for writing macros in Nim
rationale
I read a comment by Araq about how karax might be a good fit for the ast nodes in
the compiler and I've always found building the nodes in macro-s in Nim tedious.
breeze is a karax-like dsl for building nim nodes in macros:
macro s(b: untyped): untyped =
var e = newIdentNode(!"e")
result = buildMacro:
call:
dotExpr(e, ident("f"))
infix(ident("+"), 2, 3)
expands to
nnkCall.newTree(nnkDotExpr.newTree(e, newIdentNode(! "f")),
nnkInfix.newTree(newIdentNode(! "+"), newLit(2), newLit(3)))
It's equivalent to
macro s(b: untyped): untyped =
var e = newIdentNode(!"e")
result = buildMacro:
call:
dotExpr:
e
ident("f")
infix:
ident("+")
2
3
functionality
You use it invoking buildMacro with a singular child corresponding to the node you want to build
Each child is either of the form
node:
child
child
or
node(child, child)
They're equivalent in most cases and they usually expand to nnk<capitalized_node>.newTree(<visited children>)
Special cases are literals which are expanded to newLit and ident(name) which are expanded to newIdentNode.
You can build dynamically macros (with variables) just by passing them directly, e.g.
var e = newIdentNode(!"f")
result = buildMacro:
call:
e
expands to
Call
Ident !"f"