Skip to content

Commit 4f12c9b

Browse files
committed
fix work with string format
1 parent 9c2edb4 commit 4f12c9b

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

src/SimpleStateMachine.StructuralSearch.Sandbox/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ internal static class Program
1414
static void Main(string[] args)
1515
{
1616
var tesds = ParametersParser.StringFormatParameter.ParseOrThrow("\"tfasdfa\\\"sd$var$.Lenght\"");
17-
var rule = StructuralSearch.ParseFindRule("$var$ equals $var$.Lenght and Not StartsWith \"123\"");
17+
18+
19+
var rule = StructuralSearch.ParseFindRule("$var$ equals $var$.Lenght and Not StartsWith \"123\\\" $var$ \\\"\"");
1820
var rule2 = StructuralSearch.ParseFindRule("$var$ equals $var$.Offset.Start and Not StartsWith \"123\"");
1921
var result1 = rule.Execute("test");
2022
var result2 = rule.Execute("10");

src/SimpleStateMachine.StructuralSearch/Rule/ParametersParser.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@ public static class ParametersParser
1414
.TrimStart()
1515
.Try();
1616

17-
public static readonly Parser<char, IRuleParameter> Parameter =
18-
Parser.OneOf(PlaceholderPropertyParser.PlaceholderPropertyParameter, PlaceholderParameter);
19-
20-
public static readonly Parser<char, IEnumerable<IRuleParameter>> Parameters =
21-
Parameter.AtLeastOnce();
22-
2317
public static readonly Parser<char, IRuleParameter> StringParameter =
2418
CommonParser.Escaped(Constant.DoubleQuotes, Constant.PlaceholderSeparator)
2519
.Or(Parser.AnyCharExcept(Constant.DoubleQuotes, Constant.PlaceholderSeparator))
2620
.AtLeastOnceString()
2721
.Select(x => new StringParameter(x))
2822
.As<char, StringParameter, IRuleParameter>()
23+
.TrimStart()
2924
.Try();
3025

3126
public static readonly Parser<char, IRuleParameter> StringFormatParameter =
@@ -36,5 +31,14 @@ public static class ParametersParser
3631
.As<char, StringFormatParameter, IRuleParameter>()
3732
.TrimStart()
3833
.Try();
34+
35+
public static readonly Parser<char, IRuleParameter> Parameter =
36+
Parser.OneOf(PlaceholderPropertyParser.PlaceholderPropertyParameter, PlaceholderParameter, StringFormatParameter)
37+
.TrimStart()
38+
.Try();
39+
40+
public static readonly Parser<char, IEnumerable<IRuleParameter>> Parameters =
41+
Parameter.AtLeastOnce();
42+
3943
}
4044
}

src/SimpleStateMachine.StructuralSearch/Rule/RuleParser.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/SimpleStateMachine.StructuralSearch/StructuralSearch/FindRulesParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace SimpleStateMachine.StructuralSearch
99
{
10-
internal static class FindRuleParser
10+
public static class FindRuleParser
1111
{
1212
internal static Parser<char, Func<IRule, IRule, IRule>> Binary(Parser<char, BinaryRuleType> op)
1313
=> op.Select<Func<IRule, IRule, IRule>>(type => (l, r) => new BinaryRule(type, l, r));
@@ -36,7 +36,7 @@ internal static readonly Parser<char, Func<IRule, IRule, IRule>> XNOR
3636
internal static readonly Parser<char, Func<IRule, IRule>> Not
3737
= Unary(Parsers.EnumValue(UnaryRuleType.Not, true).TrimStart());
3838

39-
internal static readonly Parser<char, IRule> Expr = ExpressionParser.Build<char, IRule>(
39+
public static readonly Parser<char, IRule> Expr = ExpressionParser.Build<char, IRule>(
4040
rule => (
4141
Parser.OneOf(
4242
SubRuleParser.UnarySubRule,

0 commit comments

Comments
 (0)