tyaytypedesc.nim 424 B

12345678910111213141516171819202122
  1. discard """
  2. output: "ntWhitespace"
  3. """
  4. # bug #3357
  5. type NodeType* = enum
  6. ntWhitespace
  7. type TokenType* = enum
  8. ttWhitespace
  9. proc enumTable*[A, B, C](a: openarray[tuple[key: A, val: B]], ret: typedesc[C]): C =
  10. for item in a:
  11. result[item.key] = item.val
  12. const tokenTypeToNodeType = {
  13. ttWhitespace: ntWhitespace,
  14. }.enumTable(array[ttWhitespace..ttWhitespace, NodeType])
  15. echo tokenTypeToNodeType[ttWhitespace]