wrapper<O, V> method

void wrapper<O, V>(
  1. Parser<O> left,
  2. Parser<O> right, [
  3. dynamic action(
    1. O left,
    2. V value,
    3. O right
    )?
])

Defines a new wrapper using left and right parsers, that are typically used for parenthesis. Evaluates the optional action with the parsed left delimiter, the value and right delimiter.

Implementation

void wrapper<O, V>(Parser<O> left, Parser<O> right,
    [dynamic Function(O left, V value, O right)? action]) {
  final callback = action ?? (left, value, right) => [left, value, right];
  _wrappers.add([left, _loopback, right]
      .toSequenceParser()
      .map((value) => callback(value[0], value[1], value[2])));
}