then<R2> method

  1. @useResult
SequenceParser2<R1, R2> then<R2>(
  1. Parser<R2> other
)

Returns a parser that sequences the receiver and other, returning their results as a typed 2-element Record.

Unlike seq, which returns an untyped List<dynamic>, then preserves the static types of all matched parsers. Chained invocations of then flatten automatically into larger typed records up to 9 elements.

For example:

// Produces a (String, int) record:
final pair = letter().then(digit().map(int.parse));

// Flattens into a 3-element record (String, int, String):
final triplet = pair.then(letter());

Implementation

@useResult
SequenceParser2<R1, R2> then<R2>(Parser<R2> other) =>
    SequenceParser2<R1, R2>(this, other);