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
- ArrayLiteral
-
Array literal:
elem1, elem2, ... - Assignment
- Assignment: x = expr
- BinaryExpr
- Binary expression: left op right
- BlockStatement
- Block of statements: { ... }
- BooleanLiteral
- Boolean literal (true/false).
- CallExpr
- Function call: func(args...)
- 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 }
- 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.
- 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.
- 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.
- 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.
- SafeAccessExpr
- Safe access: obj?.property
- ScriptResult
- Result of script execution.
- Statement
- Represents a statement node.
- StringLiteral
- String literal.
- StringTemplate
- String template: "Hello ${name}!"
- 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 KodiScript.
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.
- TimeoutException
- Exception thrown when execution timeout is exceeded.