25 lines
711 B
C#
25 lines
711 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> : Parser<TToken, T>
|
||
|
{
|
||
|
private readonly Parser<TToken, T> _parser;
|
||
|
|
||
|
public FixParser(Func<Parser<TToken, T>, Parser<TToken, T>> func)
|
||
|
{
|
||
|
_parser = func(this);
|
||
|
}
|
||
|
|
||
|
internal override ParseResult<TToken, TResult> Run<TState, TResult>(TState state,
|
||
|
Func<ParseResult<TToken, T>, ParseResult<TToken, TResult>> continuation)
|
||
|
=> _parser.Run(state, continuation);
|
||
|
}
|