t9622.nim 595 B

12345678910111213141516171819202122232425262728293031
  1. discard """
  2. targets: "c cpp"
  3. matrix: "--mm:refc; --mm:arc"
  4. """
  5. type
  6. GlobNodeKind = enum
  7. LiteralIdent,
  8. Group
  9. GlobNode = object
  10. case kind: GlobNodeKind
  11. of LiteralIdent:
  12. value: string
  13. of Group:
  14. values: seq[string]
  15. PathSegment = object
  16. children: seq[GlobNode]
  17. GlobPattern = seq[PathSegment]
  18. proc parseImpl(): GlobPattern =
  19. if result.len == 0:
  20. result.add PathSegment()
  21. result[^1].children.add GlobNode(kind: LiteralIdent)
  22. block:
  23. const pattern = parseImpl()
  24. doAssert $pattern == """@[(children: @[(kind: LiteralIdent, value: "")])]"""