public static IParser <S, Association <O, T> > Separated <S, O, T>(this IParser <S, T> parser, IParser <S, O> separator) { return(parser .Continue(first => separator.AndThen(parser).Repeat() .Continue(rest => Parsers.Returns <S, Association <O, T> >(new Association <O, T>( @operators: rest.Fmap(_ => _.Item1), @operands: ArrayOperations.Concatenate(new T[] { first }, rest.Fmap(_ => _.Item2))))))); }
public static IParser <S, T[]> Separated <S, T>(this IParser <S, T> parser, IParser <S, Unit> separator) { return(parser .Continue(first => parser.After(separator).Repeat() .Continue(rest => Parsers.Returns <S, T[]>(ArrayOperations.Concatenate(new T[] { first }, rest))))); }