// parseLambda parses a lambda expression.
// The allowCond flag allows the body to be an 'a if b else c' conditional.
428245
func (p *parser) parseLambda(allowCond bool) Expr {
	lambda := p.nextToken()
	var params []Expr
	if p.tok != COLON {
		params = p.parseParams()
	}
	p.consume(COLON)

	var body Expr
	if allowCond {
		body = p.parseTest()
	} else {
		body = p.parseTestNoCond()
	}

	return &LambdaExpr{
		Lambda: lambda,
		Function: Function{
			StartPos: lambda,
			Params:   params,
			Body:     []Stmt{&ReturnStmt{Result: body}},
		},
	}
}
781723
func parseHandleExtension(fields []string) (*HandleExtension, error) {
	if len(fields) != 4 {
		return nil, errHandleExtensionInvalidString
	}
	extType, un := parseHandleExtensionString(fields[1])
	if extType == HandleExtensionUnknown {
		return nil, errHandleExtensionInvalidString
	}
	date, err := time.Parse(handleExtensionDateFormat, fields[2])
	if err != nil {
		return nil, err
	}
	var num uint64 = 1
	if len(fields[3]) != 0 {
		num, err = strconv.ParseUint(fields[3], 10, 16)
		if err != nil {
			return nil, err
		}
		if num < 1 {
			return nil, errHandleExtensionInvalidNumber
		}
	}
	return &HandleExtension{
		Date:     date.UTC().Unix(),
		Number:   uint16(num),
		Type:     extType,
		Username: un,
	}, nil
}
980441
func ParseLevel(s string) (Level, error) {
	l, ok := levelStrings[strings.ToLower(s)]
	if !ok {
		return InvalidLevel, ErrInvalidLevel
	}

	return l, nil
}
208308
func ParseLabel(in string) (*Label, error) {
	if len(in) == 0 {
		return &Label{}, nil
	}

	prefix := strings.Split(in, ":")
	segment := prefix[len(prefix)-1]
	if len(prefix) > 0 {
		prefix = prefix[:len(prefix)-1]
	}
	prefixString := strings.Join(prefix, ":")
	if len(prefixString) > 0 {
		prefixString += ":"
	}

	var categories Categories
	for _, s := range strings.Split(segment, ",") {
		if !strings.HasPrefix(s, "c") {
			return nil, fmt.Errorf("categories must start with 'c': %s", segment)
		}
		i, err := strconv.Atoi(s[1:])
		if err != nil {
			return nil, err
		}
		categories = append(categories, uint16(i))
	}
	sort.Sort(categories)

	last := -1
	for _, c := range categories {
		if int(c) == last {
			return nil, fmt.Errorf("labels may not contain duplicate categories: %s", in)
		}
		last = int(c)
	}

	return &Label{
		Prefix:     prefixString,
		Categories: categories,
	}, nil
}
1301467
func ParseLevel(s string) (LogLevel, error) {
	switch s {
	case "CRITICAL", "C":
		return CRITICAL, nil
	case "ERROR", "0", "E":
		return ERROR, nil
	case "WARNING", "1", "W":
		return WARNING, nil
	case "NOTICE", "2", "N":
		return NOTICE, nil
	case "INFO", "3", "I":
		return INFO, nil
	case "DEBUG", "4", "D":
		return DEBUG, nil
	case "TRACE", "5", "T":
		return TRACE, nil
	}
	return CRITICAL, errors.New("couldn't parse log level " + s)
}
141465
func (c Config) AllowModelAccess() bool {
	value, _ := c[AllowModelAccessKey].(bool)
	return value
}
802457
func parseHandleExtensionString(s string) (HandleExtensionType, kbname.NormalizedUsername) {
	if handleExtensionConflictString == s {
		return HandleExtensionConflict, ""
	}
	m := handleExtensionFinalizedRegex.FindStringSubmatch(s)
	if len(m) < 2 {
		return HandleExtensionUnknown, ""
	}
	return HandleExtensionFinalized, kbname.NewNormalizedUsername(m[1])
}
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
}
708483
func ParseLevel(level string) (Level, error) {
	switch strings.ToUpper(level) {
	case "MAY":
		fallthrough
	case "OPTIONAL":
		return May, nil
	case "SHOULD":
		fallthrough
	case "SHOULDNOT":
		fallthrough
	case "RECOMMENDED":
		fallthrough
	case "NOTRECOMMENDED":
		return Should, nil
	case "MUST":
		fallthrough
	case "MUSTNOT":
		fallthrough
	case "SHALL":
		fallthrough
	case "SHALLNOT":
		fallthrough
	case "REQUIRED":
		return Must, nil
	}

	var l Level
	return l, fmt.Errorf("%q is not a valid compliance level", level)
}
1260871
func parseValuedParam(param string) (string, *int) {
	re := regexp.MustCompile(`(\w+)([:,](\d+))?`)
	values := re.FindStringSubmatch(param)

	parStr := strings.ToUpper(strings.Trim(values[1], " "))

	// see if the value is supplied
	if len(values) > 3 && strings.Trim(values[3], " ") != "" {
		if value, err := strconv.Atoi(strings.Trim(values[3], " ")); err == nil {
			return parStr, &value
		}
	}

	return parStr, nil
}
360238
func safeArrayAccessData(safearray *SafeArray) (element uintptr, err error) {
	err = convertHresultToError(
		procSafeArrayAccessData.Call(
			uintptr(unsafe.Pointer(safearray)),
			uintptr(unsafe.Pointer(&element))))
	return
}
968973
func ParseLevel(level string) (Level, error) {
	level = strings.ToLower(level)
	for _, l := range levels {
		if strings.ToLower(l.String()) == level {
			return l, nil
		}
	}
	return Level(0), fmt.Errorf("unrecognized log level: %s", level)
}
189032
func (db *Database) validateCallData(selector *string, data []byte, messages *core.ValidationMessages) {
	// If the data is empty, we have a plain value transfer, nothing more to do
	if len(data) == 0 {
		return
	}
	// Validate the call data that it has the 4byte prefix and the rest divisible by 32 bytes
	if len(data) < 4 {
		messages.Warn("Transaction data is not valid ABI (missing the 4 byte call prefix)")
		return
	}
	if n := len(data) - 4; n%32 != 0 {
		messages.Warn(fmt.Sprintf("Transaction data is not valid ABI (length should be a multiple of 32 (was %d))", n))
	}
	// If a custom method selector was provided, validate with that
	if selector != nil {
		if info, err := verifySelector(*selector, data); err != nil {
			messages.Warn(fmt.Sprintf("Transaction contains data, but provided ABI signature could not be matched: %v", err))
		} else {
			messages.Info(info.String())
			db.AddSelector(*selector, data[:4])
		}
		return
	}
	// No method selector was provided, check the database for embedded ones
	embedded, err := db.Selector(data[:4])
	if err != nil {
		messages.Warn(fmt.Sprintf("Transaction contains data, but the ABI signature could not be found: %v", err))
		return
	}
	if info, err := verifySelector(embedded, data); err != nil {
		messages.Warn(fmt.Sprintf("Transaction contains data, but provided ABI signature could not be varified: %v", err))
	} else {
		messages.Info(info.String())
	}
}
1087493
func parseRelevantTxAcceptedParams(params []json.RawMessage) (transaction []byte, err error) {
	if len(params) < 1 {
		return nil, wrongNumParams(len(params))
	}

	return parseHexParam(params[0])
}
809208
func ParseLabelArrayFromArray(base []string) LabelArray {
	array := make(LabelArray, len(base))
	for i := range base {
		array[i] = ParseLabel(base[i])
	}
	return array.Sort()
}
638013
func (p *Parser) parseProcId() (string, error) {
	return parseUpToLen(p.buff, &p.cursor, p.l, 128, ErrInvalidProcId)
}
567932
func (s *booleanCompilerVisitor) AcceptBooleanLiteral(v tree.BooleanLiteral) {
	if s.topLevel {
		s.ctx.unconditionalJumpTo(s.jt)
	} else {
		s.err = errors.New("a boolean literal was found in an expression - this is likely a programmer error")
	}
}