summary refs log tree commit diff stats
path: root/tests/generics/tgenericmatcher.nim
blob: ca4dc2a4d4cc5d778787b146aa64cbc5f41dff57 (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
31
32
33
34
35
36
37
38
39
40
discard """
  output: '''
'''
"""


block tmatcher1:
  type
    TMatcherKind = enum
      mkTerminal, mkSequence, mkAlternation, mkRepeat
    TMatcher[T] = object
      case kind: TMatcherKind
      of mkTerminal:
        value: T
      of mkSequence, mkAlternation:
        matchers: seq[TMatcher[T]]
      of mkRepeat:
        matcher: PMatcher[T]
        min, max: int
    PMatcher[T] = ref TMatcher[T]

  var m: PMatcher[int]


block tmatcher2:
  type
    TMatcherKind = enum
      mkTerminal, mkSequence, mkAlternation, mkRepeat
    TMatcher[T] = object
      case kind: TMatcherKind
      of mkTerminal:
        value: T
      of mkSequence, mkAlternation:
        matchers: seq[TMatcher[T]]
      of mkRepeat:
        matcher: ref TMatcher[T]
        min, max: int
  
  var m: ref TMatcher[int]