summary refs log tree commit diff stats
path: root/tests/vm/t9622.nim
blob: 214ab0f193b8ad066159443240abad339453ba71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
discard """
  targets: "c cpp"
  matrix: "--gc:refc; --gc:arc"
"""

type
  GlobNodeKind = enum
    LiteralIdent,
    Group

  GlobNode = object
    case kind: GlobNodeKind
    of LiteralIdent:
      value: string
    of Group:
      values: seq[string]

  PathSegment = object
    children: seq[GlobNode]

  GlobPattern = seq[PathSegment]

proc parseImpl(): GlobPattern =
  if result.len == 0:
    result.add PathSegment()
  result[^1].children.add GlobNode(kind: LiteralIdent)

block:
  const pattern = parseImpl()
  doAssert $pattern == """@[(children: @[(kind: LiteralIdent, value: "")])]"""