tgenericmatcher.nim 803 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. discard """
  2. output: '''
  3. '''
  4. """
  5. block tmatcher1:
  6. type
  7. TMatcherKind = enum
  8. mkTerminal, mkSequence, mkAlternation, mkRepeat
  9. TMatcher[T] = object
  10. case kind: TMatcherKind
  11. of mkTerminal:
  12. value: T
  13. of mkSequence, mkAlternation:
  14. matchers: seq[TMatcher[T]]
  15. of mkRepeat:
  16. matcher: PMatcher[T]
  17. min, max: int
  18. PMatcher[T] = ref TMatcher[T]
  19. var m: PMatcher[int]
  20. block tmatcher2:
  21. type
  22. TMatcherKind = enum
  23. mkTerminal, mkSequence, mkAlternation, mkRepeat
  24. TMatcher[T] = object
  25. case kind: TMatcherKind
  26. of mkTerminal:
  27. value: T
  28. of mkSequence, mkAlternation:
  29. matchers: seq[TMatcher[T]]
  30. of mkRepeat:
  31. matcher: ref TMatcher[T]
  32. min, max: int
  33. var m: ref TMatcher[int]