namespace Sprache
{
partial class Parse
{
///
/// Construct a parser that will set the position to the position-aware
/// T on succsessful match.
///
///
///
///
public static Parser Positioned(this Parser parser) where T : IPositionAware
{
return i =>
{
var r = parser(i);
if (r.WasSuccessful)
{
return Result.Success(r.Value.SetPos(Position.FromInput(i), r.Remainder.Position - i.Position), r.Remainder);
}
return r;
};
}
}
}