Skip to content

Commit

Permalink
Make DSL interpret sym nodes as ident nodes (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabricio-p authored Nov 10, 2024
1 parent 937b290 commit 2535236
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/arraymancer/nn/nn_dsl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import
macros

const IdentLike = {nnkIdent, nnkSym, nnkOpenSymChoice}

type
SectionInfo = object
Expand Down Expand Up @@ -63,17 +64,25 @@ proc createLayerInfo(sectionInfo: SectionInfo): seq[LayerInfo] =

if layer.kind != nnkCall or
layer.len != 2 or
layer[0].kind != nnkIdent or
layer[0].kind notin IdentLike or
layer[1].kind != nnkStmtList or
layer[1].len != 1 or
layer[1][0].kind != nnkCall or
layer[1][0].len < 1 or
layer[1][0][0].kind != nnkIdent:
layer[1][0][0].kind notin IdentLike:
error("Unknown configuration of layer section: \"" & $toStrLit(layer) & "\"", layer)

let
nameNode = layer[0]
typeNameNode = layer[1][0][0]

result.add LayerInfo(
name: layer[0],
typeName: layer[1][0][0]
name:
if nameNode.kind != nnkOpenSymChoice: nameNode
else: nameNode.repr.ident(),
typeName:
if typeNameNode.kind != nnkOpenSymChoice: typeNameNode
else: typeNameNode.repr.ident(),
)
if layer[1][0].len >= 2:
result[^1].arguments = layer[1][0][1..^1]
Expand Down

0 comments on commit 2535236

Please sign in to comment.