From e382833aa88d9b36df47fc48924a0b61a2c7baa9 Mon Sep 17 00:00:00 2001 From: Andrea Ferretti Date: Thu, 2 Jul 2015 20:19:50 +0200 Subject: [PATCH] minor --- patty.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/patty.nim b/patty.nim index 3690193..4d0809a 100644 --- a/patty.nim +++ b/patty.nim @@ -41,7 +41,7 @@ proc makeBranch(n: NimNode): NimNode {. compileTime .} = else: error("Invalid ADT case: " & $(toStrLit(n))) -macro adt*(e: expr, body: stmt): stmt {. immediate .} = +proc defineTypes(e, body: NimNode): NimNode {. compileTime .} = e.expectKind(nnkIdent) body.expectKind(nnkStmtList) # The children of the body should look like object constructors @@ -72,6 +72,9 @@ macro adt*(e: expr, body: stmt): stmt {. immediate .} = result = newNimNode(nnkTypeSection) result.add(enumType) result.add(definedType) + +macro adt*(e: expr, body: stmt): stmt {. immediate .} = + result = defineTypes(e, body) when defined(pattydebug): echo toStrLit(result)