feat: Parser Combinator库和词法分析器 (#2)
All checks were successful
Run unit test / Unit-Test (push) Successful in 41s
All checks were successful
Run unit test / Unit-Test (push) Successful in 41s
Reviewed-on: https://git.bupt-hpc.cn/jackfiled/CanonSharp/pulls/2 Co-authored-by: jackfiled <xcrenchangjun@outlook.com> Co-committed-by: jackfiled <xcrenchangjun@outlook.com>
This commit is contained in:
18
CanonSharp.Combinator/Extensions/ReadStateExtensions.cs
Normal file
18
CanonSharp.Combinator/Extensions/ReadStateExtensions.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using CanonSharp.Combinator.Abstractions;
|
||||
|
||||
namespace CanonSharp.Combinator.Extensions;
|
||||
|
||||
public static class ReadStateExtensions
|
||||
{
|
||||
public static IEnumerable<TState> AsEnumerable<TToken, TState>(this TState source)
|
||||
where TState : IReadState<TToken, TState>
|
||||
{
|
||||
TState current = source;
|
||||
|
||||
while (current.HasValue)
|
||||
{
|
||||
yield return current;
|
||||
current = current.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user