public IParserResult <Tuple <R2, R1> > Parse(ParserInput input) { var firstResult = this.FirstParser.Parse(input); if (!firstResult.IsSuccessful) { return(new ParserFailed <Tuple <R2, R1> >()); } var secondResult = this.SecondParser.Parse(firstResult.ToInput()); if (!secondResult.IsSuccessful) { return(new ParserFailed <Tuple <R2, R1> >()); } return(ParserSucceeded.Create(Tuple.Create(secondResult.Result, firstResult.Result), secondResult.Environment, secondResult.Source)); }
public IParserResult <R> Parse(ParserInput input) { var firstResult = this.Parser.Parse(input); if (!firstResult.IsSuccessful) { return(new ParserFailed <R>()); } var secondResult = this.Consumer.Consume(firstResult.ToInput()); if (!secondResult.IsSuccessful) { return(new ParserFailed <R>()); } return(ParserSucceeded.Create(firstResult.Result, secondResult.Environment, secondResult.Source)); }
public IParserResult <R> Transform(S seed, ParserInput input) { var result1 = this.Transformer.Transform(seed, input); if (!result1.IsSuccessful) { return(result1); } var result2 = this.Consumer.Consume(result1.ToInput()); if (!result2.IsSuccessful) { return(new ParserFailed <R>()); } return(ParserSucceeded.Create(result1.Result, result2.Environment, result2.Source)); }
public IParserResult <Tuple <R2, R1> > Transform(S seed, ParserInput input) { var result1 = this.Transformer.Transform(seed, input); if (!result1.IsSuccessful) { return(new ParserFailed <Tuple <R2, R1> >()); } var result2 = this.Parser.Parse(result1.ToInput()); if (!result2.IsSuccessful) { return(new ParserFailed <Tuple <R2, R1> >()); } return(ParserSucceeded.Create(Tuple.Create(result2.Result, result1.Result), result2.Environment, result2.Source)); }
public IParserResult <R> Transform(R seed, ParserInput input) { var curResult = this.Transformer.Transform(seed, input); if (!curResult.IsSuccessful) { return(new ParserFailed <R>()); } IParserResult <R> lastSuccessfulResult; do { lastSuccessfulResult = curResult; curResult = this.Transformer.Transform(lastSuccessfulResult.Result, lastSuccessfulResult.ToInput()); } while (curResult.IsSuccessful); return(lastSuccessfulResult); }
public IParserResult <ImmutableList <R> > Parse(ParserInput input) { var list = ImmutableList <R> .Empty; var curResult = this.Parser.Parse(input); if (!curResult.IsSuccessful) { return(new ParserFailed <ImmutableList <R> >()); } IParserResult <R> lastSuccessfulResult; do { list = list.Add(curResult.Result); lastSuccessfulResult = curResult; curResult = this.Parser.Parse(lastSuccessfulResult.ToInput()); } while (curResult.IsSuccessful); return(ParserSucceeded.Create(list, lastSuccessfulResult.Environment, lastSuccessfulResult.Source)); }
public IParserResult <R> Transform(R seed, ParserInput input) => this.TransformFunc(ParserSucceeded.Create(seed, input.Environment, input.Source));
public IParserResult <R> Transform(S seed, ParserInput input) => this.Transformer.Value.Transform(seed, input);
public IParserResult Consume(ParserInput input) { return(ParserSucceeded.Create(this.Transformer(input.Environment), input.Source)); }
public IParserResult Consume(ParserInput input) => this.Consumer.Value.Consume(input);
public IParserResult <R> Parse(ParserInput input) => ParserSucceeded.Create(this.Result, input.Environment, input.Source);
public IParserResult <R> Parse(ParserInput input) => this.Parser.Value.Parse(input);