parameterSegment property

Parser<ParameterSegment> parameterSegment
final

Implementation

static final Parser<ParameterSegment> parameterSegment = chain([
  parameterName,
  match<bool>('?').value((r) => true).opt(),
  regExp.opt(),
]).map((r) {
  var match = r.value[0] as Match;
  var rgxMatch = r.value[2] as Match;

  var pre = match[1] ?? '';
  var post = match[3] ?? '';
  RegExp rgx;

  if (rgxMatch != null) {
    rgx = RegExp('(${rgxMatch[1]})');
    post = (rgxMatch[2] ?? '') + post;
  }

  if (pre.isNotEmpty || post.isNotEmpty) {
    if (rgx != null) {
      var pattern = pre + rgx.pattern + post;
      rgx = RegExp(pattern);
    } else {
      rgx = RegExp('$pre$notSlashRgx$post');
    }
  }

  var s = ParameterSegment(match[2], rgx);
  return r.value[1] == true ? OptionalSegment(s) : s;
})