// Parse start decoding phase of the packfile.
344604
func (p *Parser) Parse() (plumbing.Hash, error) {
	if err := p.init(); err != nil {
		return plumbing.ZeroHash, err
	}

	if err := p.indexObjects(); err != nil {
		return plumbing.ZeroHash, err
	}

	var err error
	p.checksum, err = p.scanner.Checksum()
	if err != nil && err != io.EOF {
		return plumbing.ZeroHash, err
	}

	if err := p.resolveDeltas(); err != nil {
		return plumbing.ZeroHash, err
	}

	if err := p.onFooter(p.checksum); err != nil {
		return plumbing.ZeroHash, err
	}

	return p.checksum, nil
}
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
}
1017176
func (p *Parser) Parse(llk *LLk, st *semantic.Statement) error {
	b, err := p.consume(llk, st, "START")
	if err != nil {
		return err
	}
	if !b {
		return fmt.Errorf("Parser.Parse: inconsitent parser, no error found, and no tokens were consumed")
	}
	return nil
}
921256
func (t *Tree) startParse(lex *lexer) {
	t.Root = nil
	t.lex = lex
}
115752
func (f *FlagSets) Parse(args []string) error {
	return f.mainSet.Parse(args)
}
1135819
func (p *Parser) Parse(data []byte) (interfaces.Mappable, error) {
	r := bytes.NewReader(data)
	decoder := xmlp.NewDecoder(r)
	err := decoder.RootElement()
	if err != nil {
		return nil, err
	}

	var feed Feed
	err = p.decode(decoder, &feed)
	if err != nil {
		return nil, err
	}

	return feed, nil
}
624174
func Parse(content string, spec *vpython.Spec) error {
	if err := cproto.UnmarshalTextML(content, spec); err != nil {
		return errors.Annotate(err, "failed to unmarshal vpython.Spec").Err()
	}
	return nil
}
581942
func (pub *DSAPublicKey) Parse(in []byte) (index []byte, ok bool) {
	var typeTag uint16
	if index, typeTag, ok = gotrax.ExtractShort(in); !ok || typeTag != dsaKeyTypeValue {
		return in, false
	}
	if index, pub.P, ok = gotrax.ExtractMPI(index); !ok {
		return in, false
	}
	if index, pub.Q, ok = gotrax.ExtractMPI(index); !ok {
		return in, false
	}
	if index, pub.G, ok = gotrax.ExtractMPI(index); !ok {
		return in, false
	}
	if index, pub.Y, ok = gotrax.ExtractMPI(index); !ok {
		return in, false
	}
	return
}
1140510
func Parse(b []byte) (*[]Packet, error) {
	r := make([]Packet, 0)

	buf := bytes.NewBuffer(b)
	var p Packet
	var packetHeader struct {
		PartType   uint16
		PartLength uint16
	}
	var time uint64
	var err error
	var valueCount uint16

	for buf.Len() > 0 {
		err = binary.Read(buf, binary.BigEndian, &packetHeader)
		if err != nil {
			return nil, err
		}
		if packetHeader.PartLength < 5 {
			return nil, ErrorInvalid
		}

		partBytes := buf.Next(int(packetHeader.PartLength) - 4)
		if len(partBytes) < int(packetHeader.PartLength)-4 {
			return nil, ErrorInvalid
		}
		partBuffer := bytes.NewBuffer(partBytes)

		switch packetHeader.PartType {
		case 0:
			str := partBuffer.String()
			p.Hostname = str[0 : len(str)-1]
		case 1:
			err = binary.Read(partBuffer, binary.BigEndian, &time)
			if err != nil {
				return nil, err
			}
			p.CdTime = time << 30
		case 2:
			str := partBuffer.String()
			p.Plugin = str[0 : len(str)-1]
		case 3:
			str := partBuffer.String()
			p.PluginInstance = str[0 : len(str)-1]
		case 4:
			str := partBuffer.String()
			p.Type = str[0 : len(str)-1]
		case 5:
			str := partBuffer.String()
			p.TypeInstance = str[0 : len(str)-1]
		case 6:
			err = binary.Read(partBuffer, binary.BigEndian, &valueCount)
			if err != nil {
				return nil, err
			}

			// make a copy so we lose reference to the underlying slice data
			p.Bytes = make([]byte, 8*valueCount, 8*valueCount)
			// collectd's protocol puts data in a seemingly weird
			// order which appears to be exactly what we want.
			copy(p.Bytes, partBytes[2+valueCount:2+valueCount+(valueCount*8)])
			// todo: what if some data is missing?

			p.DataTypes = make([]uint8, valueCount, valueCount)
			err = binary.Read(partBuffer, binary.BigEndian, p.DataTypes)
			if err != nil {
				return nil, err
			}
			for i, t := range p.DataTypes {
				// derive/gauge is little endian in protocol (!?)
				// reverse it so other code can be big endian
				if t == TypeGauge {
					for j, k := i*8, (i*8)+7; j < k; j, k = j+1, k-1 {
						p.Bytes[j], p.Bytes[k] = p.Bytes[k], p.Bytes[j]
					}
				}
			}

			r = append(r, p)
		case 7:
			// interval
			err = binary.Read(partBuffer, binary.BigEndian, &time)
			if err != nil {
				return nil, err
			}
			p.CdInterval = time << 30
		case 8:
			// high res time
			err = binary.Read(partBuffer, binary.BigEndian, &p.CdTime)
			if err != nil {
				return nil, err
			}
		case 9:
			// hi res interval
			err = binary.Read(partBuffer, binary.BigEndian, &p.CdInterval)
			if err != nil {
				return nil, err
			}
		case 0x100:
			// message (notifications), ignore
		case 0x101:
			// severity, ignore
		case 0x200:
			// Signature (HMAC-SHA-256), todo
			return nil, ErrorUnsupported
		case 0x210:
			// Encryption (AES-256/OFB/SHA-1), todo
			return nil, ErrorUnsupported
		default:
			return nil, ErrorUnsupported
		}
	}
	return &r, nil
}
121205
func (p *parser) parse() ([]node, error) {
	var nodes []node
loop:
	for {
		token := p.read()
		switch token.typ {
		case tokenEOF:
			break loop
		case tokenError:
			return nil, p.errorf(token, "%s", token.val)
		case tokenText:
			nodes = append(nodes, textNode(token.val))
		case tokenLeftDelim:
			node, err := p.parseTag()
			if err != nil {
				return nodes, err
			}
			nodes = append(nodes, node)
		case tokenRawStart:
			node, err := p.parseRawTag()
			if err != nil {
				return nodes, err
			}
			nodes = append(nodes, node)
		case tokenSetDelim:
			nodes = append(nodes, new(delimNode))
		}
	}
	return nodes, nil
}
594880
func Parse(f io.Reader) (Sections, error) {
	tree, err := ParseAST(f)
	if err != nil {
		return Sections{}, err
	}

	v := NewDefaultVisitor()
	if err = Walk(tree, v); err != nil {
		return Sections{}, err
	}

	return v.Sections, nil
}
943675
func (p *parser) Parse() []Pattern {
	// keep parsing until there's no more patterns
	_patterns := make([]Pattern, 0)
	for {
		_pattern := p.Next()
		if _pattern == nil {
			return _patterns
		}
		_patterns = append(_patterns, _pattern)
	}
}
58929
func Parse(in string) (Release, error) {
	var rel Release
	parts := strings.Split(in, ".")
	if len(parts) != 3 {
		return rel, errors.New("release: invalid release " + in)
	}

	var err error
	rel.Year, err = strconv.Atoi(parts[0])
	if err != nil {
		return rel, err
	} else if rel.Year > 2038 || rel.Year < 2000 {
		return rel, errors.New("release: " + parts[0] + " is an invalid year (2000 >= year <= 2038)")
	}

	rel.Month, err = strconv.Atoi(parts[1])
	if err != nil {
		return rel, err
	} else if rel.Month < 1 || rel.Month > 12 {
		return rel, errors.New("release: " + parts[1] + " is an invalid month (1 >= month <= 12)")
	}

	parts = strings.SplitN(parts[2], "-", 2)
	rel.Iteration, err = strconv.Atoi(parts[0])
	if err != nil {
		return rel, err
	}

	if len(parts) == 2 {
		rel.Extra = parts[1]
	}

	return rel, nil
}
1049431
func (parser *TransitionParser) Parse(data []byte, state string) ([]byte, ParserStateID) {
	currentStateID := parser.GetStateID(state)

	if currentStateID == ParserStateStop {
		return nil, currentStateID // ### return, immediate stop ###
	}

	currentState := parser.tokens[currentStateID]
	dataLen := len(data)
	readStartIdx := 0
	continueIdx := 0

	for parseIdx := 0; parseIdx < dataLen; parseIdx++ {
		node := currentState.MatchStart(data[parseIdx:])
		if node == nil {
			continue // ### continue, no match ###
		}

		t := node.Payload.(Transition)
		if t.callback != nil {
			if t.flags&ParserFlagInclude != 0 {
				t.callback(data[readStartIdx:parseIdx+node.PathLen], currentStateID)
			} else {
				t.callback(data[readStartIdx:parseIdx], currentStateID)
			}
		}

		// Move the reader
		if t.flags&ParserFlagContinue == 0 {
			parseIdx += node.PathLen - 1
		} else {
			parseIdx--
		}
		continueIdx = parseIdx + 1

		if t.flags&ParserFlagAppend == 0 {
			readStartIdx = continueIdx
		}

		nextStateID := t.nextState

		// Pop before push to allow both at the same time
		if t.flags&ParserFlagPop != 0 {
			stackLen := len(parser.stack)
			if stackLen > 0 {
				nextStateID = parser.stack[stackLen-1]
				parser.stack = parser.stack[:stackLen-1]
			}
		}

		if t.flags&ParserFlagPush != 0 {
			parser.stack = append(parser.stack, currentStateID)
		}

		// Transition to next
		currentStateID = nextStateID
		if currentStateID == ParserStateStop {
			break // ### break, stop state ###
		}

		currentState = parser.tokens[currentStateID]
	}

	if readStartIdx == dataLen {
		return nil, currentStateID // ### return, everything parsed ###
	}

	return data[readStartIdx:], currentStateID
}
887168
func (parser *Parser) Parse(path string) error {
	if !parser.initialised {
		if err := parser.init(); err != nil {
			return err
		}
	}

	contents, err := ioutil.ReadFile(path)

	if err != nil {
		return err
	}

	return parser.rt.run(string(contents))
}
1003157
func Parse(buf []byte) (*Message, error) {
	msg := &Message{}
	return msg, parse(buf, msg)
}
969180
func (t *Template) Parse(filename string) (*Template, error) {
	tmplBytes, err := t.file(filename)
	if err != nil {
		return nil, err
	}
	newTmpl, err := t.tmpl.Parse(string(tmplBytes))
	if err != nil {
		return nil, err
	}
	return t.replaceTmpl(newTmpl), nil
}