tyaytypedesc.nim 402 B

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