build method

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

Implementation

@override
String build(Context context, ParserResult? result) {
  final parsers = _getParsers();
  if (parsers.length < 2) {
    throw StateError('The list of parsers must contain at least 2 elements');
  }

  var template = '{{next}}';
  for (var i = 0; i < parsers.length; i++) {
    final parser = parsers[i];
    final values = {
      'p1': parser.build(context, result),
    };
    final isLast = i == parsers.length - 1;
    final templateParser =
        render2(isLast, _templateLast, _templateParser, values);
    values.clear();
    values.addAll({
      'next': templateParser,
    });
    template = render(template, values);
  }

  return render(template, {});
}