def AaGSeq.matches

bend-osdev-apparmor@0.1.0.0 · glob.bend:67

import bend-osdev-apparmor@0.1.0.0/glob.bend as Glob
import Base
import bend-osdev-apparmor@0.1.0.0/text.bend as X

67def AaGSeq.matches(+seq: List<&2, AaGTok>, s: List<&2, U32>) -> Bool:
68  match seq:
69    case Nil{}:
70      X.AaText.is_nil(s)
71    case Con{AaGChar{c}, r}:
72      match s:
73        case Nil{}:
74          False{}
75        case Con{h, t}:
76          Bool.and(U32.is_eq(h, c), AaGSeq.matches(r, t))
77    case Con{AaGAny{}, r}:
78      match s:
79        case Nil{}:
80          False{}
81        case Con{h, t}:
82          Bool.and(U32.is_ne(h, 47), AaGSeq.matches(r, t))
83    case Con{AaGClass{neg, rs}, r}:
84      match s:
85        case Nil{}:
86          False{}
87        case Con{h, t}:
88          Bool.and(AaGClass.has(neg, rs, h), AaGSeq.matches(r, t))
89    case Con{AaGStar{}, r}:
90      match s:
91        case Nil{}:
92          AaGSeq.matches(r, Nil{})
93        case Con{+h, +t}:
94          Bool.or(AaGSeq.matches(r, Con{h, t}), Bool.and(U32.is_ne(h, 47), AaGSeq.matches(seq, t)))
95    case Con{AaGStar2{}, r}:
96      match s:
97        case Nil{}:
98          AaGSeq.matches(r, Nil{})
99        case Con{+h, +t}:
100          Bool.or(AaGSeq.matches(r, Con{h, t}), AaGSeq.matches(seq, t))

Uses (10)

Used by (9)