Something to inspire you:
    
    
    import macros
    
    template recursive(node, action): untyped {.dirty.} =
      proc helper(n: NimNode): NimNode {.gensym.} =
        action
        result = copyNimNode(n)
        for i in 0 ..< n.len:
          result.add helper(n[i])
      helper(node)
    
    template match(n, x): untyped =
      template arg: untyped = x
      n == getAst(arg())[0]
    
    macro replace90by100(n: untyped): untyped =
      recursive(n):
        if match(n, 90):
          return newLit(100)
    
    echo replace90by100(@[90, 100, 90])
    

Reply via email to