replace method

  1. @mustCallSuper
void replace(
  1. Parser source,
  2. Parser target
)

Changes the receiver by replacing source with target. Does nothing if source does not exist in Parser.children.

The following example creates a letter parser and then defines a parser called example that accepts one or more letters. Eventually the parser example is modified by replacing the letter parser with a new parser that accepts a digit. The resulting example parser accepts one or more digits.

final letter = letter();
final example = letter.plus();
example.replace(letter, digit());

Override this method and Parser.children in all subclasses that reference other parsers.

Implementation

@mustCallSuper
void replace(Parser source, Parser target) {}