def css.match
gralha-css-style@0.1.0.1 · css.bend:215
import gralha-css-style@0.1.0.1/css.bend as Css
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
215def css.match(+steps: List<&2, CSSStep>, +contexts: List<&2, CSSContext>, +one: Bool) -> Bool:
216 match steps contexts:
217 case Nil{} _: True{}
218 case Con{step, rest} Nil{}: False{}
219 case Con{CSSStep{compound, relation}, rest} Con{CSSContext{node, parents, previous, index, count}, others}:
220 +rel = relation
221 (css.simple(128n, compound, CSSContext{node, parents, previous, index, count}) &&
222 U.branch(Bool, U32.is_eq(rel, 0), _ => True{},
223 _ => css.match(rest, U.choose(List<&2, CSSContext>, U32.is_le(rel, 2), parents, previous), U32.is_eq(rel, 2) || U32.is_eq(rel, 3))))
224 || U.branch(Bool, one, _ => False{}, _ => css.match(steps, others, False{}))