alehander92 / gara

MIT License
103 stars 4 forks source link

Multiple multiple capturing (asterisk) #4

Open Leu-Gim opened 5 years ago

Leu-Gim commented 5 years ago
let b = @[0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5]
type A = 2..4
match(b):
of @[*_, *A @t, *_, A @u, *_]:
  assert t == @[2, 3, 4]
  assert u == 2

Like in regular expressions. Even a limited version - just skipping (*_) at beginning, skipping at the end, and multi-capture between - would be of much value, and in such version it doesn't need re-matching (i.e. trying other combination after failure).