// NewParser creates and returns a new Parser that reads files from the given
// filesystem. If a nil filesystem is passed then the system's "real" filesystem
// will be used, via afero.OsFs.
334999
func NewParser(fs afero.Fs) *Parser {
	if fs == nil {
		fs = afero.OsFs{}
	}

	return &Parser{
		fs: afero.Afero{Fs: fs},
		p:  hclparse.NewParser(),
	}
}
856940
func NewReader(input io.Reader) *Reader {
	return &Reader{
		input: bufio.NewReader(input),
	}
}
390462
func (d Decoder) NewReader(rd io.Reader) *Reader {
	b := new(Reader)
	b.buf = make([]byte, defaultBufSize)
	b.rd = rd
	b.decode = d
	return b
}
1323778
func NewReader(r io.Reader) *Reader {
	return &Reader{
		Delimiter: '\t',
		r:         bufio.NewReader(r),
	}
}
968514
func NewReader(i io.Reader) (o io.Reader, err error) {
	// Create reader
	r := bufio.NewReader(i)

	// Read first 4 bytes
	var b []byte
	if b, err = r.Peek(4); err != nil {
		err = errors.Wrap(err, "astiunicode: reading first 4 bytes failed")
		return
	}

	// Create transformer
	if bytes.HasPrefix(b, bomHeaderUTF32BE) || bytes.HasPrefix(b, bomHeaderUTF32LE) {
		err = errors.New("astiunicode: UTF32 is not handled yet")
		return
	} else if bytes.HasPrefix(b, bomHeaderUTF16BE) {
		o = transform.NewReader(r, unicode.UTF16(unicode.BigEndian, unicode.IgnoreBOM).NewDecoder())
	} else if bytes.HasPrefix(b, bomHeaderUTF16LE) {
		o = transform.NewReader(r, unicode.UTF16(unicode.LittleEndian, unicode.IgnoreBOM).NewDecoder())
	} else if bytes.HasPrefix(b, bomHeaderUTF8) {
		o = transform.NewReader(r, unicode.UTF8.NewDecoder())
	} else {
		o = r
	}
	return
}
285577
func NewReader(r io.Reader, bo binary.ByteOrder) Reader {
	return &reader{
		r:  r,
		bo: bo,
	}
}
1103441
func New(m *Model) *Parser {
	d := &Parser{
		Output: make(chan *lingo.Dependency),
		Error:  make(chan error),

		Model: m,
	}

	return d
}
25975
func NewReader(f io.ReaderAt) (*Reader, error) {
	r := &Reader{r: f}
	section := io.NewSectionReader(f, 0, 0xffff)
	err := binary.Read(section, binary.LittleEndian, &r.hdr)
	if err != nil {
		return nil, err
	}

	if r.hdr.ImageTag != wimImageTag {
		return nil, &ParseError{Oper: "image tag", Err: errors.New("not a WIM file")}
	}

	if r.hdr.Flags&^supportedHdrFlags != 0 {
		return nil, fmt.Errorf("unsupported WIM flags %x", r.hdr.Flags&^supportedHdrFlags)
	}

	if r.hdr.CompressionSize != 0x8000 {
		return nil, fmt.Errorf("unsupported compression size %d", r.hdr.CompressionSize)
	}

	if r.hdr.TotalParts != 1 {
		return nil, errors.New("multi-part WIM not supported")
	}

	fileData, images, err := r.readOffsetTable(&r.hdr.OffsetTable)
	if err != nil {
		return nil, err
	}

	xmlinfo, err := r.readXML()
	if err != nil {
		return nil, err
	}

	var info info
	err = xml.Unmarshal([]byte(xmlinfo), &info)
	if err != nil {
		return nil, &ParseError{Oper: "XML info", Err: err}
	}

	for i, img := range images {
		for _, imgInfo := range info.Image {
			if imgInfo.Index == i+1 {
				img.ImageInfo = imgInfo
				break
			}
		}
	}

	r.fileData = fileData
	r.Image = images
	r.XMLInfo = xmlinfo
	return r, nil
}
308415
func NewParser(raw []string) (p *Parser, sub string) {
	if len(raw) < 1 {
		panic("Must use a subcommand")
	}
	p = &Parser{make(map[string]Flag), make([]string, 0)}
	sub = raw[0]
	i := 1
	for i < len(raw) {
		switch {
		case strings.HasPrefix(raw[i], "--"):
			pieces := strings.Split(raw[i], "=")
			if len(pieces) == 1 {
				p.flags[strings.TrimPrefix(pieces[0], "--")] = Flag{Long, ""}
			} else {
				p.flags[strings.TrimPrefix(pieces[0], "--")] = Flag{Long, pieces[1]}
			}
			i++
		case strings.HasPrefix(raw[i], "-"):
			pieces := strings.Split(raw[i], "=")
			if len(pieces) == 1 {
				p.flags[strings.TrimPrefix(pieces[0], "-")] = Flag{Short, ""}
			} else {
				p.flags[strings.TrimPrefix(pieces[0], "-")] = Flag{Short, pieces[1]}
			}
			i++
		default:
			goto END
		}
	}
END:
	if i < len(raw) {
		p.args = append(p.args, raw[i:]...)
	}
	return
}
1101264
func newBytesBinParser(b []byte) *binParser {
	p := &binParser{bufio.NewReader(bytes.NewReader(b)), 0, 0}
	if p.r == nil {
		return nil
	}
	return p
}
930940
func NewReader(r io.Reader) *Reader {
	return &Reader{
		r:       r,
		decoded: make([]byte, maxUncompressedChunkLen),
		buf:     make([]byte, MaxEncodedLen(maxUncompressedChunkLen)+checksumSize),
	}
}
982231
func NewParserReader(logFile io.Reader, parser StringParser) *Reader {
	return &Reader{
		file:   logFile,
		parser: parser,
	}
}
1155805
func newParser(r io.Reader, contentType string, baseURL *url.URL) (*parser, error) {
	r, err := charset.NewReader(r, contentType)
	if err != nil {
		return nil, err
	}

	tree, err := html.Parse(r)
	if err != nil {
		return nil, err
	}

	return &parser{
		tree:            tree,
		data:            &Microdata{},
		baseURL:         baseURL,
		identifiedNodes: make(map[string]*html.Node),
	}, nil
}
1135932
func NewParse(tag, format string) (*template.Template, error) {
	return template.New(tag).Funcs(basicFunctions).Parse(format)
}
1165812
func NewParserWithoutHeader(reader io.Reader, data interface{}) *Parser {
	r := csv.NewReader(reader)
	r.Comma = '\t'

	p := &Parser{
		Reader:    r,
		Data:      data,
		ref:       reflect.ValueOf(data).Elem(),
		normalize: -1,
	}

	return p
}
1362711
func New() *Parser {
	parser := &Parser{
		swagger: &spec.Swagger{
			SwaggerProps: spec.SwaggerProps{
				Info: &spec.Info{
					InfoProps: spec.InfoProps{
						Contact: &spec.ContactInfo{},
						License: &spec.License{},
					},
				},
				Paths: &spec.Paths{
					Paths: make(map[string]spec.PathItem),
				},
				Definitions: make(map[string]spec.Schema),
			},
		},
		files:                make(map[string]*ast.File),
		TypeDefinitions:      make(map[string]map[string]*ast.TypeSpec),
		CustomPrimitiveTypes: make(map[string]string),
		registerTypes:        make(map[string]*ast.TypeSpec),
	}
	return parser
}
688398
func NewReader(rs io.ReadSeeker) (*Reader, error) {
	// Starts reading from image data area
	sector := dataAreaSector
	// Iterates over volume descriptors until it finds the primary volume descriptor
	// or an error condition.
	for {
		offset, err := rs.Seek(int64(sector*sectorSize), os.SEEK_SET)
		if err != nil {
			return nil, ErrCorruptedImage(err)
		}

		var volDesc VolumeDescriptor
		if err := binary.Read(rs, binary.BigEndian, &volDesc); err != nil {
			return nil, ErrCorruptedImage(err)
		}

		if volDesc.Type == primaryVol {
			// backs up to the beginning of the sector again in order to unpack
			// the entire primary volume descriptor more easily.
			if _, err := rs.Seek(offset, os.SEEK_SET); err != nil {
				return nil, ErrCorruptedImage(err)
			}

			reader := new(Reader)
			reader.image = &imageReader{rs}
			reader.queue = new(gotoolkit.SliceQueue)

			if err := reader.unpackPVD(); err != nil {
				return nil, ErrCorruptedImage(err)
			}

			return reader, nil
		}

		if volDesc.Type == volSetTerminator {
			return nil, ErrInvalidImage(errors.New("Volume Set Terminator reached. A Primary Volume Descriptor was not found."))
		}
		sector++
	}
}