Loyc.Syntax.LNodeExt.ListMatches C# (CSharp) Method

ListMatches() private static method

private static ListMatches ( VList candidates, VList patterns, LNode>.MMap &captures, VList &unmatchedAttrs ) : bool
candidates VList
patterns VList
captures LNode>.MMap
unmatchedAttrs VList
return bool
		private static bool ListMatches(VList<LNode> candidates, VList<LNode> patterns, ref MMap<Symbol, LNode> captures, ref VList<LNode> unmatchedAttrs)
		{
			if (patterns.Count != candidates.Count && !patterns.Any(IsParamsCapture))
				return false;

			// Scan from the end of the list to the beginning (RVLists is good at this),
			// matching args one-by-one. Use MatchThenParams() in case of $(params capture).
			while (!patterns.IsEmpty)
			{
				LNode pArg = patterns.Pop();
				if (IsParamsCapture(pArg))
					return MatchThenParams(candidates, patterns, pArg, ref captures, ref unmatchedAttrs);
				if (candidates.IsEmpty)
					return false;
				if (!MatchesPatternNested(candidates.Pop(), pArg, ref captures, ref unmatchedAttrs))
					return false;
			}
			return true;
		}