Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
enum IDType : Enum<IDType>
Link copied to clipboard
expect class TypedExpressionListener(functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY, constants: (String) -> Any? = { null }) : TypedExpressionListenerBase
Link copied to clipboard
abstract class TypedExpressionListenerBase(val functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY, val constants: (String) -> Any? = { null }) : KeyLangParserBaseListener

A base class for handling typed expressions in a custom language parser. This class provides an extensive set of overrides for various parser rules to allow custom implementation when these rules are triggered during parsing.

Link copied to clipboard
typealias TypedFunction0 = () -> Any
Link copied to clipboard
typealias TypedFunction1 = (Any) -> Any
Link copied to clipboard
typealias TypedFunction2 = (Any, Any) -> Any
Link copied to clipboard
typealias TypedFunction3 = (Any, Any, Any) -> Any
Link copied to clipboard
typealias TypedFunction4 = (Any, Any, Any, Any) -> Any
Link copied to clipboard
typealias TypedFunction5 = (Any, Any, Any, Any, Any) -> Any
Link copied to clipboard
class TypedFunctionExtensions(val functions0: Map<String, TypedFunction0> = emptyMap(), val functions1: Map<String, TypedFunction1> = emptyMap(), val functions2: Map<String, TypedFunction2> = emptyMap(), val functions3: Map<String, TypedFunction3> = emptyMap(), val functions4: Map<String, TypedFunction4> = emptyMap(), val functions5: Map<String, TypedFunction5> = emptyMap())

Functions

Link copied to clipboard
fun abs(x: Any): Any
Link copied to clipboard
fun <T0, R> compileFunction1(expression: String, parameter0: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY): (T0) -> R

Compiles a string expression into a single-parameter function capable of evaluating the expression.

Link copied to clipboard
fun <T0, R> compileFunction1OrNull(expression: String, parameter0: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY, onError: (Throwable) -> Unit = { }): (T0) -> R?

Tries to compile a given string expression into a single-parameter function. Returns the compiled function if successful, or null if an error occurs during compilation. Errors are handled using the provided onError callback.

Link copied to clipboard
fun <T0, T1, R> compileFunction2(expression: String, parameter0: String, parameter1: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY): (T0, T1) -> R

Compiles a string expression into a lambda function with two parameters.

Link copied to clipboard
fun <T0, T1, R> compileFunction2OrNull(expression: String, parameter0: String, parameter1: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY, onError: (Throwable) -> Unit = { }): (T0, T1) -> R?

Attempts to compile a string expression into a lambda function with two parameters, returning null if an error occurs during compilation.

Link copied to clipboard
fun <T0, T1, T2, R> compileFunction3(expression: String, parameter0: String, parameter1: String, parameter2: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY): (T0, T1, T2) -> R

Compiles a 3-parameter function from a given string expression, allowing dynamic evaluation with specified parameters, constants, and external function extensions.

Link copied to clipboard
fun <T0, T1, T2, R> compileFunction3OrNull(expression: String, parameter0: String, parameter1: String, parameter2: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY, onError: (Throwable) -> Unit = { }): (T0, T1, T2) -> R?

Compiles a 3-parameter function from a given string expression, returning null if an error occurs during compilation.

Link copied to clipboard
fun compileTypedExpression(expression: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY): () -> Any

Compiles a typed expression and returns a lambda that can execute the compiled expression.

Link copied to clipboard
fun evaluateTypedExpression(expression: String, constants: (String) -> Any? = { null }, functions: TypedFunctionExtensions = TypedFunctionExtensions.EMPTY): Any?

Evaluates a typed expression based on the provided string input, constants, and function definitions.