using CanonSharp.Combinator.Abstractions; namespace CanonSharp.Combinator.Parsers.Bases; /// /// 修正?解析器 /// 感觉是一种递归的高级实现? /// /// /// /// internal sealed class FixParser : Parser { private readonly Parser _parser; public FixParser(Func, Parser> func) { _parser = func(this); } internal override ParseResult Run(TState state, Func, ParseResult> continuation) => _parser.Run(state, continuation); } internal sealed class FixParser( Func>, TParameter, Parser> func, TParameter parameter) : Parser { internal override ParseResult Run(TState state, Func, ParseResult> continuation) => func(p => new FixParser(func, p), parameter).Run(state, continuation); }