/*
Parse tags to get customized parameters.
171034
protected LinkedList<APIParameter> parseCustomizedParameters(MethodDoc methodDoc) {
		Tag[] tags = methodDoc.tags(WRParamTaglet.NAME);
		LinkedList<APIParameter> result = new LinkedList<APIParameter>();
		for (int i = 0; i < tags.length; i++) {
			result.add(WRParamTaglet.parse(tags[i].text()));
		}
		return result;
	}
675046
function parseAllTags(buf) {
  var result = [];
  var element;
  
  while (buf.length > 0) {
    element = parseTag(buf);
    buf = buf.slice(element.length);
    result.push(element.tag);
  }
  
  return result;
}
458422
protected function parseParams():self
	{
		$params= preg_split('/(?<!\\\\)\\|/',$this->line->pregGet('/^-[\w-:]+\((.*?)\)(?= |(\\{>)?$)/',1));

		if( ($m= count($params)) != ($n= count($this->config['params'])) ){$this->document->throw("Tag $this->name has $n parameters $m given.");}

		array_map(function( $key, $value ){return $this->setAttribute($key,$this->checkExpression(str_replace('\\|','|',$value)));},$this->config['params'],$params);

		return $this;
	}
420555
function parseTagged(definition, taggedTypes) {
	let match = definition.match(/^(\w+)(?:\((.*)\))?$/),
		tag, args, typeInfo
	if (!match) {
		return
	}

	// Get type info
	tag = match[1]
	typeInfo = taggedTypes[tag]
	if (!typeInfo) {
		return
	}

	// Special no-'()' case: only match 'tag' if minArgs is zero
	if (typeInfo.minArgs > 0 && match[2] === undefined) {
		return
	}

	// Parse and check args
	args = (match[2] || '').trim().split(/\s*,\s*/)
	if (args.length === 1 && args[0] === '') {
		// Especial empty case
		args = []
	}
	args = args.map((arg, i) => {
		if (!arg) {
			if (!typeInfo.sparse) {
				throw new Error('Missing argument at position ' + i + ' for tagged type ' + tag)
			}
			return
		}

		if (typeInfo.numeric) {
			arg = Number(arg)
			if (isNaN(arg)) {
				throw new Error('Invalid numeric argument at position ' + i + ' for tagged type ' + tag)
			}
		}

		return arg
	})
	args.original = definition
	if (args.length < typeInfo.minArgs) {
		throw new Error('Too few arguments for tagged type ' + tag)
	} else if (typeInfo.maxArgs && args.length > typeInfo.maxArgs) {
		throw new Error('Too many arguments for tagged type ' + tag)
	}

	return new Field(typeInfo.type, typeInfo.parseArgs ? typeInfo.parseArgs(args) : args)
}
1043126
function getParamType(tag) {
  var expression = tag.expression,
      result = '',
      type = tag.type;

  switch (type) {
    case 'AllLiteral':
      result = '*';
      break;

    case 'NameExpression':
      result = _.toString(tag.name);
      break;

    case 'RestType':
      result = '...' + result;
      break;

    case 'TypeApplication':
      expression = undefined;
      result = _(tag)
        .chain()
        .get('applications')
        .map(_.flow(getParamType, fp.add(fp, '[]')))
        .sort(util.compareNatural)
        .join('|')
        .value();
      break;

    case 'UnionType':
      result = _(tag)
        .chain()
        .get('elements')
        .map(getParamType)
        .sort(util.compareNatural)
        .join('|')
        .value();
  }
  if (expression) {
    result += getParamType(expression);
  }
  return type == 'UnionType'
    ? ('(' + result + ')')
    : result;
}
193345
function parseEndTag(tag, tagName) {

      // If no tag name is provided, clean shop
      if (!tagName)
        var pos = 0;

      // Find the closest opened tag of the same type
      else {
        tagName = tagName.toLowerCase();
        for (var pos = stack.length - 1; pos >= 0; pos--)
          if (stack[pos] == tagName)
            break;
      }

      if (pos >= 0) {
        // Close all the open elements, up the stack
        for (var i = stack.length - 1; i >= pos; i--)
          results += "</" + stack[i] + ">";

        // Remove the open elements from the stack
        stack.length = pos;
      }

    }
12046
public function parseTags($string)
    {
        foreach ($this->tags as $tag => $code) {
            if (strpos($string, "<{$tag}>") !== false
                || strpos($string, "</{$tag}>") !== false
            ) {
                $string = str_replace("<{$tag}>", $code, $string);
                $string = str_replace("</{$tag}>", $this->tags['default'], $string);
            }
        }

        return $string . $this->tags['default'];
    }
840864
def _parse_fields(parsed):
    
    # Note: Call this `out` to avoid name conflict with `fields` module
    out = []

    # Prepare field tags
    tags = parsed.find_all(_tag_ptn)
    for tag in tags:
        helpers.lowercase_attr_names(tag)

    while tags:
        tag = tags.pop(0)
        try:
            field = _parse_field(tag, tags)
        except exceptions.InvalidNameError:
            continue
        if field is not None:
            out.append(field)

    return out
1022983
function parseText(parts, tag, h, param, continuationMarker, state) {
    var end = parts.length;
    if (!endTagRe.hasOwnProperty(tag.name)) {
      endTagRe[tag.name] = new RegExp('^' + tag.name + '(?:[\\s\\/]|$)', 'i');
    }
    var re = endTagRe[tag.name];
    var first = tag.next;
    var p = tag.next + 1;
    for (; p < end; p++) {
      if (parts[p - 1] === '<\/' && re.test(parts[p])) { break; }
    }
    if (p < end) { p -= 1; }
    var buf = parts.slice(first, p).join('');
    if (tag.eflags & html4.eflags.CDATA) {
      if (h.cdata) {
        h.cdata(buf, param, continuationMarker,
          continuationMaker(h, parts, p, state, param));
      }
    } else if (tag.eflags & html4.eflags.RCDATA) {
      if (h.rcdata) {
        h.rcdata(normalizeRCData(buf), param, continuationMarker,
          continuationMaker(h, parts, p, state, param));
      }
    } else {
      throw new Error('bug');
    }
    return p;
  }
967108
function decodeTags (tags) {
  let elementType = 'p';
  const classes = [];
  tags.forEach(tag => {
    if (typeof tag !== 'string') return;
    const foundTag = tag.match(/^<([\w-]+)>$/);
    if (foundTag) {
      elementType = foundTag[1];
      return;
    }
    const foundClass = tag.match(/^\.([\w-]+)$/);
    if (foundClass) {
      classes.push(foundClass[1]);
      return;
    }
  });
  return {elementType, classes};
}
47858
def _split_params(tag_prefix, tag_suffix):
    ""
    if tag_suffix[-1:] != ')':
        raise ValueError, "unbalanced parenthesis in type %s%s" % (tag_prefix, tag_suffix)
    return map(_maybe_int, tag_suffix[:-1].split(','))
1176055
function(item) {
  var result = {};

  _.each(item, function(value, key) {
    if (fix[key]) {
      result[key] = parseItem(fix[key](value));
    } else if (key === 'Tags') {
      result[key] = parseTags(value);
    } else {
      result[key] = parseItem(value);
    }
  });

  return result;
}
1008351
protected function getTagValues()
    {
        // Step1 Get tags value from cache
        $keys = array_map(array($this, 'getTagKey'), $this->tags);
        $values = $this->cache->getMulti($keys);

        // Step2 Initialize new tags value
        $emptyKeys = array_diff($values, array_filter($values));
        if ($emptyKeys) {
            $newValues = $this->setTagValues($emptyKeys);
            $values = array_merge($values, $newValues);
        }

        return $values;
    }
230533
private Object getValuePopulatedWithTags(final String originalTag, final String stringValue)
    {
        // See if the value is a surrogate key in the tag parser's map that was placed there during preprocessing,
        // and if so, unpack the values retrieved via the key and use those to populate the field
        final Object value = constructFromString(stringValue, getLongName());

        if (TaggedArgument.class.isAssignableFrom(getUnderlyingFieldClass())) {
            // NOTE: this propagates the tag name/attributes to the field BEFORE the value is set
            TaggedArgument taggedArgument = (TaggedArgument) value;
            TaggedArgumentParser.populateArgumentTags(
                    taggedArgument,
                    getLongName(),
                    originalTag);
        } else if (originalTag != null) {
            // a tag was found for a non-taggable argument
            throw new CommandLineException(
                    String.format("The argument: \"%s/%s\" does not accept tags: \"%s\"",
                            getShortName(),
                            getFullName(),
                            originalTag));
        }
        return value;
    }
1082665
function _parseParameters(rule, parameter) {
    if (rule.toLowerCase() == 'regex') return [parameter];
    if (is_string(parameter)) {
      return parameter.split(',');
    };

    return [];
  }
731116
private function parseTagBlock(string $tags, Types\Context $context): array
    {
        $tags = $this->filterTagBlock($tags);
        if (!$tags) {
            return [];
        }

        $result = $this->splitTagBlockIntoTagLines($tags);
        foreach ($result as $key => $tagLine) {
            $result[$key] = $this->tagFactory->create(trim($tagLine), $context);
        }

        return $result;
    }
1020613
private static ParameterFiller parseParameter(String parameter) {
    String wrappedParameter = "{" + parameter + "}";
    String trimmedParameter = parameter.trim();
    ParameterFiller parameterFiller = parseDateParameter(wrappedParameter, trimmedParameter);
    if (parameterFiller != null) {
      return parameterFiller;
    }

    parameterFiller = parseLevelParameter(wrappedParameter, trimmedParameter);
    if (parameterFiller != null) {
      return parameterFiller;
    }

    parameterFiller = parseTagParameter(wrappedParameter, trimmedParameter);
    if (parameterFiller != null) {
      return parameterFiller;
    }

    parameterFiller = parseMessageParameter(wrappedParameter, trimmedParameter);
    if (parameterFiller != null) {
      return parameterFiller;
    }

    return null;
  }