Skip to content

Commit e47385d

Browse files
committed
fix parsing whitespaces
1 parent 3418f69 commit e47385d

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

src/SimpleStateMachine.StructuralSearch/Parsers/PlaceholderParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public override Parser<char, string> BuildParser(Func<Parser<char, string>?> nex
2020
Func<Parser<char, string>?> nextNext)
2121
{
2222
var _next = next();
23-
var _nextNext = nextNext() ?? Parser<char>.End.ThenReturn(string.Empty);
23+
var _nextNext = nextNext() ?? Parser.OneOf(CommonParser.WhiteSpaces, Parser<char>.End.ThenReturn(string.Empty));
2424
var lookahead = Parsers.Lookahead(_next.Then(_nextNext, (s1, s2) =>
2525
{
2626
OnLookahead = () => new List<LookaheadResult<char, string>>

src/SimpleStateMachine.StructuralSearch/Rules/Parameters/PlaceholderFileParameter.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public string GetValue()
2525
FileProperty.Lenght => input.Lenght.ToString(),
2626
_ => throw new ArgumentOutOfRangeException()
2727
};
28-
29-
return null;
3028
}
3129

3230
public override string ToString()

src/SimpleStateMachine.StructuralSearch/SeriesParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public override bool TryParse(ref ParseState<char> state, ref PooledList<Expecte
2727
var parser = Parsers.ElementAt(i);
2828
if (!parser.TryParse(ref state, ref expecteds, out var _result))
2929
{
30-
result = Enumerable.Empty<string>();
30+
result = results;
3131
return false;
3232
}
3333

src/SimpleStateMachine.StructuralSearch/StructuralSearch/CommonParser.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ internal static readonly Parser<char, string> LineEnds
2525
= EndOfLine.AtLeastOnceString();
2626

2727
internal static readonly Parser<char, string> WhiteSpaces
28-
= OneOf(Spaces, LineEnds);
28+
= OneOf(Spaces, LineEnds, LineEnds)
29+
.AtLeastOnceString();
2930

3031
internal static readonly Parser<char, string> Identifier
3132
= Letter.Then(AnyString, (h, t) => h + t);

src/SimpleStateMachine.StructuralSearch/StructuralSearch/FindTemplateParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static FindTemplateParser()
3232
.Try();
3333

3434
internal static readonly Parser<char, Parser<char, string>> WhiteSpaces =
35-
ParserToParser.ResultAsParser(CommonParser.WhiteSpaces)
35+
ParserToParser.ParserAsParser(CommonParser.WhiteSpaces)
3636
.Try();
3737

3838
internal static readonly Parser<char, Parser<char, string>> Placeholder =

src/SimpleStateMachine.StructuralSearch/Templates/FindTemplate/ParserToParser.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public static Parser<char, Parser<char, string>> ResultAsParser(Parser<char, str
2727
return parser.Select(value => Parsers.String(value, ignoreCase));
2828
}
2929

30+
public static Parser<char, Parser<char, string>> ParserAsParser(Parser<char, string> parser)
31+
{
32+
return parser.Select(value => parser);
33+
}
34+
3035
public static Parser<char, Parser<char, SourceMatch>> ResultAsMatch(Parser<char, string> parser, bool ignoreCase = false)
3136
{
3237
return parser.Select(x=> Parsers.String(x, ignoreCase).AsMatch());

0 commit comments

Comments
 (0)