// ParseReader takes an io.Reader and returns Queries or an error.
6661
func ParseReader(reader io.Reader) (Queries, error) {
	var (
		lastTag  Tag
		lastLine parsedLine
	)

	queries := make(Queries)
	scanner := bufio.NewScanner(reader)

	for scanner.Scan() {
		line := parseLine(scanner.Text())

		switch line.Type {

		case lineBlank, lineComment:
			// we don't care about blank and comment lines
			continue

		case lineQuery:
			// got a query but no tag before
			if lastTag == "" {
				return nil, ErrTagMissing
			}

			query := line.Value
			// if query is multiline
			if queries[lastTag] != "" {
				query = " " + query
			}
			queries[lastTag] += query

		case lineTag:
			// got a tag after another tag
			if lastLine.Type == lineTag {
				return nil, ErrTagOverwritten
			}

			lastTag = Tag(line.Value)

		}

		lastLine = line
	}

	if err := scanner.Err(); err != nil {
		return nil, err
	}

	return queries, nil
}
91076
func Parse(r io.Reader) (Value, error) {
	rr := bufio.NewReader(r)
	data := []rune{}
	for {
		c, _, err := rr.ReadRune()
		if err == io.EOF {
			break
		}
		if err != nil {
			return nil, err
		}
		data = append(data, c)
	}
	return parse(data)
}
1206481
func (e *BinXMLEntityReference) Parse(reader io.ReadSeeker) error {
	err := encoding.Unmarshal(reader, &e.Token, Endianness)
	if err != nil {
		return err
	}
	err = encoding.Unmarshal(reader, &e.NameOffset, Endianness)
	if err != nil {
		return err
	}
	o := BackupSeeker(reader)
	// if the Entity Name is just after
	if int64(e.NameOffset) == o {
		return e.Name.Parse(reader)
	}
	// We jump to the right offset
	GoToSeeker(reader, int64(e.NameOffset))
	err = e.Name.Parse(reader)
	// We restore our position
	GoToSeeker(reader, o)
	return err
}
606069
func ParseFile(filename string, opts ...Option) (i interface{}, err error) {
	f, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer func() {
		if closeErr := f.Close(); closeErr != nil {
			err = closeErr
		}
	}()
	return ParseReader(filename, f, opts...)
}
1056603
func (u *uploader) nextReader() (io.ReadSeeker, int, []byte, error) {
	type readerAtSeeker interface {
		io.ReaderAt
		io.ReadSeeker
	}
	switch r := u.in.Body.(type) {
	case readerAtSeeker:
		var err error

		n := u.cfg.PartSize
		if u.totalSize >= 0 {
			bytesLeft := u.totalSize - u.readerPos

			if bytesLeft <= u.cfg.PartSize {
				err = io.EOF
				n = bytesLeft
			}
		}

		reader := io.NewSectionReader(r, u.readerPos, n)
		u.readerPos += n

		return reader, int(n), nil, err

	default:
		part := u.bufferPool.Get().([]byte)
		n, err := readFillBuf(r, part)
		u.readerPos += int64(n)

		return bytes.NewReader(part[0:n]), n, part, err
	}
}
1059516
func Parse(r io.Reader) (*html.Node, error) {
	return html.Parse(r)
}
86570
func checkParsingError(err error, reader io.ReadSeeker, e Element) {
	UpdateLastElements(e)
	if err != nil {
		log.DontPanicf("%s: parsing %T", err, e)
		DebugReader(reader, 10, 5)
	}
}
822599
func Parse(record string) ([]string, error) {
	reader := csv.NewReader(strings.NewReader(record))
	result, err := reader.Read()
	if err != nil {
		return nil, err
	}
	return result, nil
}
1327069
func (f *FilterQLParser) ParseFilter() (*FilterSelect, error) {
	f.setLexer(f.statement)
	return f.parseSelectStart()
}
42827
func NewReader(r io.Reader) (*Reader, error) {
	if r == nil {
		return nil, errors.New("Reader must not be nil")
	}

	return &Reader{r: r}, nil
}
1236165
func LoadFromReader(reader io.Reader, password []byte) (*KeyStore, error) {
	ks := &KeyStore{
		entries: make(map[string]interface{}),
	}
	err := ks.Parse(reader, password)
	if err != nil {
		return nil, err
	}
	return ks, err
}
215070
func (p *parser) Parse(r io.Reader) (err error) {
	cr := newChecksumReader(r)

	if err = readMagicString(cr); err != nil {
		return err
	}

	var rdbVersion int
	if rdbVersion, err = readVersionNumber(cr); err != nil {
		return err
	}

	for {
		if err = p.readDatabase(cr); err != nil && err != errNoMoreDatabases {
			return err
		} else if err != nil && err == errNoMoreDatabases {
			break
		}

		for {
			if err = p.readKeyValuePair(cr); err != nil && err != errNoMoreKeyValuePair {
				return err
			} else if err != nil && err == errNoMoreKeyValuePair {
				break
			}
		}

		if p.scratch[0] == 0xFF {
			break
		}
	}

	// Read the CRC64 checksum with RDB version >= 5
	if rdbVersion >= 5 {
		sum := cr.checksum

		var checksum uint64
		if err := binary.Read(cr, binary.LittleEndian, &checksum); err != nil {
			return err
		}

		if sum != checksum {
			return ErrInvalidChecksum
		}
	}

	p.ctx.closeChannels()

	return nil
}
161743
func (c *Context) DataFromReader(code int, contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string) {
	c.Render(code, render.Reader{
		Headers:       extraHeaders,
		ContentType:   contentType,
		ContentLength: contentLength,
		Reader:        reader,
	})
}
1213943
func runeReader(r io.Reader) io.RuneReader {
	if rr, ok := r.(io.RuneReader); ok {
		return rr
	}
	return bufio.NewReader(r)
}
906665
func NewConfigurationParserFromReader(settings io.Reader) *ConfigurationParser {
	is := InstallationSettings{}
	b, _ := ioutil.ReadAll(settings)
	if err := json.Unmarshal(b, &is); err != nil {
		lo.G.Error("Unmarshal installation settings error", err)
	}
	
    is.SetPGDumpUtilVersions()
	return &ConfigurationParser{
		InstallationSettings: is,
	}
}
212065
func ParseAST(r io.Reader) ([]AST, error) {
	lexer := iniLexer{}
	tokens, err := lexer.Tokenize(r)
	if err != nil {
		return []AST{}, err
	}

	return parse(tokens)
}
989700
func JSONReader(v interface{}) (r io.Reader, err error) {
	buf := new(bytes.Buffer)
	err = json.NewEncoder(buf).Encode(v)
	r = bytes.NewReader(buf.Bytes())
	return
}