Skip to content

With1<A>

extension typeWith1<A>(Parser0<A>)

A view of a Parser0 that exposes combinators returning Parser.

Obtained via Parser0.with1. Use it when you need to sequence a Parser0 with a Parser and want the result to be typed as Parser.

Constructors

With1()

With1(Parser0<A>parser)

Properties

parser final

finalParser0<A>parser

soft no setter

Soft01<A>getsoft

Returns a Soft01 view using soft (backtracking) product combinators.

Implementation
dart
Soft01<A> get soft => Soft01(parser);

Methods

between()

Parser<A>between(Parser<dynamic>b,Parser<dynamic>c)

Matches b, then this parser, then c, returning only this parser's result. All three parsers must be Parser so the whole sequence is guaranteed to consume input.

Implementation
dart
Parser<A> between(Parser<dynamic> b, Parser<dynamic> c) =>
    b.voided.product(parser.product(c.voided)).map((tup) => tup.$2.$1);

flatMap()

Parser<B>flatMap<B>(Parser<B>Function(A)f)

Sequences this parser with f where f returns a Parser, producing a Parser result.

Implementation
dart
Parser<B> flatMap<B>(Function1<A, Parser<B>> f) => Parsers.flatMap01(parser, f);

product()

Parser<Record>product<B>(Parser<B>that)

Runs this parser then that (Parser), returning both results. The result is a Parser.

Implementation
dart
Parser<(A, B)> product<B>(Parser<B> that) => Parsers.product01(parser, that);

productL()

Parser<A>productL<B>(Parser<B>that)

Runs this parser then that, discarding that's result.

Implementation
dart
Parser<A> productL<B>(Parser<B> that) =>
    Parsers.product01(parser, Parsers.voided(that)).map((t) => t.$1);

productR()

Parser<A>productR<B>(Parser<B>that)

Runs this parser (voided) then that, returning that's result.

Implementation
dart
Parser<B> productR<B>(Parser<B> that) =>
    Parsers.product01(Parsers.voided0(parser), that).map((t) => t.$2);

surroundedBy()

Parser<A>surroundedBy(Parser<dynamic>that)

Matches that, then this parser, then that again.

Implementation
dart
Parser<A> surroundedBy(Parser<dynamic> that) => between(that, that);