// Parse parses the DataType expecting it to be a String type.
10348
func (parser StringTypeParser) Parse(d DataType) error {
	if value, ok := AsString(d); ok {
		parser.setter(value)
	} else {
		return fmt.Errorf("Error parsing type of %#v as a String", d)
	}
	return nil
}
849437
func (p *ParamParser) Parse(paramTypes []ast.ParamType) (*ast.ParamStatement, error) {
	l := lexer.New(p.src)

	stmt := &ast.ParamStatement{
		ErrorCode: DefaultParamErrorCode,
		Type:      ast.GetMasterParamType(paramTypes...),
		Src:       p.src,
	}

	lastParamFunc := ast.ParamFunc{}

	for {
		t := l.NextToken()
		if t.Type == token.EOF {
			if stmt.Name == "" {
				p.appendErr("[1:] parameter name is missing")
			}
			break
		}

		switch t.Type {
		case token.LBRACE:
			// can accept only letter or number only.
			nextTok := l.NextToken()
			stmt.Name = nextTok.Literal
		case token.COLON:
			// type can accept both letters and numbers but not symbols ofc.
			nextTok := l.NextToken()
			paramType, found := ast.LookupParamType(nextTok.Literal, paramTypes...)

			if !found {
				p.appendErr("[%d:%d] unexpected parameter type: %s", t.Start, t.End, nextTok.Literal)
			}
			stmt.Type = paramType
			// param func
		case token.IDENT:
			lastParamFunc.Name = t.Literal
		case token.LPAREN:
			// param function without arguments ()
			if l.PeekNextTokenType() == token.RPAREN {
				// do nothing, just continue to the RPAREN
				continue
			}

			argValTok := l.NextDynamicToken() // catch anything from "(" and forward, until ")", because we need to
			// be able to use regex expression as a macro type's func argument too.

			// fmt.Printf("argValTok: %#v\n", argValTok)
			// fmt.Printf("argVal: %#v\n", argVal)
			lastParamFunc.Args = append(lastParamFunc.Args, argValTok.Literal)

		case token.COMMA:
			argValTok := l.NextToken()
			lastParamFunc.Args = append(lastParamFunc.Args, argValTok.Literal)
		case token.RPAREN:
			stmt.Funcs = append(stmt.Funcs, lastParamFunc)
			lastParamFunc = ast.ParamFunc{} // reset
		case token.ELSE:
			errCodeTok := l.NextToken()
			if errCodeTok.Type != token.INT {
				p.appendErr("[%d:%d] expected error code to be an integer but got %s", t.Start, t.End, errCodeTok.Literal)
				continue
			}
			errCode, err := strconv.Atoi(errCodeTok.Literal)
			if err != nil {
				// this is a bug on lexer if throws because we already check for token.INT
				p.appendErr("[%d:%d] unexpected lexer error while trying to convert error code to an integer, %s", t.Start, t.End, err.Error())
				continue
			}
			stmt.ErrorCode = errCode
		case token.RBRACE:
			// check if } but not {
			if stmt.Name == "" {
				p.appendErr("[%d:%d] illegal token: }, forgot '{' ?", t.Start, t.End)
			}
			break
		case token.ILLEGAL:
			p.appendErr("[%d:%d] illegal token: %s", t.Start, t.End, t.Literal)
		default:
			p.appendErr("[%d:%d] unexpected token type: %q with value %s", t.Start, t.End, t.Type, t.Literal)
		}
	}

	return stmt, p.Error()
}
104638
func parse(text []byte) (t *tree, err error) {
	t = &tree{
		text: text,
	}
	err = t.Parse(text)
	return
}
899667
func Parse(s string) (r T, err error) {
	_, err = fmt.Sscan(s,
		&r.P0[0], &r.P0[1],
		&r.P1[0], &r.P1[1],
		&r.P2[0], &r.P2[1],
	)
	return r, err
}
961350
func Parse(data string) (out String, _ error) {
	var (
		// Variables used by Ragel
		cs  = 0 // current state
		p   = 0 // current position in data
		pe  = len(data)
		eof = pe // eof == pe if this is the last data block

		// We use the following variables to actually build the String.

		// Index in data where the currently captured string started.
		idx int

		v variable // variable being read, if any
		l literal  // literal being read, if any

		// Current term. This is either the variable that we just read or the
		// literal. We will append it to `out` and move on.
		t term
	)

	{
		cs = interpolate_start
	}

	{
		if p == pe {
			goto _test_eof
		}
		switch cs {
		case 8:
			goto st_case_8
		case 9:
			goto st_case_9
		case 1:
			goto st_case_1
		case 10:
			goto st_case_10
		case 2:
			goto st_case_2
		case 3:
			goto st_case_3
		case 0:
			goto st_case_0
		case 4:
			goto st_case_4
		case 5:
			goto st_case_5
		case 6:
			goto st_case_6
		case 7:
			goto st_case_7
		}
		goto st_out
	st_case_8:
		switch data[p] {
		case 36:
			goto st1
		case 92:
			goto st2
		}
		goto tr12
	tr12:
		idx = p
		l = literal(data[idx : p+1])
		t = l
		goto st9
	tr15:
		l = literal(data[idx : p+1])
		t = l
		goto st9
	tr18:
		out = append(out, t)
		idx = p
		l = literal(data[idx : p+1])
		t = l
		goto st9
	st9:
		if p++; p == pe {
			goto _test_eof9
		}
	st_case_9:
		switch data[p] {
		case 36:
			goto tr16
		case 92:
			goto tr17
		}
		goto tr15
	tr16:
		out = append(out, t)
		goto st1
	st1:
		if p++; p == pe {
			goto _test_eof1
		}
	st_case_1:
		if data[p] == 123 {
			goto st3
		}
		goto tr0
	tr0:
		l = literal(data[p-1 : p+1])
		t = l
		goto st10
	tr2:
		l = literal(data[p : p+1])
		t = l
		goto st10
	tr8:
		t = v
		goto st10
	tr10:
		idx = p
		t = v
		goto st10
	st10:
		if p++; p == pe {
			goto _test_eof10
		}
	st_case_10:
		switch data[p] {
		case 36:
			goto tr16
		case 92:
			goto tr17
		}
		goto tr18
	tr17:
		out = append(out, t)
		goto st2
	st2:
		if p++; p == pe {
			goto _test_eof2
		}
	st_case_2:
		goto tr2
	st3:
		if p++; p == pe {
			goto _test_eof3
		}
	st_case_3:
		if data[p] == 95 {
			goto tr3
		}
		switch {
		case data[p] > 90:
			if 97 <= data[p] && data[p] <= 122 {
				goto tr3
			}
		case data[p] >= 65:
			goto tr3
		}
		goto st0
	st_case_0:
	st0:
		cs = 0
		goto _out
	tr3:
		idx = p
		v.Name = data[idx : p+1]
		goto st4
	tr6:
		v.Name = data[idx : p+1]
		goto st4
	st4:
		if p++; p == pe {
			goto _test_eof4
		}
	st_case_4:
		switch data[p] {
		case 58:
			goto tr7
		case 95:
			goto tr6
		case 125:
			goto tr8
		}
		switch {
		case data[p] < 48:
			if 45 <= data[p] && data[p] <= 46 {
				goto st5
			}
		case data[p] > 57:
			switch {
			case data[p] > 90:
				if 97 <= data[p] && data[p] <= 122 {
					goto tr6
				}
			case data[p] >= 65:
				goto tr6
			}
		default:
			goto tr6
		}
		goto st0
	st5:
		if p++; p == pe {
			goto _test_eof5
		}
	st_case_5:
		if data[p] == 95 {
			goto tr6
		}
		switch {
		case data[p] < 65:
			if 48 <= data[p] && data[p] <= 57 {
				goto tr6
			}
		case data[p] > 90:
			if 97 <= data[p] && data[p] <= 122 {
				goto tr6
			}
		default:
			goto tr6
		}
		goto st0
	tr7:
		v.HasDefault = true
		goto st6
	st6:
		if p++; p == pe {
			goto _test_eof6
		}
	st_case_6:
		if data[p] == 125 {
			goto tr10
		}
		goto tr9
	tr9:
		idx = p
		v.Default = data[idx : p+1]
		goto st7
	tr11:
		v.Default = data[idx : p+1]
		goto st7
	st7:
		if p++; p == pe {
			goto _test_eof7
		}
	st_case_7:
		if data[p] == 125 {
			goto tr8
		}
		goto tr11
	st_out:
	_test_eof9:
		cs = 9
		goto _test_eof
	_test_eof1:
		cs = 1
		goto _test_eof
	_test_eof10:
		cs = 10
		goto _test_eof
	_test_eof2:
		cs = 2
		goto _test_eof
	_test_eof3:
		cs = 3
		goto _test_eof
	_test_eof4:
		cs = 4
		goto _test_eof
	_test_eof5:
		cs = 5
		goto _test_eof
	_test_eof6:
		cs = 6
		goto _test_eof
	_test_eof7:
		cs = 7
		goto _test_eof

	_test_eof:
		{
		}
		if p == eof {
			switch cs {
			case 9, 10:
				out = append(out, t)
			}
		}

	_out:
		{
		}
	}


	if cs < 8 {
		return out, fmt.Errorf("cannot parse string %q", data)
	}

	return out, nil
}
292460
func Parse(s string) (t *Template, err error) {
	t = new(Template)
	t.tree, err = parse.Parse(s)
	if err != nil {
		return nil, err
	}
	return t, nil
}
52530
func (*Bytes) Parse(value string) (i uint64, err error) {
	parts := pattern.FindStringSubmatch(value)
	if len(parts) < 3 {
		return 0, fmt.Errorf("error parsing value=%s", value)
	}
	bytesString := parts[1]
	multiple := parts[2]
	bytes, err := strconv.ParseUint(bytesString, 10, 64)
	if err != nil {
		return
	}

	switch multiple {
	case "B":
		return bytes * B, nil
	case "K", "KB":
		return bytes * KB, nil
	case "M", "MB":
		return bytes * MB, nil
	case "G", "GB":
		return bytes * GB, nil
	case "T", "TB":
		return bytes * TB, nil
	case "P", "PB":
		return bytes * PB, nil
	}

	return
}
1167653
func (p *Parser) Parse() error {
	for {
		t, err := p.decoder.Token()
		if err == io.EOF {
			break
		} else if serr, ok := err.(*json.SyntaxError); ok {
			return WithStack(&ParseError{msg: err.Error(), Offset: serr.Offset})
		} else if err != nil {
			return WithStack(&ParseError{msg: err.Error()})
		}
		switch x := t.(type) {
		case nil:
			if err := p.builder.AddValue(NewNullValue()); err != nil {
				return WithStack(err)
			}
		case bool:
			if err := p.builder.AddValue(NewBoolValue(x)); err != nil {
				return WithStack(err)
			}
		case json.Number:
			if xu, err := strconv.ParseUint(string(x), 10, 64); err == nil {
				if err := p.builder.AddValue(NewUIntValue(xu)); err != nil {
					return WithStack(err)
				}
			} else if xi, err := x.Int64(); err == nil {
				if err := p.builder.AddValue(NewIntValue(xi)); err != nil {
					return WithStack(err)
				}
			} else {
				if xf, err := x.Float64(); err == nil {
					if err := p.builder.AddValue(NewDoubleValue(xf)); err != nil {
						return WithStack(err)
					}
				} else {
					return WithStack(&ParseError{msg: err.Error()})
				}
			}
		case string:
			if err := p.builder.AddValue(NewStringValue(x)); err != nil {
				return WithStack(err)
			}
		case json.Delim:
			switch x {
			case '[':
				if err := p.builder.OpenArray(p.options.BuildUnindexedArrays); err != nil {
					return WithStack(err)
				}
			case '{':
				if err := p.builder.OpenObject(p.options.BuildUnindexedObjects); err != nil {
					return WithStack(err)
				}
			case ']', '}':
				if err := p.builder.Close(); err != nil {
					return WithStack(err)
				}
			}
		}
	}
	return nil
}
1332130
func Parse(input string) (*Tree, error) {
	t := NewTree(bytes.NewReader([]byte(input)))
	return t, t.Parse()
}
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
}
717535
func parse(data []byte) (datapointArray []pluginData, err error) {
	var endpointData endpointInfo

	if err = json.Unmarshal(data, &endpointData); err != nil {
		err = fmt.Errorf("Processing JSON structure")
		return
	}

	for _, point := range endpointData.Payload {
		datapointArray = append(datapointArray, point)
	}

	return
}
212694
func Parse(s string) (map[string]interface{}, error) {
	vals := map[string]interface{}{}
	scanner := bytes.NewBufferString(s)
	t := newParser(scanner, vals, false)
	err := t.parse()
	return vals, err
}
985658
func (s ConstraintStr) Parse() (Constraints, error) {
	raw, err := version.NewConstraint(string(s))
	if err != nil {
		return Constraints{}, err
	}
	return Constraints{raw}, nil
}
735299
func Parse(md metadata.MD) interface{} {
	if parser == nil {
		return nil
	}
	return parser.Parse(md)
}
106997
func (parser *myParser) Parse(s string) error {
	typ := reflect.TypeOf(parser.ptr)
	val := reflect.ValueOf(parser.ptr)
	if typ.Kind() == reflect.Ptr {
		kind := reflect.Indirect(val).Type().Kind()
		if kind == reflect.Struct {
			typElem, valElem := typ.Elem(), val.Elem()
			numField := valElem.NumField()
			for i := 0; i < numField; i++ {
				_, valField := typElem.Field(i), valElem.Field(i)
				if valField.Kind() == reflect.Int &&
					valField.CanSet() {
					valField.SetInt(2)
				}
				if valField.Kind() == reflect.String &&
					valField.CanSet() {
					valField.SetString("B")
				}
			}
		}
	}
	return nil
}
353291
func parse(str string, index int) *Pair {
	var key, value string
	if index > 0 {
		key, value = str[:index], str[index+1:]
	} else if index == 0 {
		key, value = "", str[1:]
	} else if index < 0 {
		key, value = str, ""
	}

	return &Pair{Key: key, Value: value}
}
1221937
func Parse(v interface{}) ([]string, error) {
	if command, _, err := generateCommand(v, true); err == nil {
		return command, err
	} else {
		return nil, err
	}
}