using CanonSharp.Combinator.Abstractions;
namespace CanonSharp.Combinator.Parsers.Bases;
///
/// 映射解析器
/// 提供一个函数修改上游解析器返回的结果
///
/// 上游解析器
/// 修改上游解析器返回结果的
///
///
///
internal sealed class MapParser(
IParser parser,
Func func) : IParser
{
public IParseResult Run(TState state,
Func, IParseResult> continuation)
where TState : IReadState
=> parser.Run(state, result => continuation(result.Map(func)));
}