build<T> method Null safety

Parser<T> build<T>(
  1. {Function? start,
  2. List<Object> arguments = const []}
)

Builds a composite parser from this definition.

The optional start reference specifies a different starting production into the grammar. The optional arguments list parametrizes the called production.

Implementation

Parser<T> build<T>({Function? start, List<Object> arguments = const []}) {
  if (start != null) {
    return resolve(Function.apply(start, arguments));
  } else if (arguments.isEmpty) {
    return resolve(this.start() as Parser<T>);
  } else {
    throw StateError('Invalid arguments passed.');
  }
}