kodi_script library

KodiScript - A lightweight, embeddable scripting language for Dart.

Usage:

import 'package:kodi_script/kodi_script.dart';

final result = KodiScript.run('''
  let name = "Kodi"
  print("Hello " + name)
''');

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

Classes

ArrayDestructure
Array destructuring: let a, b = expr
ArrayLiteral
Array literal: elem1, elem2, ...
Assignment
Assignment: x = expr
BinaryExpr
Binary expression: left op right
BlockStatement
Block of statements: { ... }
BooleanLiteral
Boolean literal (true/false).
BreakStatement
Break statement: break
BreakValue
Signals a break out of the nearest enclosing loop.
CallExpr
Function call: func(args...)
Computed
A computed value that automatically recalculates when dependencies change.
ContinueStatement
Continue statement: continue
ContinueValue
Signals a continue to the next iteration of the nearest loop.
ElvisExpr
Elvis expression: expr ?: default
Environment
Environment holds variable bindings.
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.
KodiAssignable
Interface for objects that support custom assignment logic.
KodiBindable
Interface for objects that can be bound to KodiScript.
KodiScript
KodiScript is the main entry point for the KodiScript SDK.
KodiScriptBuilder
Builder for KodiScript execution.
KSEngine
Persistent script engine for mini-app execution.
KSEngineResult
Result of a KSEngine operation.
Lexer
Lexer tokenizes KodiScript source code.
NativeFunctions
Registry of native functions for KodiScript.
NativeFunctionValue
Native function wrapper.
Node
Base class for all AST nodes.
NullLiteral
Null literal.
NumberLiteral
Numeric literal.
ObjectDestructure
Object destructuring: let {a, b} = expr
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.
SpreadExpr
Spread expression: ...expr (used in array literals and call arguments)
Statement
Represents a statement node.
StringLiteral
String literal.
StringTemplate
String template: "Hello ${name}!"
TernaryExpr
Ternary expression: condition ? consequent : alternative
Token
Represents a single token with type, value, and position.
TryStatement
Try/catch statement: try { body } catch (e) { catchBlock }
UnaryExpr
Unary expression: op expr
VarDecl
Variable declaration: let x = expr
WhileStatement
While statement: while (condition) { body }

Enums

ErrorKind
Classifies why execution failed, for programmatic handling.
TokenType
Represents token types in KodiScript.

Constants

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

Functions

createObs(List<Object?> args) → Rx<Object?>
Factory function to create Rx instances from KodiScript.
kodiStringify(Object? value) → String
Renders a KodiScript value in canonical form. Shared across the interpreter (print, string templates, string concatenation) and natives (toString, join) so that output is identical across language implementations:

Typedefs

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

Exceptions / Errors

KodiScriptException
Exception thrown when script execution fails.
MaxOperationsExceeded
Exception thrown when max operations is exceeded.
StackOverflowExceeded
Exception thrown when the function call depth limit is exceeded.
TimeoutException
Exception thrown when execution timeout is exceeded.