From 1efd50210cff4e1aa01a49b54c975d0adce27103 Mon Sep 17 00:00:00 2001 From: Timerix Date: Sat, 5 Apr 2025 10:06:34 +0500 Subject: [PATCH] NoMatchExpression --- ParadoxSaveParser.Lib/SearchExpression.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ParadoxSaveParser.Lib/SearchExpression.cs b/ParadoxSaveParser.Lib/SearchExpression.cs index afa4b46..1acd038 100644 --- a/ParadoxSaveParser.Lib/SearchExpression.cs +++ b/ParadoxSaveParser.Lib/SearchExpression.cs @@ -88,7 +88,9 @@ public static class SearchExpressionCompiler remaining = query.Slice(partBeforePointLength + 1); if (part is "*") return new AnyMatchExpression(remaining.IsEmpty ? null : Compile(remaining)); - + if (part is "~") + return new NoMatchExpression(); + for (int j = 0; j < part.Length; j++) if (CharEqualsAndNotEscaped('*', part, j)) 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 subExprs) : ISearchExpression { public bool DoesMatch(SearchArgs args, out ISearchExpression? nextSearchExpression)