you might also try something like this
    
    
    import macros
    
    #const CX = "8"
    const CX = "7"
    macro process_const_str(s: static[string]): typed =
      result = newNimNode(nnkStmtList)
      if s[0] == '7':
          for i in 0..<3:
            result.add newCall("echo", newLit"is 7")
      else:
          for i in 0..<2:
            result.add newCall("echo", newLit"not 7")
    
    macro prep(s: static[string]): typed =
          result = newNimNode(nnkStmtList)
          # this generate the string constant symbol from `s`
          # and call a secondary level macro that parse the const string to 
generate
          # some code.
          result.add newCall("process_const_str", newIdentNode("C" & $s))
    
    prep("X")
    
    

Reply via email to