krom_script library

KromScript - A lightweight, embeddable scripting language for Dart.

Usage:

import 'package:krom_script/krom_script.dart';

final result = KromScript.run('''
  let name = "Krom"
  print("Hello " + name)
''');

print(result.output); // ["Hello Krom"]

Classes

ArrayLiteral
Array literal: elem1, elem2, ...
Assignment
Assignment: x = expr Assignment: left = expr
ASTPrinter
ASTPrinter converts an AST back into KromScript source code.
BinaryExpr
Binary expression: left op right
BlockStatement
Block of statements: { ... }
BooleanLiteral
Boolean literal (true/false).
CallExpr
Function call: func(args...)
Computed
A computed value that automatically recalculates when dependencies change.
ElvisExpr
Elvis expression: expr ?: default
Environment
Environment holds variable bindings.
ExecutionLimits
Limits applied to every script execution — KromScript.eval / run / builder(...).execute() as well as the mini-app engine (top-level load, build(), callbacks, reactive builders) — so a misbehaving — or hostile — mini-app cannot hang the host: an operation budget and a wall-clock deadline, both enforced by the interpreter at each statement and loop iteration.
ExecutionResult
Result of an interpreter execution.
Expression
Represents an expression node.
ExpressionStatement
Expression statement wraps an expression.
ForStatement
For statement: for (variable in iterable) { body }
FunctionDeclaration
Function declaration: function name(params) { body }
FunctionLiteral
Function literal: fn(x, y) { ... }
FunctionValue
Function value (user defined).
Identifier
Variable identifier.
IfStatement
If statement: if (condition) { consequence } else { alternative }
IndexExpr
Index expression: leftindex
Interpreter
Interpreter evaluates AST nodes.
KromBindable
Interface for objects that can be bound to KromScript.
KromScript
KromScript is the main entry point for the KromScript SDK.
KromScriptBuilder
Builder for KromScript execution.
KSEngine
Persistent script engine for mini-app execution.
KSEngineResult
Result of a KSEngine operation.
Lexer
Lexer tokenizes KromScript source code.
NativeFunctions
Registry of native functions for KromScript.
NativeFunctionValue
Native function wrapper.
Node
Base class for all AST nodes.
NullLiteral
Null literal.
NumberLiteral
Numeric literal.
ObjectLiteral
Object literal: {key: value, ...}
Parser
Parser parses tokens from a Lexer into an AST.
Program
Program is the root node of every AST.
PropertyAccessExpr
Property access: obj.property
ReturnStatement
Return statement: return expr
ReturnValue
Wrapper to signal early return from evaluation.
Rx<T>
A reactive variable that notifies listeners when its value changes.
RxNotifier
Singleton manager for reactive dependency capture.
SafeAccessExpr
Safe access: obj?.property
ScriptResult
Result of script execution.
Statement
Represents a statement node.
StringLiteral
String literal.
StringTemplate
String template: "Hello ${name}!"
TernaryExpr
Ternary conditional: condition ? consequent : alternate
Token
Represents a single token with type, value, and position.
UnaryExpr
Unary expression: op expr
VarDecl
Variable declaration: let x = expr
WhileStatement
While statement: while (condition) { body }

Enums

TokenType
Represents token types in KromScript.

Constants

methodNotFound → const _MethodNotFound
Sentinel value indicating a method was not found on a KromBindable object.

Functions

createObs(List<Object?> args) Rx<Object?>
Factory function to create Rx instances from KromScript.
kromCanonicalNumber(num value) num
THE RULE — one canonical numeric representation, applied on every path.
kromCanonicalValue(Object? value) Object?
Applies kromCanonicalNumber to value and, recursively, to every number inside a List or a Map it contains.
kromDisplay(Object? value) String
Converts a KromScript value to its display string.

Typedefs

NativeFunc = Object? Function(List<Object?> args)
Native function signature.

Exceptions / Errors

KromException
Base exception for all KromScript errors.
KromResourceError
Error thrown when script execution times out or exceeds operation limit.
KromRuntimeError
Error thrown during execution (runtime error).
KromScriptException
Exception thrown when script execution fails.
KromSyntaxError
Error thrown during parsing (syntax error).