示例#1
0
        public override IEnumerable <MatchResult> Match(Value v, MatchContext context)
        {
            if (!(v is ExpressionValue expr))
            {
                return(new MatchResult[0]);
            }

            return(_head.Match(expr.Head, context)
                   .SelectMany(res => PatternMatching.SequenceMatch(_parts, expr.Parts, res.Context)
                               .Select(partRes => partRes.Context.WithMatch(_engine.Expr(
                                                                                _engine.PatternMatching.ToSingle(res.SequenceMatch),
                                                                                partRes.SequenceMatch
                                                                                )))));
        }