buildBody method

  1. @override
BuildBodyResult buildBody(
  1. BuildContext context,
  2. bool hasResult
)
override

Builds a parser function body and returns the source code of the function body.

Implementation

@override
BuildBodyResult buildBody(BuildContext context, bool hasResult) {
  RangeError.checkNotNegative(m, 'm');
  if (n < m) {
    throw ArgumentError.value(n, 'n', 'Must be greater than or equal to $m');
  }

  final reader = getCharReader(is16BitPredicate(predicate), 'c');
  final template = m == 0 ? _template0 : _template;
  final templateNoResult = m == 0 ? _template0NoResult : _templateNoResult;
  return renderBody(
    this,
    context,
    hasResult,
    template,
    templateNoResult,
    {
      'm': getAsCode(m),
      'n': getAsCode(n),
      'predicate': predicate.calculate(context, ['c']),
      'read': reader.name,
      'size': reader.size,
    },
  );
}