If I understand you correctly, here you go: 
    
    
    import macros
    
    type
      Foo = enum
        foo = "Foo"
        bar = "Bar"
        more = "More"
    
    macro enumFields(n: typed): untyped =
      let impl = getType(n)
      expectKind impl[1], nnkEnumTy
      result = nnkBracket.newTree()
      for f in impl[1]:
        case f.kind
        of nnkSym, nnkIdent:
          result.add newLit(f.strVal)
        else: discard
    
    for f in enumFields(Foo):
      echo f
    
    
    Run

Reply via email to