CanonSharp/CanonSharp.Combinator/Extensions/ReadStateExtensions.cs
jackfiled 3ed8bf5d36
All checks were successful
Run unit test / Unit-Test (push) Successful in 41s
feat: Parser Combinator库和词法分析器 (#2)
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>
2024-08-13 14:46:11 +08:00

19 lines
438 B
C#

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;
}
}
}