// Parse the production:
// stream   ::= STREAM-START implicit_document? explicit_document* STREAM-END
//              ************
971651
func yaml_parser_parse_stream_start(parser *yaml_parser_t, event *yaml_event_t) bool {
	token := peek_token(parser)
	if token == nil {
		return false
	}
	if token.typ != yaml_STREAM_START_TOKEN {
		return yaml_parser_set_parser_error(parser, "did not find expected <stream-start>", token.start_mark)
	}
	parser.state = yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE
	*event = yaml_event_t{
		typ:        yaml_STREAM_START_EVENT,
		start_mark: token.start_mark,
		end_mark:   token.end_mark,
		encoding:   token.encoding,
	}
	skip_token(parser)
	return true
}
322916
func (m *ChannelMap) Parse(s string) {
	cstr := C.CString(s)
	defer C.free(unsafe.Pointer(cstr))
	m.fromC(C.pa_channel_map_parse(m.toC(), cstr))
}
30606
func (pp *primitiveParser) Parse() map[string]*data {
	pp.loadTypeComments()
	pp.loadStructs()

	visible := make(map[string]*data)
	for k := range pp.structmap {
		if strings.ToUpper(string(k[0])) != string(k[0]) { // not exported
			continue
		}
		pp.visitStruct(visible, k, false)
	}

	return visible
}
1101882
func (c *Compiler) ParseFile(filename string) (err error) {
	defer func() {
		if r := recover(); r != nil {
			err = errors.New(r.(string))
		}
	}()

	parser, err := parser.FileParser(filename)

	if err != nil {
		return
	}

	c.node = parser.Parse()
	c.filename = filename
	return
}
594500
func Parse(r io.Reader) (*Node, error) {
	p := &parser{
		tokenizer: NewTokenizer(r),
		doc: &Node{
			Type: DocumentNode,
		},
		scripting:  true,
		framesetOK: true,
		im:         initialIM,
	}
	err := p.parse()
	if err != nil {
		return nil, err
	}
	return p.doc, nil
}
980202
func (b *boundedBuilder) Parse(s string) (*Literal, error) {
	l, err := defaultBuilder.Parse(s)
	if err != nil {
		return nil, err
	}
	t := l.Type()
	switch t {
	case Text:
		if text, err := l.Text(); err != nil || len(text) > b.max {
			return nil, fmt.Errorf("literal.Parse: cannot create literal due to size of %v (%d>%d)", t, len(text), b.max)
		}
	case Blob:
		if blob, err := l.Blob(); err != nil || len(blob) > b.max {
			return nil, fmt.Errorf("literal.Parse: cannot create literal due to size of %v (%d>%d)", t, len(blob), b.max)
		}
	}
	return l, nil
}
694224
func Parse(cfg API, reader io.Reader, bufSize int) *Iterator {
	return &Iterator{
		cfg:    cfg.(*frozenConfig),
		reader: reader,
		buf:    make([]byte, bufSize),
		head:   0,
		tail:   0,
	}
}
427450
func Parse(input string) (doc *Document, err error) {

	const (
		normal     = iota
		comment    = iota
		eolcomment = iota
		word       = iota
	)

	var (
		document    Document
		curBlock    Block = Block{}
		state       int   = normal
		lastNewline int   = 0
		buffer      string
		address     rune
	)

	input += "\n"

	defer func() {
		if r := recover(); r != nil {
			err = errors.New(fmt.Sprintf("%s", r))
		}
	}()

	parserPanic := func(idx int, err string) string {
		nl := 0
		for idy, s := range input {
			if idy == idx {
				break
			} else if s == '\n' {
				nl++
			}
		}
		panic(fmt.Sprintf("Line %d, pos %d: %s", nl, idx-lastNewline+1, err))
	}

	parseNormal := func(c rune, idx int) {
		switch c {
		case '/':
			if idx-lastNewline == 0 {
				curBlock.BlockDelete = true
				lastNewline--
			} else {
				parserPanic(idx, "Unexpected /")
			}
		case '%':
			fm := Filemarker{}
			curBlock.AppendNode(&fm)
		case '(':
			state = comment
		case ';':
			state = eolcomment
		case '\n':
			document.AppendBlock(curBlock)
			curBlock = Block{}
			lastNewline = idx + 1
		case '\r':
			// Ignore
			return
		case ' ':
			// Ignore
			return
		default:
			if c >= 97 && c <= 122 {
				// Lower-case character
				state = word
				address = c - 32 // Make uppercase
			} else if (c >= 65 && c <= 90) || c == 64 || c == 94 {
				// Upper-case character, @ or ^
				state = word
				address = c
			} else {
				// No clue
				parserPanic(idx, fmt.Sprintf("Expected word address, found [%c]", c))
			}
		}
	}

	parseComment := func(c rune, idx int) {
		switch c {
		case ')':
			state = normal
			cm := Comment{buffer, false}
			curBlock.AppendNode(&cm)
			buffer = ""
		case '\n':
			parserPanic(idx, "Non-terminated comment")
		default:
			buffer += string(c)
		}
	}

	parseEOLComment := func(c rune, idx int) {
		switch c {
		case '\n':
			state = normal
			cm := Comment{buffer, true}
			curBlock.AppendNode(&cm)
			buffer = ""
			parseNormal(c, idx)
		default:
			buffer += string(c)
		}
	}

	parseWord := func(c rune, idx int) {
		if (c >= 48 && c <= 57) || c == 46 || c == 45 || c == 43 {
			// [0-9\.\-\+]
			buffer += string(c)
		} else {
			if len(buffer) == 0 {
				parserPanic(idx, fmt.Sprintf("Expected word command, found [%c]", c))
			}
			// End of command
			state = normal
			f, _ := strconv.ParseFloat(string(buffer), 64)
			w := Word{address, f}
			curBlock.AppendNode(&w)
			buffer = ""
			parseNormal(c, idx)
		}
	}

	for idx, c := range input {
		switch state {
		case normal:
			parseNormal(c, idx)
		case comment:
			parseComment(c, idx)
		case eolcomment:
			parseEOLComment(c, idx)
		case word:
			parseWord(c, idx)
		}
	}
	return &document, nil
}
1267327
func (c *Compiler) Parse(input string) (err error) {
	defer func() {
		if r := recover(); r != nil {
			err = errors.New(r.(string))
		}
	}()

	parser, err := parser.StringParser(input)
    parser.FileName(c.filename)

	if err != nil {
		return
	}

	c.node = parser.Parse()
	return
}
33864
func Parse(rawtemplate string) (template *UriTemplate, err error) {
	template = new(UriTemplate)
	template.raw = rawtemplate
	split := strings.Split(rawtemplate, "{")
	template.parts = make([]templatePart, len(split)*2-1)
	for i, s := range split {
		if i == 0 {
			if strings.Contains(s, "}") {
				err = errors.New("unexpected }")
				break
			}
			template.parts[i].raw = s
		} else {
			subsplit := strings.Split(s, "}")
			if len(subsplit) != 2 {
				err = errors.New("malformed template")
				break
			}
			expression := subsplit[0]
			template.parts[i*2-1], err = parseExpression(expression)
			if err != nil {
				break
			}
			template.parts[i*2].raw = subsplit[1]
		}
	}
	if err != nil {
		template = nil
	}
	return template, err
}
891109
func (s *FileSource) Parse() (tree.RawPolicy, error) {
	file, err := ioutil.ReadFile(s.Filename)
	if err != nil {
		return tree.RawPolicy{}, err
	}
	return parseLines(s.Filename, strings.Split(string(file), "\n"))
}
1477
func Parse(raw string) (Sentence, error) {
	s, err := parseSentence(raw)
	if err != nil {
		return nil, err
	}
	if strings.HasPrefix(s.Raw, SentenceStart) {
		switch s.Type {
		case TypeRMC:
			return newRMC(s)
		case TypeGGA:
			return newGGA(s)
		case TypeGSA:
			return newGSA(s)
		case TypeGLL:
			return newGLL(s)
		case TypeVTG:
			return newVTG(s)
		case TypeZDA:
			return newZDA(s)
		case TypePGRME:
			return newPGRME(s)
		case TypeGSV:
			return newGSV(s)
		case TypeHDT:
			return newHDT(s)
		case TypeGNS:
			return newGNS(s)
		case TypeTHS:
			return newTHS(s)
		}
	}
	if strings.HasPrefix(s.Raw, SentenceStartEncapsulated) {
		switch s.Type {
		case TypeVDM, TypeVDO:
			return newVDMVDO(s)
		}
	}
	return nil, fmt.Errorf("nmea: sentence prefix '%s' not supported", s.Prefix())
}
1085525
func Parse(src []byte) (*ast.File, error) {
	// normalize all line endings
	// since the scanner and output only work with "\n" line endings, we may
	// end up with dangling "\r" characters in the parsed data.
	src = bytes.Replace(src, []byte("\r\n"), []byte("\n"), -1)

	p := newParser(src)
	return p.Parse()
}
238188
func (d DefaultBodyParser) Parse(buf []byte, body interface{}, mediaType, charset string) error {
	if len(buf) == 0 {
		return ErrBadRequest.WithMsg("request entity empty")
	}
	switch true {
	case mediaType == MIMEApplicationJSON, isLikeMediaType(mediaType, "json"):
		err := json.Unmarshal(buf, body)
		if err == nil {
			return nil
		}

		if ute, ok := err.(*json.UnmarshalTypeError); ok {
			if ute.Field == "" { // go1.11
				return fmt.Errorf("Unmarshal type error: expected=%v, got=%v, offset=%v",
					ute.Type, ute.Value, ute.Offset)
			}
			return fmt.Errorf("Unmarshal type error: field=%v, expected=%v, got=%v, offset=%v",
				ute.Field, ute.Type, ute.Value, ute.Offset)
		} else if se, ok := err.(*json.SyntaxError); ok {
			return fmt.Errorf("Syntax error: offset=%v, error=%v", se.Offset, se.Error())
		} else {
			return err
		}
	case mediaType == MIMEApplicationXML, isLikeMediaType(mediaType, "xml"):
		return xml.Unmarshal(buf, body)
	case mediaType == MIMEApplicationForm:
		val, err := url.ParseQuery(string(buf))
		if err == nil {
			err = ValuesToStruct(val, body, "form")
		}
		return err
	}

	return ErrUnsupportedMediaType.WithMsg("unsupported media type")
}
975350
func ParseFile(filename string) (interface{}, error) {
	var (
		bytes []byte
		err   error
	)
	if bytes, err = ioutil.ReadFile(filename); err != nil {
		return nil, err
	}
	return Parse(bytes)
}
1083139
func (p FloatParser) Parse(field string) (result interface{}, err error) {
	return strconv.ParseFloat(field, 64)
}
473279
func Parse(r io.Reader) (*Template, error) {
	// Create a buffer to copy what we read
	var buf bytes.Buffer
	if _, err := buf.ReadFrom(r); err != nil {
		return nil, err
	}

	// First, decode the object into an interface{}. We do this instead of
	// the rawTemplate directly because we'd rather use mapstructure to
	// decode since it has richer errors.
	var raw interface{}
	if err := json.Unmarshal(buf.Bytes(), &raw); err != nil {
		return nil, err
	}

	// Create our decoder
	var md mapstructure.Metadata
	var rawTpl rawTemplate
	rawTpl.RawContents = buf.Bytes()
	decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
		Metadata: &md,
		Result:   &rawTpl,
	})
	if err != nil {
		return nil, err
	}

	// Do the actual decode into our structure
	if err := decoder.Decode(raw); err != nil {
		return nil, err
	}

	// Build an error if there are unused root level keys
	if len(md.Unused) > 0 {
		sort.Strings(md.Unused)

		unusedMap, ok := raw.(map[string]interface{})
		if !ok {
			return nil, fmt.Errorf("Failed to convert unused root level keys to map")
		}

		for _, unused := range md.Unused {
			if unused[0] == '_' {
				commentVal, ok := unusedMap[unused].(string)
				if !ok {
					return nil, fmt.Errorf("Failed to cast root level comment value to string")
				}

				comment := map[string]string{
					unused: commentVal,
				}

				rawTpl.Comments = append(rawTpl.Comments, comment)
				continue
			}

			err = multierror.Append(err, fmt.Errorf(
				"Unknown root level key in template: '%s'", unused))
		}
	}
	if err != nil {
		return nil, err
	}

	// Return the template parsed from the raw structure
	return rawTpl.Template()
}