boolexpr

package
v0.0.0-...-ba608e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package boolexpr evaluates boolean expressions over integers. Used by ExpressionRecognition (OCR node placeholders) and IMS R1 (cached item IDs).

Index

Constants

This section is empty.

Variables

View Source
var (
	// PlaceholderPattern matches {name} tokens in an expression.
	PlaceholderPattern = regexp.MustCompile(`\{([^{}]+)\}`)

	IntMax = int(^uint(0) >> 1)
	IntMin = -IntMax - 1
)

Functions

func ClampInt

func ClampInt(value float64) int

ClampInt clamps a float64 into platform int range.

func Evaluate

func Evaluate(expression string) (any, error)

Evaluate parses and evaluates a boolean or integer expression. Callers that need a recognition hit must assert the result is bool.

func ParseIntLiteral

func ParseIntLiteral(raw string) (int, error)

ParseIntLiteral parses an integer literal; out-of-range values clamp to IntMax/IntMin.

func ResolvePlaceholders

func ResolvePlaceholders(expression string, resolve ResolveFunc) (string, map[string]int, error)

ResolvePlaceholders replaces every {name} in expression via resolve. Returns the numeric expression string and a map of placeholder → value.

Types

type ResolveFunc

type ResolveFunc func(name string) (int, error)

ResolveFunc maps a placeholder name to an integer value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL