// Parse parses a CiliumNetworkPolicy and returns a list of cilium policy
// rules.
762380
func (r *CiliumNetworkPolicy) Parse() (api.Rules, error) {
	if r.ObjectMeta.Name == "" {
		return nil, fmt.Errorf("CiliumNetworkPolicy must have name")
	}

	namespace := k8sUtils.ExtractNamespace(&r.ObjectMeta)
	name := r.ObjectMeta.Name
	uid := r.ObjectMeta.UID

	retRules := api.Rules{}

	if r.Spec != nil {
		if err := r.Spec.Sanitize(); err != nil {
			return nil, fmt.Errorf("Invalid CiliumNetworkPolicy spec: %s", err)

		}
		cr := k8sCiliumUtils.ParseToCiliumRule(namespace, name, uid, r.Spec)
		retRules = append(retRules, cr)
	}
	if r.Specs != nil {
		for _, rule := range r.Specs {
			if err := rule.Sanitize(); err != nil {
				return nil, fmt.Errorf("Invalid CiliumNetworkPolicy specs: %s", err)

			}
			cr := k8sCiliumUtils.ParseToCiliumRule(namespace, name, uid, rule)
			retRules = append(retRules, cr)
		}
	}

	return retRules, 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
}
178472
func Parse(file io.Reader) (*Rules, error) {
	r := &Rules{patterns: []*pattern{}}

	s := bufio.NewScanner(file)
	for s.Scan() {
		if err := r.parseRule(s.Text()); err != nil {
			return r, err
		}
	}
	return r, s.Err()
}
599461
func (c *Configure) Parse() {
	c.setup()
	for _, opt := range c.options {
		changed := false
		for _, checker := range c.stack {
			switch opt.typ {
			case stringType:
				s, err := checker.String(opt.name)
				if err != nil {
					continue
				}

				opt.set(s)
			case intType:
				i, err := checker.Int(opt.name)
				if err != nil {
					continue
				}

				opt.set(i)
			case boolType:
				b, err := checker.Bool(opt.name)
				if err != nil {
					continue
				}

				opt.set(b)
			}

			changed = true
			break
		}

		if !changed {
			opt.set(opt.def)
		}
	}
}
530463
func ParseACLPolicy(ns *namespace.Namespace, rules string) (*Policy, error) {
	return parseACLPolicyWithTemplating(ns, rules, false, nil, nil)
}
985658
func (s ConstraintStr) Parse() (Constraints, error) {
	raw, err := version.NewConstraint(string(s))
	if err != nil {
		return Constraints{}, err
	}
	return Constraints{raw}, nil
}
41465
func (p *EnvironConfigReader) parse(reader io.Reader) error {
	var (
		line string
		err  error
	)

	bufReader := bufio.NewReader(reader)
	for err != io.EOF {
		line, err = bufReader.ReadString('\n')
		if err != nil && err != io.EOF {
			return err
		}

		line = strings.TrimSpace(strings.Split(line, "#")[0])
		if err := p.keyvalue([]byte(line)); err != nil {
			return err
		}
	}
	return nil
}
640088
func (c *commonFlags) Parse() error {
	if err := c.defaultFlags.Parse(); err != nil {
		return err
	}
	if c.serverURL == "" {
		return errors.Reason("must provide -server").Err()
	}
	s, err := lhttp.CheckURL(c.serverURL)
	if err != nil {
		return err
	}
	c.serverURL = s
	c.parsedAuthOpts, err = c.authFlags.Options()
	return err
}
707291
func (opts *ContainersOpts) parse() (url.Values, Headers) {
	v := url.Values{}
	var h Headers
	if opts != nil {
		if opts.Limit > 0 {
			v.Set("limit", strconv.Itoa(opts.Limit))
		}
		if opts.Prefix != "" {
			v.Set("prefix", opts.Prefix)
		}
		if opts.Marker != "" {
			v.Set("marker", opts.Marker)
		}
		if opts.EndMarker != "" {
			v.Set("end_marker", opts.EndMarker)
		}
		h = opts.Headers
	}
	return v, h
}
919223
func (p *binParser) parse() *Graph {

	if p == nil || !p.header() {
		return nil
	}

	ev := &SimpleEventHandler{}

	for {
		lev, bin, b := p.line(true)
		if lev == 0 {
			break
		}
		// Store the content in the same format as it was sent (string or []byte)
		if bin {
			ev.AddBytesAt(b, lev-1)
		} else {
			ev.AddAt(string(b), lev-1)
		}
	}
	return ev.Tree()
}
497657
func Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
	return new(Parser).Parse(tokenString, keyFunc)
}
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
}
443427
func Parse(r io.Reader, cfg Config) (Result, error) {
	return parseSection(r, cfg, lexIntroSection)
}
786641
func (s *HTTPServer) parse(resp http.ResponseWriter, req *http.Request, dc *string, b *structs.QueryOptions) bool {
	return s.parseInternal(resp, req, dc, b, true)
}
986135
func (p *Parser) Parse(data []byte) (interfaces.Mappable, error) {
	var feed Feed

	err := xml.Unmarshal(data, &feed)
	if err != nil {
		return nil, err
	}

	return feed, nil
}
35282
func (n *Narcissus) Parse(val interface{}) error {
	ref, err := structRef(val)
	if err != nil {
		return fmt.Errorf("invalid interface: %v", err)
	}

	err = n.Autoload(ref)
	if err != nil {
		return fmt.Errorf("failed to autoload file: %v", err)
	}

	path, err := getPath(ref)
	if err != nil {
		return fmt.Errorf("undefined path: %v", err)
	}

	return n.parseStruct(ref, path)
}
1221937
func Parse(v interface{}) ([]string, error) {
	if command, _, err := generateCommand(v, true); err == nil {
		return command, err
	} else {
		return nil, err
	}
}