NoMatchExpression

This commit is contained in:
Timerix 2025-04-05 10:06:34 +05:00
parent 5de3a94a46
commit 1efd50210c

View File

@ -88,7 +88,9 @@ public static class SearchExpressionCompiler
remaining = query.Slice(partBeforePointLength + 1); remaining = query.Slice(partBeforePointLength + 1);
if (part is "*") if (part is "*")
return new AnyMatchExpression(remaining.IsEmpty ? null : Compile(remaining)); return new AnyMatchExpression(remaining.IsEmpty ? null : Compile(remaining));
if (part is "~")
return new NoMatchExpression();
for (int j = 0; j < part.Length; j++) for (int j = 0; j < part.Length; j++)
if (CharEqualsAndNotEscaped('*', part, j)) if (CharEqualsAndNotEscaped('*', part, j))
throw new NotImplementedException("pattern matching other than '*' is not implemented yet"); throw new NotImplementedException("pattern matching other than '*' is not implemented yet");
@ -112,6 +114,15 @@ public static class SearchExpressionCompiler
} }
} }
private record NoMatchExpression : ISearchExpression
{
public bool DoesMatch(SearchArgs args, out ISearchExpression? nextSearchExpression)
{
nextSearchExpression = null;
return false;
}
}
private record MultipleMatchExpression(List<ISearchExpression> subExprs) : ISearchExpression private record MultipleMatchExpression(List<ISearchExpression> subExprs) : ISearchExpression
{ {
public bool DoesMatch(SearchArgs args, out ISearchExpression? nextSearchExpression) public bool DoesMatch(SearchArgs args, out ISearchExpression? nextSearchExpression)