// parseString parses a single- or double-quoted string.
972768
func (p *parser) parseString() (result string, err error) {
	i := p.i
	if len(p.s) < i+2 {
		return "", errors.New("expected string, found EOF instead")
	}

	quote := p.s[i]
	i++

loop:
	for i < len(p.s) {
		switch p.s[i] {
		case '\\':
			if len(p.s) > i+1 {
				switch c := p.s[i+1]; c {
				case '\r':
					if len(p.s) > i+2 && p.s[i+2] == '\n' {
						i += 3
						continue loop
					}
					fallthrough
				case '\n', '\f':
					i += 2
					continue loop
				}
			}
			p.i = i
			val, err := p.parseEscape()
			if err != nil {
				return "", err
			}
			i = p.i
			result += val
		case quote:
			break loop
		case '\r', '\n', '\f':
			return "", errors.New("unexpected end of line in string")
		default:
			start := i
			for i < len(p.s) {
				if c := p.s[i]; c == quote || c == '\\' || c == '\r' || c == '\n' || c == '\f' {
					break
				}
				i++
			}
			result += p.s[start:i]
		}
	}

	if i >= len(p.s) {
		return "", errors.New("EOF in string")
	}

	// Consume the final quote.
	i++

	p.i = i
	return result, nil
}
1053776
func ParseString(cfg API, input string) *Iterator {
	return ParseBytes(cfg, []byte(input))
}
56997
func GetString(n ast.Node) (string, error) {
	if node, ok := n.(*ast.BasicLit); ok && node.Kind == token.STRING {
		return strconv.Unquote(node.Value)
	}
	return "", fmt.Errorf("Unexpected AST node type: %T", n)
}
754078
func (*parser) parseString(b []byte) string {
	n := 0
	for n < len(b) && b[n] != 0 {
		n++
	}
	return string(b[0:n])
}
1265939
func (enc Encoding) DecodeString(s string) ([]byte, error) {
	if enc.convert {
		s = convertEncoding(s)
	}
	return enc.encoding.DecodeString(ensurePadding(s))
}
1094200
func URLString(ustring string) RequestOption {
	return func(req *http.Request) (*http.Request, error) {
		u, err := url.Parse(ustring)
		if err != nil {
			return nil, err
		}

		req.URL = u
		return req, nil
	}
}
1224595
func posString(slice []string, element string) int {
	for index, elem := range slice {
		if elem == element {
			return index
		}
	}
	return -1
}
494232
func ParseString(data string, unmarshal func([]byte, interface{}) error) (*Config, error) {
	conf := &Config{}
	if err := unmarshal([]byte(data), conf); err != nil {
		return nil, err
	}

	if err := conf.Sanitize(); err != nil {
		return nil, err
	}
	return conf, nil
}
73677
func UnmarshalString(in string, out interface{}) error {
	return Unmarshal(strings.NewReader(in), out)
}
404649
func ParseString(id string) (ID, error) {
	i, err := strconv.ParseInt(id, 10, 64)
	return ID(i), err

}
1374349
func (sf *ScalarFunction) EvalString(ctx sessionctx.Context, row chunk.Row) (string, bool, error) {
	return sf.Function.evalString(row)
}
284423
func ParseJSONFromString(json string, options ...ParserOptions) (Slice, error) {
	return ParseJSON(strings.NewReader(json), options...)
}
366562
func (n *NullInt) ParseStringValue(val string) error {
	if val == "" {
		return nil
	}

	intVal, err := strconv.Atoi(val)
	if err != nil {
		return err
	}

	n.Value = intVal
	n.IsSet = true

	return nil
}
1039909
func (b *builtinBinSig) evalString(row chunk.Row) (string, bool, error) {
	val, isNull, err := b.args[0].EvalInt(b.ctx, row)
	if isNull || err != nil {
		return "", true, err
	}
	return fmt.Sprintf("%b", uint64(val)), false, nil
}
1188595
func (d *doubleStar) String() string {
	if d.Until == nil {
		return "**"
	}
	return fmt.Sprintf("**/%s", d.Until.String())
}
134995
func (doc *PluginDocument) ParseString(comment string) {

	lines := sliceIterator{
		slice:    strings.Split(comment, "\n"),
		position: 0,
	}

	// This parses the comment block into 5 strings:
	// doc.BlockHeading, doc.Description, doc.Example,
	// metadataText, parametersText

	_, doc.BlockHeading, _ = lines.next()
	if _, tmp, _ := lines.next(); tmp != "" {
		panic(fmt.Sprintf("Expected empty line after block heading, got \"%s\"", tmp))
	}

	section := sectionStart

	var (
		metadataText   string
		parametersText string
		line           string
		trimmedLine    string
		lineNr         int
	)

	for {
		prevTrimmedLine := trimmedLine
		line, trimmedLine, lineNr = lines.next()

		if lineNr < 0 {
			break
		}

		// Look for section delimiter
		_, nextTrimmedLine, _ := lines.peek()
		if prevTrimmedLine == "" && nextTrimmedLine == "" {
			switch trimmedLine {
			case headingMetadata:
				section = sectionMetadata
				lines.next()
				continue

			case headingParameters:
				section = sectionParameters
				lines.next()
				continue

			case headingConfigurationExample:
				section = sectionConfigurationExample
				lines.next()
				continue
			}

			// Support for arbitrary section headers could be added here
		}

		// Assign lines to their own section
		switch section {
		case sectionStart:
			doc.Description += line + "\n"
			continue

		case sectionMetadata:
			metadataText += line + "\n"
			continue

		case sectionParameters:
			parametersText += line + "\n"
			continue

		case sectionConfigurationExample:
			doc.Example += line + "\n"
			continue
		}
	}

	// Metadata and Parameters sections are assumed to contain (recursive) definition lists
	// Description and Examples are taken as-is
	doc.Metadata.parseAndAppendString(metadataText)
	doc.Parameters.parseAndAppendString(parametersText)
}
585160
func (b *builtinSubstring3ArgsSig) evalString(row chunk.Row) (string, bool, error) {
	str, isNull, err := b.args[0].EvalString(b.ctx, row)
	if isNull || err != nil {
		return "", true, err
	}
	pos, isNull, err := b.args[1].EvalInt(b.ctx, row)
	if isNull || err != nil {
		return "", true, err
	}
	length, isNull, err := b.args[2].EvalInt(b.ctx, row)
	if isNull || err != nil {
		return "", true, err
	}
	runes := []rune(str)
	numRunes := int64(len(runes))
	if pos < 0 {
		pos += numRunes
	} else {
		pos--
	}
	if pos > numRunes || pos < 0 {
		pos = numRunes
	}
	end := pos + length
	if end < pos {
		return "", false, nil
	} else if end < numRunes {
		return string(runes[pos:end]), false, nil
	}
	return string(runes[pos:]), false, nil
}