// parseField parses VPP binary API object field from JSON node
358033
func parseField(ctx *context, field *jsongo.JSONNode) (*Field, error) {
	if field.Len() < 2 || field.At(0).GetType() != jsongo.TypeValue || field.At(1).GetType() != jsongo.TypeValue {
		return nil, errors.New("invalid JSON for field specified")
	}

	fieldType, ok := field.At(0).Get().(string)
	if !ok {
		return nil, fmt.Errorf("field type is %T, not a string", field.At(0).Get())
	}
	fieldName, ok := field.At(1).Get().(string)
	if !ok {
		return nil, fmt.Errorf("field name is %T, not a string", field.At(1).Get())
	}
	var fieldLength float64
	if field.Len() >= 3 {
		fieldLength, ok = field.At(2).Get().(float64)
		if !ok {
			return nil, fmt.Errorf("field length is %T, not float64", field.At(2).Get())
		}
	}
	var fieldLengthFrom string
	if field.Len() >= 4 {
		fieldLengthFrom, ok = field.At(3).Get().(string)
		if !ok {
			return nil, fmt.Errorf("field length from is %T, not a string", field.At(3).Get())
		}
	}

	return &Field{
		Name:     fieldName,
		Type:     fieldType,
		Length:   int(fieldLength),
		SizeFrom: fieldLengthFrom,
	}, nil
}
1301993
func (v *evalVisitor) evalField(ctx reflect.Value, fieldName string, exprRoot bool) reflect.Value {
	result := zero

	ctx, _ = indirect(ctx)
	if !ctx.IsValid() {
		return result
	}

	// check if this is a method call
	result, isMeth := v.evalMethod(ctx, fieldName, exprRoot)
	if !isMeth {
		switch ctx.Kind() {
		case reflect.Struct:
			// example: firstName => FirstName
			expFieldName := strings.Title(fieldName)

			// check if struct have this field and that it is exported
			if tField, ok := ctx.Type().FieldByName(expFieldName); ok && (tField.PkgPath == "") {
				// struct field
				result = ctx.FieldByIndex(tField.Index)
				break
			}

			// attempts to find template variable name as a struct tag
			result = v.evalStructTag(ctx, fieldName)
		case reflect.Map:
			nameVal := reflect.ValueOf(fieldName)
			if nameVal.Type().AssignableTo(ctx.Type().Key()) {
				// map key
				result = ctx.MapIndex(nameVal)
			}
		case reflect.Array, reflect.Slice:
			if i, err := strconv.Atoi(fieldName); (err == nil) && (i < ctx.Len()) {
				result = ctx.Index(i)
			}
		}
	}

	// check if result is a function
	result, _ = indirect(result)
	if result.Kind() == reflect.Func {
		result = v.evalFieldFunc(fieldName, result, exprRoot)
	}

	return result
}
47388
func (p *Parser) parseFields() (Fields, error) {
	var fields Fields

	for {
		// Parse the field.
		f, err := p.parseField()
		if err != nil {
			return nil, err
		}

		// Add new field.
		fields = append(fields, f)

		// If there's not a comma next then stop parsing fields.
		if tok, _, _ := p.Scan(); tok != COMMA {
			p.Unscan()
			break
		}
	}
	return fields, nil
}
816934
func objectMetaFieldsSet(objectMeta metav1.Object, namespaceScoped bool) fields.Set {
	if namespaceScoped {
		return fields.Set{
			"metadata.name":      objectMeta.GetName(),
			"metadata.namespace": objectMeta.GetNamespace(),
		}
	}
	return fields.Set{
		"metadata.name": objectMeta.GetName(),
	}
}
940462
func parseFrom(t *Tree, start Pos) (Node, error) {
	name, err := t.parseExpr()
	if err != nil {
		return nil, err
	}
	_, err = t.expectValue(tokenName, "import")
	if err != nil {
		return nil, err
	}
	imports := make(map[string]string)
	for {
		tok := t.nextNonSpace()
		switch tok.tokenType {
		case tokenEOF:
			return nil, newUnexpectedEOFError(tok)
		case tokenName:
			mal := tok.value
			mna := mal
			tok = t.peekNonSpace()
			if tok.tokenType == tokenName {
				t.nextNonSpace()
				if tok.value != "as" {
					return nil, newUnexpectedValueError(tok, "as")
				}
				tok, err = t.expect(tokenName)
				if err != nil {
					return nil, err
				}
				mal = tok.value
			}
			imports[mna] = mal
		case tokenPunctuation:
			if tok.value != "," {
				return nil, newUnexpectedValueError(tok, ",")
			}
		case tokenTagClose:
			return NewFromNode(name, imports, start), nil
		default:
			return nil, newUnexpectedTokenError(tok)
		}
	}
}
178320
func flagField(v *reflect.Value) *flag {
	return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset))
}
1241307
func (s *Server) ParseClientFirst(client_first []byte) error {
	auth_pref := []byte{'a', '='}

	if err := validateMessage(client_first); err != nil {
		return err
	}

	return sasl.EachToken(client_first, ',', func(token []byte) error {
		switch {
		case len(token) == 1 && (token[0] == 'n' || token[0] == 'y'):
			s.binding = token[0]
		case len(token) == 0 || bytes.HasPrefix(token, auth_pref):
			if bytes.HasPrefix(token, auth_pref) {
				_, v := sasl.ExtractKeyValue(token, '=')
				s.auth_id = deprepare(v)
			}
		case bytes.HasPrefix(token, []byte{'n', '='}):
			_, v := sasl.ExtractKeyValue(token, '=')
			s.username = deprepare(v)
		case bytes.HasPrefix(token, []byte{'r', '='}):
			_, v := sasl.ExtractKeyValue(token, '=')
			s.client_nonce = v
		default:
			return WrongClientMessage("Unknown field")
		}
		return nil
	})
}
877214
func parsePatternedFields(input string, schemaObject *SchemaObject) {
	lines := strings.Split(input, "\n")
	for _, line := range lines {

		line = strings.Replace(line, " \\| ", " OR ", -1)

		parts := strings.Split(line, "|")
		if len(parts) > 1 {
			fieldName := strings.Trim(stripLink(parts[0]), " ")
			fieldName = removeMarkdownLinks(fieldName)
			if fieldName == "HTTP Status Code" {
				fieldName = "^([0-9X]{3})$"
			}
			if fieldName != "Field Pattern" && fieldName != "---" {
				typeName := parts[1]
				typeName = strings.Trim(typeName, " ")
				typeName = strings.Replace(typeName, "`", "", -1)
				typeName = removeMarkdownLinks(typeName)
				typeName = strings.Replace(typeName, " ", "", -1)
				typeName = strings.Replace(typeName, "Object", "", -1)
				typeName = strings.Replace(typeName, "{expression}", "Expression", -1)
				isArray := false
				if typeName[0] == '[' && typeName[len(typeName)-1] == ']' {
					typeName = typeName[1 : len(typeName)-1]
					isArray = true
				}
				isMap := false
				mapPattern := regexp.MustCompile("^Mapstring,\\[(.*)\\]$")
				if matches := mapPattern.FindSubmatch([]byte(typeName)); matches != nil {
					typeName = string(matches[1])
					isMap = true
				}
				description := strings.Trim(parts[len(parts)-1], " ")
				description = removeMarkdownLinks(description)
				description = strings.Replace(description, "\n", " ", -1)

				schemaField := SchemaObjectField{
					Name:        fieldName,
					Type:        typeName,
					IsArray:     isArray,
					IsMap:       isMap,
					Description: description,
				}
				schemaObject.PatternedFields = append(schemaObject.PatternedFields, schemaField)
			}
		}
	}
}
1155225
func (api *API) Field(ctx context.Context, indexName, fieldName string) (*Field, error) {
	span, _ := tracing.StartSpanFromContext(ctx, "API.Field")
	defer span.Finish()

	if err := api.validate(apiField); err != nil {
		return nil, errors.Wrap(err, "validating api method")
	}

	field := api.holder.Field(indexName, fieldName)
	if field == nil {
		return nil, newNotFoundError(ErrFieldNotFound)
	}
	return field, nil
}
775368
func decodeObjectFields(objValue reflect.Value, body map[string]*json.RawMessage) error {
	objValueType := objValue.Type()
	for i := 0; i != objValue.NumField(); i++ {
		f := objValueType.Field(i)
		if f.Anonymous {
			// Recurse into fields of anonymous field
			if err := decodeObjectFields(objValue.Field(i), body); err != nil {
				return driver.WithStack(err)
			}
		} else {
			// Decode individual field
			jsonName := strings.Split(f.Tag.Get("json"), ",")[0]
			if jsonName == "" {
				jsonName = f.Name
			} else if jsonName == "-" {
				continue
			}
			raw, ok := body[jsonName]
			if ok && raw != nil {
				field := objValue.Field(i)
				if err := json.Unmarshal(*raw, field.Addr().Interface()); err != nil {
					return driver.WithStack(err)
				}
			}
		}
	}
	return nil
}
539870
func (p *parser) parseFieldValue(s string, msgName string, field *descriptor.FieldDescriptorProto) (interface{}, error) {
	switch field.GetType() {

	case descriptor.FieldDescriptorProto_TYPE_DOUBLE:
		return strconv.ParseFloat(s, 64)

	case descriptor.FieldDescriptorProto_TYPE_FLOAT:
		x, err := strconv.ParseFloat(s, 32)
		return float32(x), err

	case
		descriptor.FieldDescriptorProto_TYPE_INT32,
		descriptor.FieldDescriptorProto_TYPE_SFIXED32,
		descriptor.FieldDescriptorProto_TYPE_SINT32:

		x, err := strconv.ParseInt(s, 10, 32)
		return int32(x), err

	case descriptor.FieldDescriptorProto_TYPE_INT64,
		descriptor.FieldDescriptorProto_TYPE_SFIXED64,
		descriptor.FieldDescriptorProto_TYPE_SINT64:

		return strconv.ParseInt(s, 10, 64)

	case descriptor.FieldDescriptorProto_TYPE_UINT32, descriptor.FieldDescriptorProto_TYPE_FIXED32:
		x, err := strconv.ParseUint(s, 10, 32)
		return uint32(x), err

	case descriptor.FieldDescriptorProto_TYPE_UINT64, descriptor.FieldDescriptorProto_TYPE_FIXED64:
		return strconv.ParseUint(s, 10, 64)

	case descriptor.FieldDescriptorProto_TYPE_BOOL:
		return strconv.ParseBool(s)

	case descriptor.FieldDescriptorProto_TYPE_STRING:
		return s, nil

	case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
		return nil, fmt.Errorf(
			"%s.%s is a message field. Specify its field values, not the message itself",
			msgName, field.GetName())

	case descriptor.FieldDescriptorProto_TYPE_BYTES:
		return hex.DecodeString(s)

	case descriptor.FieldDescriptorProto_TYPE_ENUM:
		obj, err := p.resolve(field.GetTypeName())
		if err != nil {
			return nil, err
		}
		enum, ok := obj.(*descriptor.EnumDescriptorProto)
		if !ok {
			return nil, fmt.Errorf(
				"field %s.%s is declared as of type enum %s, but %s is not an enum",
				msgName, field.GetName(),
				field.GetTypeName(), field.GetTypeName(),
			)
		}
		return parseEnum(enum, s)

	default:
		return nil, fmt.Errorf("field type %s is not supported", field.GetType())
	}
}
906629
func parseField(parser *Parser) (*ast.Field, error) {
	var (
		name       *ast.Name
		alias      *ast.Name
		arguments  []*ast.Argument
		directives []*ast.Directive
		err        error
	)
	start := parser.Token.Start
	if name, err = parseName(parser); err != nil {
		return nil, err
	}
	if skp, err := skip(parser, lexer.COLON); err != nil {
		return nil, err
	} else if skp {
		alias = name
		if name, err = parseName(parser); err != nil {
			return nil, err
		}
	}
	if arguments, err = parseArguments(parser); err != nil {
		return nil, err
	}
	if directives, err = parseDirectives(parser); err != nil {
		return nil, err
	}
	var selectionSet *ast.SelectionSet
	if peek(parser, lexer.BRACE_L) {
		if selectionSet, err = parseSelectionSet(parser); err != nil {
			return nil, err
		}
	}
	return ast.NewField(&ast.Field{
		Alias:        alias,
		Name:         name,
		Arguments:    arguments,
		Directives:   directives,
		SelectionSet: selectionSet,
		Loc:          loc(parser, start),
	}), nil
}
1342871
func parseFieldLine(l string) (field, rest string, ok bool) {
	if m := fieldRe.FindStringSubmatch(l); m != nil {
		return m[1], m[2], true
	}
	return
}
603990
func (p IntParser) Parse(field string) (result interface{}, err error) {
	return strconv.ParseInt(field, 10, 64)
}
1176260
func (marshaler *DefaultEnvMarshaler) unmarshalField(
	fieldStruct reflect.StructField,
	structFieldVal reflect.Value,
	fieldEnvTag string,
	parser *DefaultParser,
) error {
	structFieldType := structFieldVal.Type()
	fieldName := fieldStruct.Name

	if structFieldType.Kind() == reflect.Ptr {
		indirectType := structFieldType.Elem()
		indirectVal, unmarshErr := marshaler.unmarshalNonPtr(indirectType, fieldEnvTag, parser)
		if unmarshErr != nil {
			return errors.Wrapf(unmarshErr, "error unmarshaling field %s", fieldName)
		}
		structFieldVal.Set(indirectVal.Addr())
		return nil

	}

	fieldVal, unmarshErr := marshaler.unmarshalNonPtr(structFieldType, fieldEnvTag, parser)
	if unmarshErr != nil {
		return errors.Wrapf(unmarshErr, "error unmarshaling field %s", fieldName)
	}

	structFieldVal.Set(*fieldVal)
	return nil
}
1041202
func ParseFromForm(req *http.Request, format Format, u ...json.Unmarshaler) (JWS, error) {
	if b, ok := fromForm(req); ok {
		return parseJumpTable[format](b, u...)
	}
	return nil, ErrNoTokenInRequest
}
68947
func ParseEnvironment(content string, environment *vpython.Environment) error {
	if err := proto.UnmarshalText(content, environment); err != nil {
		return errors.Annotate(err, "failed to unmarshal vpython.Environment").Err()
	}
	return nil
}