// parse naively tokenises hours and minutes.
//
// returns error when input format was incorrect.
323717
func parse(hhmm string) (hh int, mm int, err error) {

	hh = int(hhmm[0]-'0')*10 + int(hhmm[1]-'0')
	mm = int(hhmm[3]-'0')*10 + int(hhmm[4]-'0')

	if hh < 0 || hh > 24 {
		hh, mm = 0, 0
		err = errors.New("invalid hh format")
	}
	if mm < 0 || mm > 59 {
		hh, mm = 0, 0
		err = errors.New("invalid mm format")
	}

	return
}
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
}
191378
func (m *Parser) parse() (*Ast, error) {

	comment := m.initialComment()
	u.Debug(comment)
	// Now, find First Keyword
	switch m.curToken.T {
	case lex.TokenSelect:
		m.initialKeyword = m.curToken
		return m.parseSelect(comment)
	default:
		return nil, fmt.Errorf("Unrecognized query, expected [SELECT] influx ql")
	}
}
673769
func Parse(s string) (r T, err error) {
	_, err = fmt.Sscan(s,
		&r[0][0], &r[0][1], &r[0][2],
		&r[1][0], &r[1][1], &r[1][2],
		&r[2][0], &r[2][1], &r[2][2],
	)
	return r, err
}
355538
func (parser *FormatParser) Parse(req *http.Request, params imageserver.Params) error {
	imageserver_http.ParseQueryString("format", req, params)
	if !params.Has("format") {
		return nil
	}
	format, err := params.GetString("format")
	if err != nil {
		return err
	}
	if format == "jpg" {
		format = "jpeg"
	}
	params.Set("format", format)
	return nil
}
416025
func Parse(tokens []*lexer.Token, params Params) (*fsm.State, error) {
	p := &parser{
		spec:       params.Spec,
		options:    params.Options,
		optionsIdx: params.OptionsIdx,
		args:       params.Args,
		argsIdx:    params.ArgsIdx,
		tokens:     tokens,
	}
	return p.parse()
}
1039751
func Parse(value string) (s Size, err error) {
	var (
		i    int
		r    rune
		num  float64
		unit string
	)

	for i, r = range value {
		if (r < '0' || r > '9') && r != '.' {
			break
		}
	}

	if num, err = strconv.ParseFloat(value[:i], 64); err != nil {
		return
	}

	unit = strings.TrimSpace(value[i:])
	switch unit {
	case "", "B":
		s = Size(num * B)
	case "K", "KB":
		s = Size(num * KB)
	case "M", "MB":
		s = Size(num * MB)
	case "G", "GB":
		s = Size(num * GB)
	case "T", "TB":
		s = Size(num * TB)
	case "P", "PB":
		s = Size(num * PB)
	case "E", "EB":
		s = Size(num * EB)
	default:
		err = errors.New("invalid value: " + value)
	}
	return
}
946257
func Parse(parser, obj interface{}) {
	parsers := Parsers{}

	if p, ok := parser.(StringParser); ok {
		parsers.StringParser = p
	}
	if p, ok := parser.(IntParser); ok {
		parsers.IntParser = p
	}
	if p, ok := parser.(FloatParser); ok {
		parsers.FloatParser = p
	}

	parseRecursive(parsers, reflect.ValueOf(obj))
}
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)
	}
}
597448
func (m *tokenManager) Parse(ctx context.Context, tokenString string) (*jwt.Token, error) {
	keyFunc := m.KeyFunction(ctx)
	jwtToken, err := jwt.Parse(tokenString, keyFunc)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err,
		}, "unable to parse token")
		return nil, autherrors.NewUnauthorizedError(err.Error())
	}
	return jwtToken, nil
}
30409
func parse(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
	rtype := r.Type()
	if rtype.Kind() == reflect.Ptr {
		rtype = rtype.Elem() // check kind of actual element type
	}

	t := tag.Get("type")
	if t == "" {
		switch rtype.Kind() {
		case reflect.Struct:
			// also it can't be a time object
			if _, ok := r.Interface().(*time.Time); !ok {
				t = "structure"
			}
		case reflect.Slice:
			// also it can't be a byte slice
			if _, ok := r.Interface().([]byte); !ok {
				t = "list"
			}
		case reflect.Map:
			t = "map"
		}
	}

	switch t {
	case "structure":
		if field, ok := rtype.FieldByName("_"); ok {
			tag = field.Tag
		}
		return parseStruct(r, node, tag)
	case "list":
		return parseList(r, node, tag)
	case "map":
		return parseMap(r, node, tag)
	default:
		return parseScalar(r, node, tag)
	}
}
265310
func (p Parser) Parse(spec string) (Schedule, error) {
	if len(spec) == 0 {
		return nil, fmt.Errorf("Empty spec string")
	}
	if spec[0] == '@' && p.options&Descriptor > 0 {
		return parseDescriptor(spec)
	}

	// Figure out how many fields we need
	max := 0
	for _, place := range places {
		if p.options&place > 0 {
			max++
		}
	}
	min := max - p.optionals

	// Split fields on whitespace
	fields := strings.Fields(spec)

	// Validate number of fields
	if count := len(fields); count < min || count > max {
		if min == max {
			return nil, fmt.Errorf("Expected exactly %d fields, found %d: %s", min, count, spec)
		}
		return nil, fmt.Errorf("Expected %d to %d fields, found %d: %s", min, max, count, spec)
	}

	// Fill in missing fields
	fields = expandFields(fields, p.options)

	var err error
	field := func(field string, r bounds) uint64 {
		if err != nil {
			return 0
		}
		var bits uint64
		bits, err = getField(field, r)
		return bits
	}

	var (
		second     = field(fields[0], seconds)
		minute     = field(fields[1], minutes)
		hour       = field(fields[2], hours)
		dayofmonth = field(fields[3], dom)
		month      = field(fields[4], months)
		dayofweek  = field(fields[5], dow)
	)
	if err != nil {
		return nil, err
	}

	return &SpecSchedule{
		Second: second,
		Minute: minute,
		Hour:   hour,
		Dom:    dayofmonth,
		Month:  month,
		Dow:    dayofweek,
	}, nil
}
347320
func Parse(data string) (map[string]interface{}, error) {
	p, err := parse(data, "", false)
	if err != nil {
		return nil, err
	}
	return p.mapping, nil
}
738613
func DateParse(dateString, format string) (time.Time, error) {
	replacer := strings.NewReplacer(datePatterns...)
	format = replacer.Replace(format)
	return time.ParseInLocation(format, dateString, time.Local)
}
735299
func Parse(md metadata.MD) interface{} {
	if parser == nil {
		return nil
	}
	return parser.Parse(md)
}
94126
func (fs *FlagSet) Parse(line string) error {
	var args []string
	for _, token := range lexer(line, ',').split() {
		name, value := token.split()
		args = append(args, fmt.Sprintf("-%s", name))
		if value != "" {
			args = append(args, value)
		}
	}

	return fs.F.Parse(args)
}
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
}