chore: remove unused code.
This commit is contained in:
parent
3ed8bf5d36
commit
65d4d0e6e8
|
@ -12,11 +12,6 @@ public abstract class ParseResult<TToken, T>
|
|||
/// </summary>
|
||||
public abstract T Value { get; }
|
||||
|
||||
protected ParseResult()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在当前结果上应用下一个解析器
|
||||
/// </summary>
|
||||
|
|
|
@ -157,7 +157,7 @@ public static class ParserBuilder
|
|||
/// <returns></returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Parser<TToken, T> Choice<TToken, T>(IEnumerable<Parser<TToken, T>> parsers)
|
||||
=> parsers.Reverse().Aggregate((next, parser) => parser.Alternative(next));
|
||||
=> parsers.Aggregate((result, parser) => result.Alternative(parser));
|
||||
|
||||
/// <summary>
|
||||
/// 按照给定的解析器组依次尝试
|
||||
|
@ -218,6 +218,5 @@ public static class ParserBuilder
|
|||
public static Parser<TToken, IEnumerable<TToken>> Take1Till<TToken, TIgnore>(Parser<TToken, TIgnore> termintor)
|
||||
=> Any<TToken>().Many1Till(termintor);
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -22,12 +22,3 @@ internal sealed class FixParser<TToken, T> : Parser<TToken, T>
|
|||
Func<ParseResult<TToken, T>, ParseResult<TToken, TResult>> continuation)
|
||||
=> _parser.Run(state, continuation);
|
||||
}
|
||||
|
||||
internal sealed class FixParser<TToken, TParameter, T>(
|
||||
Func<Func<TParameter, Parser<TToken, T>>, TParameter, Parser<TToken, T>> func,
|
||||
TParameter parameter) : Parser<TToken, T>
|
||||
{
|
||||
internal override ParseResult<TToken, TResult> Run<TState, TResult>(TState state,
|
||||
Func<ParseResult<TToken, T>, ParseResult<TToken, TResult>> continuation)
|
||||
=> func(p => new FixParser<TToken, TParameter, T>(func, p), parameter).Run(state, continuation);
|
||||
}
|
||||
|
|
|
@ -15,4 +15,8 @@
|
|||
<ProjectReference Include="..\CanonSharp.Combinator\CanonSharp.Combinator.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="SyntaxTree\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -28,7 +28,8 @@ public class CombinatorParserTests : ParserTestsBase
|
|||
Parser<char, IEnumerable<char>> parser = Sequence(Token('a'), Token('b'), Token('c'));
|
||||
ValidateSuccessfulResult(parser, ['a', 'b', 'c'], "abc");
|
||||
|
||||
parser = Sequence([Token('a'), Token('b'), Token('c')]);
|
||||
IEnumerable<Parser<char, char>> parsers = [Token('a'), Token('b'), Token('c')];
|
||||
parser = Sequence(parsers);
|
||||
ValidateSuccessfulResult(parser, ['a', 'b', 'c'], "abc");
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,13 @@ public class PrimitiveParserTests : ParserTestsBase
|
|||
ValidateFailedResult(parser, "123");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SatisfyFailedTest()
|
||||
{
|
||||
Parser<char, char> parser = Satisfy<char>(char.IsLetter);
|
||||
ValidateFailedResult(parser, "");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnyTest()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user