// Rparse seperate string use last seperator string
349590
func Rparse(str, sep string) *Pair {
	return parse(str, strings.LastIndex(str, sep))
}
1027752
func string_partition(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) {
	recv := string(recv_.(String))
	var sep string
	if err := UnpackPositionalArgs(fnname, args, kwargs, 1, &sep); err != nil {
		return nil, err
	}
	if sep == "" {
		return nil, fmt.Errorf("%s: empty separator", fnname)
	}
	var i int
	if fnname[0] == 'p' {
		i = strings.Index(recv, sep) // partition
	} else {
		i = strings.LastIndex(recv, sep) // rpartition
	}
	tuple := make(Tuple, 0, 3)
	if i < 0 {
		if fnname[0] == 'p' {
			tuple = append(tuple, String(recv), String(""), String(""))
		} else {
			tuple = append(tuple, String(""), String(""), String(recv))
		}
	} else {
		tuple = append(tuple, String(recv[:i]), String(sep), String(recv[i+len(sep):]))
	}
	return tuple, nil
}
1111289
func Parse(raw string) Links {
	var links Links

	// One chunk: <url>; rel="foo"
	for _, chunk := range strings.Split(raw, ",") {

		link := Link{URL: "", Rel: "", Params: make(map[string]string)}

		// Figure out what each piece of the chunk is
		for _, piece := range strings.Split(chunk, ";") {

			piece = strings.Trim(piece, " ")
			if piece == "" {
				continue
			}

			// URL
			if piece[0] == '<' && piece[len(piece)-1] == '>' {
				link.URL = strings.Trim(piece, "<>")
				continue
			}

			// Params
			key, val := parseParam(piece)
			if key == "" {
				continue
			}

			// Special case for rel
			if strings.ToLower(key) == "rel" {
				link.Rel = val
			} else {
				link.Params[key] = val
			}
		}

		if link.URL != "" {
			links = append(links, link)
		}
	}

	return links
}
1005229
func (p *parser) parse(pf *ProtoFile) error {
	for {
		// read any documentation if found...
		documentation, err := p.readDocumentationIfFound()
		if err != nil {
			return err
		}
		if p.eofReached {
			break
		}

		// skip any intervening whitespace if present...
		p.skipWhitespace()
		if p.eofReached {
			break
		}

		// read any declaration...
		err = p.readDeclaration(pf, documentation, parseCtx{ctxType: fileCtx})
		if err != nil {
			return err
		}
		if p.eofReached {
			break
		}
	}
	return nil
}
233178
func SliceSeparator(sep rune) Option {
	return func(ini *INI) error {
		ini.sliceSep = sep
		return nil
	}
}
838645
func SplitTrimSpace(s, sep string) []string {
	split := strings.Split(s, sep)
	strs := []string{}
	for _, str := range split {
		strs = append(strs, strings.TrimSpace(str))
	}
	return strs
}
1328090
func Parse(arn string) (*ARN, error) {
	p := strings.SplitN(arn, delimiter, 6)

	// Ensure that we have all the components that make up an ARN.
	if len(p) < 6 {
		return nil, ErrInvalidARN
	}

	a := &ARN{
		ARN:      p[0],
		AWS:      p[1],
		Service:  p[2],
		Region:   p[3],
		Account:  p[4],
		Resource: p[5],
	}

	// ARN's always start with "arn:aws" (hopefully).
	if a.ARN != "arn" || a.AWS != "aws" {
		return nil, ErrInvalidARN
	}

	return a, nil
}
1068351
func Parse(text string) Parameter {
	var splits []string
	var name, data string

	name = strings.Replace(text, "<", "", -1)
	name = strings.Replace(name, ">", "", -1)
	data = "string"

	if strings.Contains(name, ":") {
		splits = strings.Split(name, ":")

		name = splits[0]
		data = splits[1]
	}

	return NewParameterWithType(name, data)
}
537678
func (t *Tree) Parse() error {
	go t.lex.tokenize()
	for {
		n, err := t.parse()
		if err != nil {
			return t.enrichError(err)
		}
		if n == nil {
			break
		}
		t.root.Append(n)
	}
	t.traverse(t.root)
	return nil
}
594756
func (hpt *hostParamTransformer) split(s, sep string) []string {
	slice := []string{}
	n := strings.Count(s, sep) + 1
	c := sep[0]
	start := 0

	var a []string
	if cap(slice) == n {
		a = slice
	} else {
		a = make([]string, n)
	}

	na := 0
	for i := 0; i+len(sep) <= len(s) && na+1 < n; i++ {
		if s[i] == c && (len(sep) == 1 || s[i:i+len(sep)] == sep) && (i == 0 || s[i-1] != '\\') {
			a[na] = s[start:i]
			na++
			start = i + len(sep)
			i += len(sep) - 1
		}
	}
	a[na] = s[start:]
	slice = a[0 : na+1]
	return slice
}
321915
func SplitMap(s, sep string, m func(p string) (string, bool)) []string {
	parts := strings.Split(s, sep)
	out := []string{}
	for _, part := range parts {
		if mp, ok := m(part); ok {
			out = append(out, mp)
		}
	}
	return out
}
1275844
func Parse(v string) (r Version, err error) {
	parts := semVerRegex.FindStringSubmatch(v)
	if parts == nil {
		return r, fmt.Errorf(`cannot parse as semantic version: %q`, v)
	}

	if r.Major, err = parseUint(parts[1]); err != nil {
		return r, err
	}
	if r.Minor, err = parseUint(parts[2]); err != nil {
		return r, err
	}
	if r.Patch, err = parseUint(parts[3]); err != nil {
		return r, err
	}

	if parts[4] != "" {
		r.Pre = strings.Split(parts[4], ".")
	}
	r.Meta = parts[5]
	return r, nil
}
456061
func parse(desc string) (chain []*term) {
	origDesc := desc
	for len(desc) != 0 {
		t := parseTerm(desc)
		if t == nil {
			fmt.Printf("failed to parse %q past %q\n", origDesc, desc)
			return nil
		}
		desc = desc[len(t.desc):]
		chain = append(chain, t)
		if len(desc) >= 2 {
			if !strings.HasPrefix(desc, "->") {
				fmt.Printf("failed to parse %q past %q, expected \"->\"\n", origDesc, desc)
				return nil
			}
			desc = desc[2:]
		}
	}
	return chain
}
629776
func parse(s string) (string, string) {
	if s == "/" {
		return s, ""
	}
	for i := 1; i < len(s); i++ {
		if s[i] == '/' {
			return s[0:i], s[i:]
		}
	}

	return s, ""
}
290163
func splitTokens(tokens []string, sep string) (s splitted, err error) {
	index := index(tokens, sep)
	if index == -1 {
		return s, fmt.Errorf("'%s' not found in ['%s']", sep, strings.Join(tokens, "','"))
	}
	return splitted{
		Left:  tokens[:index],
		Right: tokens[index+1:],
	}, nil
}
11051
func SplitCondenseSpace(s, sep string) []string {
	split := strings.Split(s, sep)
	strs := []string{}
	for _, str := range split {
		str = strings.TrimSpace(str)
		if len(str) > 0 {
			strs = append(strs, str)
		}
	}
	return strs
}
459749
func Parse(input string) (*UPID, error) {
	upid := new(UPID)

	splits := strings.Split(input, "@")
	if len(splits) != 2 {
		return nil, fmt.Errorf("Expect one `@' in the input")
	}
	upid.ID = splits[0]

	if _, err := net.ResolveTCPAddr("tcp4", splits[1]); err != nil {
		return nil, err
	}
	upid.Host, upid.Port, _ = net.SplitHostPort(splits[1])
	return upid, nil
}