// ParseLevel parses a string into a type Level
178295
func ParseLevel(level string) (Level, error) {
	if lvl, ok := std.headers[level+": "]; ok {
		return lvl, nil
	}

	return unknown, fmt.Errorf("could not parse level %s", level)
}
118303
func parseSelectLabel(str string, delim byte) Label {
	lbl := parseLabel(str, delim)

	if lbl.Source == LabelSourceUnspec {
		lbl.Source = LabelSourceAny
	}

	return lbl
}
29768
func (p *Parser) parseFill() (FillOption, interface{}, error) {
	// Parse the expression first.
	tok, _, lit := p.ScanIgnoreWhitespace()
	p.Unscan()
	if tok != IDENT || strings.ToLower(lit) != "fill" {
		return NullFill, nil, nil
	}

	expr, err := p.ParseExpr()
	if err != nil {
		return NullFill, nil, err
	}
	fill, ok := expr.(*Call)
	if !ok {
		return NullFill, nil, errors.New("fill must be a function call")
	} else if len(fill.Args) != 1 {
		return NullFill, nil, errors.New("fill requires an argument, e.g.: 0, null, none, previous, linear")
	}
	switch fill.Args[0].String() {
	case "null":
		return NullFill, nil, nil
	case "none":
		return NoFill, nil, nil
	case "previous":
		return PreviousFill, nil, nil
	case "linear":
		return LinearFill, nil, nil
	default:
		switch num := fill.Args[0].(type) {
		case *IntegerLiteral:
			return NumberFill, num.Val, nil
		case *NumberLiteral:
			return NumberFill, num.Val, nil
		default:
			return NullFill, nil, fmt.Errorf("expected number argument in fill()")
		}
	}
}
440273
func ParseLogLevel(configuration *viper.Viper, defaultLevel logrus.Level) (
	logrus.Level, error) {

	logStr := configuration.GetString("logging.level")
	if logStr == "" {
		return defaultLevel, nil
	}
	return logrus.ParseLevel(logStr)
}
1218654
func parseBool(str string) (value bool, err error) {
	switch str {
	case "1", "t", "T", "true", "TRUE", "True", "YES", "yes", "Yes", "y", "ON", "on", "On":
		return true, nil
	case "0", "f", "F", "false", "FALSE", "False", "NO", "no", "No", "n", "OFF", "off", "Off":
		return false, nil
	}
	return false, fmt.Errorf("parsing \"%s\": invalid syntax", str)
}
373122
func (p *parser) parseSelector() (result Selector, err error) {
	p.skipWhitespace()
	result, err = p.parseSimpleSelectorSequence()
	if err != nil {
		return
	}

	for {
		var combinator byte
		if p.skipWhitespace() {
			combinator = ' '
		}
		if p.i >= len(p.s) {
			return
		}

		switch p.s[p.i] {
		case '+', '>', '~':
			combinator = p.s[p.i]
			p.i++
			p.skipWhitespace()
		case ',', ')':
			// These characters can't begin a selector, but they can legally occur after one.
			return
		}

		if combinator == 0 {
			return
		}

		c, err := p.parseSimpleSelectorSequence()
		if err != nil {
			return nil, err
		}

		switch combinator {
		case ' ':
			result = descendantSelector(result, c)
		case '>':
			result = childSelector(result, c)
		case '+':
			result = siblingSelector(result, c, true)
		case '~':
			result = siblingSelector(result, c, false)
		}
	}

	panic("unreachable")
}
1144976
func parseLoad(data string) (loads []float64, err error) {
	loads = make([]float64, 3)
	parts := strings.Fields(data)
	if len(parts) < 3 {
		return nil, fmt.Errorf("unexpected content in %s", procFilePath("loadavg"))
	}
	for i, load := range parts[0:3] {
		loads[i], err = strconv.ParseFloat(load, 64)
		if err != nil {
			return nil, fmt.Errorf("could not parse load '%s': %s", load, err)
		}
	}
	return loads, nil
}
752591
func (p *Parser) parseLeftDelim(cur *ListNode) error {
	p.pos += len(leftDelim)
	p.consumeText()
	newNode := newList()
	cur.append(newNode)
	cur = newNode
	return p.parseInsideAction(cur)
}
528807
func parseLesson(tmpl *template.Template, path string) ([]byte, error) {
	f, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer f.Close()
	doc, err := present.Parse(prepContent(f), path, 0)
	if err != nil {
		return nil, err
	}

	lesson := Lesson{
		doc.Title,
		doc.Subtitle,
		make([]Page, len(doc.Sections)),
	}

	for i, sec := range doc.Sections {
		p := &lesson.Pages[i]
		w := new(bytes.Buffer)
		if err := sec.Render(w, tmpl); err != nil {
			return nil, fmt.Errorf("render section: %v", err)
		}
		p.Title = sec.Title
		p.Content = w.String()
		codes := findPlayCode(sec)
		p.Files = make([]File, len(codes))
		for i, c := range codes {
			f := &p.Files[i]
			f.Name = c.FileName
			f.Content = string(c.Raw)
			hash := sha1.Sum(c.Raw)
			f.Hash = base64.StdEncoding.EncodeToString(hash[:])
		}
	}

	w := new(bytes.Buffer)
	if err := json.NewEncoder(w).Encode(lesson); err != nil {
		return nil, fmt.Errorf("encode lesson: %v", err)
	}
	return w.Bytes(), nil
}
94937
func parseListen(v interface{}) (*hostPort, error) {
	hp := &hostPort{}
	switch vv := v.(type) {
	// Only a port
	case int64:
		hp.port = int(vv)
	case string:
		host, port, err := net.SplitHostPort(vv)
		if err != nil {
			return nil, fmt.Errorf("could not parse address string %q", vv)
		}
		hp.port, err = strconv.Atoi(port)
		if err != nil {
			return nil, fmt.Errorf("could not parse port %q", port)
		}
		hp.host = host
	}
	return hp, nil
}
659220
func (t *tree) parseListLiteral(first item, expr ast.Node) ast.Node {
	var items []ast.Node
	items = append(items, expr)
	for {
		items = append(items, t.parseExpr(0))
		next := t.next()
		if next.typ == itemRightBracket {
			return &ast.ListLiteralNode{first.pos, items}
		}
		if next.typ != itemComma {
			t.unexpected(next, "parsing value list")
		}
	}
}
287693
func (d *domainClient) QuerySelectorAll(ctx context.Context, args *QuerySelectorAllArgs) (reply *QuerySelectorAllReply, err error) {
	reply = new(QuerySelectorAllReply)
	if args != nil {
		err = rpcc.Invoke(ctx, "DOM.querySelectorAll", args, reply, d.conn)
	} else {
		err = rpcc.Invoke(ctx, "DOM.querySelectorAll", nil, reply, d.conn)
	}
	if err != nil {
		err = &internal.OpError{Domain: "DOM", Op: "QuerySelectorAll", Err: err}
	}
	return
}
627596
func (t *tree) parseLet(token item) ast.Node {
	var name = t.expect(itemDollarIdent, "let")
	if t.peek().typ == itemColon {
		t.next()
		var node = &ast.LetValueNode{token.pos, name.val[1:], t.parseExpr(0)}
		t.expect(itemRightDelimEnd, "let")
		return node
	}
	t.parseAttrs("kind")
	switch next := t.next(); next.typ {
	case itemRightDelim:
		var node = &ast.LetContentNode{token.pos, name.val[1:], t.itemList(itemLetEnd)}
		t.expect(itemRightDelim, "let")
		return node
	default:
		t.unexpected(next, "{let}")
	}
	panic("unreachable")
}
701919
func (o Options) SelectOrderOrAll(order []byte) []Option {
	if order == nil {
		opts := make([]Option, 0, len(o))
		for i, v := range o {
			opts = append(opts, Option{Code: i, Value: v})
		}
		return opts
	}
	return o.SelectOrder(order)
}
868368
func ParseLevel(level string) (api.Level, error) {
	for i, name := range levelNames {
		if strings.EqualFold(name, level) {
			return api.Level(i), nil
		}
	}
	return api.ERROR, errors.New("logger: invalid log level")
}
844179
func (t *tree) parseListOrMap(token item) ast.Node {
	// check if it's empty
	switch t.next().typ {
	case itemColon:
		t.expect(itemRightBracket, "map literal")
		return &ast.MapLiteralNode{token.pos, nil}
	case itemRightBracket:
		return &ast.ListLiteralNode{token.pos, nil}
	}
	t.backup()

	// parse the first expression, and check the subsequent delimiter
	var firstExpr = t.parseExpr(0)
	switch tok := t.next(); tok.typ {
	case itemColon:
		return t.parseMapLiteral(token, firstExpr)
	case itemComma:
		return t.parseListLiteral(token, firstExpr)
	case itemRightBracket:
		return &ast.ListLiteralNode{token.pos, []ast.Node{firstExpr}}
	default:
		t.unexpected(tok, "list/map literal")
	}
	return nil
}
946860
func (m *defaultTypeWriter) Eval(ctx expr.EvalContext, vals []value.Value) (value.Value, bool) {

	if len(vals) == 0 || vals[0] == nil || vals[0].Nil() {
		return nil, false
	}
	switch sv := vals[0].(type) {
	case value.StringValue:
		return sv, true
	}
	return value.NewStringValue(""), false
}