replace method
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
@override
void replace(Parser source, Parser target) {
super.replace(source, target);
if (delegate == source) {
delegate = target as Parser<T>;
}
}