build method

  1. @override
String build(
  1. Context context,
  2. ParserResult? result
)
override

Implementation

@override
String build(Context context, ParserResult? result) {
  if (m < 0) {
    throw RangeError.value(m, 'm', 'Must be equal to or greater than 0');
  }

  if (n < m) {
    throw RangeError.value(
        n, 'n', 'Must be equal to or greater than \'m\' ($m)');
  }

  if (n == 0) {
    throw RangeError.value(n, 'n', 'Must be greater than 0');
  }

  context.refersToStateSource = true;
  final fast = result == null;
  final values = context.allocateLocals(['count', 'pos']);
  final isUnicode = predicate.isUnicode;
  values.addAll({
    'm': '$m',
    'n': '$n',
    'test': predicate.build(context, 'test', ['c']),
  });
  final String template;
  if (isUnicode) {
    if (fast) {
      template = _template32Fast;
    } else {
      template = _template32;
    }
  } else {
    if (fast) {
      template = _template16Fast;
    } else {
      template = _template16;
    }
  }

  return render(template, values, [result]);
}