parseReg function

void parseReg(
  1. Map<String, dynamic> obj,
  2. Map<String, dynamic> location,
  3. String content
)

Implementation

void parseReg(
    Map<String, dynamic> obj, Map<String, dynamic> location, String content) {
  var needsBlank = obj['name'] != null && obj['names'] != null;
  if (obj['push'] != null && location[obj['push']] == null) {
    assert(obj['push'] != null);
    location[obj['push']] = [];
  } else if (needsBlank && location[obj['name']] == null) {
    assert(obj['name'] != null);
    location[obj['name']] = createMap();
  }

  var keyLocation = obj['push'] != null
      ? createMap()
      : // blank object that will be pushed
      needsBlank
          ? location[obj['name']]
          : location; // otherwise, named location or root

  if (obj['reg'] is RegExp) {
    attachProperties(
        obj['reg'].allMatches(content), keyLocation, obj['names'], obj['name']);
  } else {
    attachProperties(RegExp(obj['reg']).allMatches(content), keyLocation,
        obj['names'], obj['name']);
  }

  if (obj['push'] != null) {
    location[obj['push']].add(keyLocation);
  }
}