jackfiled
cf19f8197e
Reviewed-on: https://git.bupt-hpc.cn/jackfiled/CanonSharp/pulls/3 Co-authored-by: jackfiled <xcrenchangjun@outlook.com> Co-committed-by: jackfiled <xcrenchangjun@outlook.com>
26 lines
757 B
C#
26 lines
757 B
C#
using CanonSharp.Combinator.Abstractions;
|
|
|
|
namespace CanonSharp.Combinator.Parsers.Bases;
|
|
|
|
/// <summary>
|
|
/// 修正?解析器
|
|
/// 感觉是一种递归的高级实现?
|
|
///
|
|
/// </summary>
|
|
/// <typeparam name="TToken"></typeparam>
|
|
/// <typeparam name="T"></typeparam>
|
|
internal sealed class FixParser<TToken, T> : IParser<TToken, T>
|
|
{
|
|
private readonly IParser<TToken, T> _parser;
|
|
|
|
public FixParser(Func<IParser<TToken, T>, IParser<TToken, T>> func)
|
|
{
|
|
_parser = func(this);
|
|
}
|
|
|
|
public IParseResult<TToken, TResult> Run<TState, TResult>(TState state,
|
|
Func<IParseResult<TToken, T>, IParseResult<TToken, TResult>> continuation)
|
|
where TState : IReadState<TToken, TState>
|
|
=> _parser.Run(state, continuation);
|
|
}
|