seq method

  1. @useResult
Parser<List> seq(
  1. Parser other
)

Returns a parser that accepts the receiver followed by other. The resulting parser returns a list of the parse result of the receiver followed by the parse result of other. Calling this method on an existing sequence code does not nest this sequence into a new one, but instead augments the existing sequence with other.

For example, the parser letter().seq(digit()).seq(letter()) accepts a letter followed by a digit and another letter. The parse result of the input string 'a1b' is the list ['a', '1', 'b'].

Implementation

@useResult
Parser<List> seq(Parser other) => this is SequenceParser
    ? [...children, other].toSequenceParser()
    : [this, other].toSequenceParser();