From 65d4d0e6e847657e94723aaccfeb5ff2ba65c8b3 Mon Sep 17 00:00:00 2001
From: jackfiled <xcrenchangjun@outlook.com>
Date: Tue, 13 Aug 2024 22:42:11 +0800
Subject: [PATCH] chore: remove unused code.

---
 CanonSharp.Combinator/Abstractions/ParseResult.cs        | 5 -----
 CanonSharp.Combinator/ParserBuilder.cs                   | 3 +--
 CanonSharp.Combinator/Parsers/Bases/FixParser.cs         | 9 ---------
 CanonSharp.Common/CanonSharp.Common.csproj               | 4 ++++
 .../CombinatorsTests/CombinatorParserTests.cs            | 3 ++-
 .../CombinatorsTests/PrimitiveParserTests.cs             | 7 +++++++
 6 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/CanonSharp.Combinator/Abstractions/ParseResult.cs b/CanonSharp.Combinator/Abstractions/ParseResult.cs
index 7f58852..e38be41 100644
--- a/CanonSharp.Combinator/Abstractions/ParseResult.cs
+++ b/CanonSharp.Combinator/Abstractions/ParseResult.cs
@@ -12,11 +12,6 @@ public abstract class ParseResult<TToken, T>
     /// </summary>
     public abstract T Value { get; }
 
-    protected ParseResult()
-    {
-
-    }
-
     /// <summary>
     /// 在当前结果上应用下一个解析器
     /// </summary>
diff --git a/CanonSharp.Combinator/ParserBuilder.cs b/CanonSharp.Combinator/ParserBuilder.cs
index 5d84120..b4bde54 100644
--- a/CanonSharp.Combinator/ParserBuilder.cs
+++ b/CanonSharp.Combinator/ParserBuilder.cs
@@ -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
 }
diff --git a/CanonSharp.Combinator/Parsers/Bases/FixParser.cs b/CanonSharp.Combinator/Parsers/Bases/FixParser.cs
index a8f3b3a..81b9bab 100644
--- a/CanonSharp.Combinator/Parsers/Bases/FixParser.cs
+++ b/CanonSharp.Combinator/Parsers/Bases/FixParser.cs
@@ -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);
-}
diff --git a/CanonSharp.Common/CanonSharp.Common.csproj b/CanonSharp.Common/CanonSharp.Common.csproj
index fbfc2bd..4359b8a 100644
--- a/CanonSharp.Common/CanonSharp.Common.csproj
+++ b/CanonSharp.Common/CanonSharp.Common.csproj
@@ -15,4 +15,8 @@
       <ProjectReference Include="..\CanonSharp.Combinator\CanonSharp.Combinator.csproj" />
     </ItemGroup>
 
+    <ItemGroup>
+      <Folder Include="SyntaxTree\" />
+    </ItemGroup>
+
 </Project>
diff --git a/CanonSharp.Tests/CombinatorsTests/CombinatorParserTests.cs b/CanonSharp.Tests/CombinatorsTests/CombinatorParserTests.cs
index 25c4eed..b70d3be 100644
--- a/CanonSharp.Tests/CombinatorsTests/CombinatorParserTests.cs
+++ b/CanonSharp.Tests/CombinatorsTests/CombinatorParserTests.cs
@@ -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");
     }
 
diff --git a/CanonSharp.Tests/CombinatorsTests/PrimitiveParserTests.cs b/CanonSharp.Tests/CombinatorsTests/PrimitiveParserTests.cs
index 504af07..39d1825 100644
--- a/CanonSharp.Tests/CombinatorsTests/PrimitiveParserTests.cs
+++ b/CanonSharp.Tests/CombinatorsTests/PrimitiveParserTests.cs
@@ -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()
     {