Haxe API Reference
The complete public API of the Loreline runtime.
New to Loreline in Haxe? Start with the integration guide. This page is the comprehensive reference.
This reference is wider than the others. Haxe is the language Loreline is written in, and every other target is compiled from it: the classes below include the whole AST node hierarchy and the interpreter's runtime state, which the wrappers of the other languages do not expose.
Quick reference
Loreline
The main public API for Loreline runtime. Provides easy access to the core functionality for parsing and running Loreline scripts.
parse
public static function parse(input:String, ?filePath:String, ?handleFile:ImportsFileHandler, ?callback:(script:Script)->Void):Null<Script>
Parses the given text input and creates an executable Script instance from it.
| Parameter | Type | Description |
|---|---|---|
input |
String |
The Loreline script content as a string (.lor format)
|
filePath |
String |
Optional file path of the input being parsed. If provided, requires handleFile as well.
|
handleFile |
ImportsFileHandler |
Optional file handler to read imports. If that handler is asynchronous, then parse() will return null and callback argument should be used
|
callback |
(script:Script)->Void |
If provided, will be called with the resulting script as argument. Mostly useful when reading file imports asynchronously |
Returns
Null<Script>
The parsed script as an AST Script instance (if loaded synchronously)
Throws If the script contains syntax errors or other parsing issues
This is the first step in working with a Loreline script. The returned Script object can then be passed to methods play() or resume().
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
play
public static function play(script:Script, handleDialogue:DialogueHandler, handleChoice:ChoiceHandler, handleFinish:FinishHandler, ?beatName:String, ?options:InterpreterOptions):Interpreter
Starts playing a Loreline script from the beginning or a specific beat.
| Parameter | Type | Description |
|---|---|---|
script |
Script |
The parsed script (result from parse())
|
handleDialogue |
DialogueHandler |
Function called when dialogue text should be displayed |
handleChoice |
ChoiceHandler |
Function called when player needs to make a choice |
handleFinish |
FinishHandler |
Function called when script execution completes |
beatName |
String |
Optional name of a specific beat to start from (defaults to first beat) |
options |
InterpreterOptions |
Additional options |
Returns
Interpreter
The interpreter instance that is running the script
This function takes care of initializing the interpreter and starting execution immediately. You'll need to provide handlers for dialogues, choices, and script completion.
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
resume
public static function resume(script:Script, handleDialogue:DialogueHandler, handleChoice:ChoiceHandler, handleFinish:FinishHandler, saveData:SaveData, ?beatName:String, ?options:InterpreterOptions):Interpreter
Resumes a previously saved Loreline script from its saved state.
| Parameter | Type | Description |
|---|---|---|
script |
Script |
The parsed script (result from parse())
|
handleDialogue |
DialogueHandler |
Function called when dialogue text should be displayed |
handleChoice |
ChoiceHandler |
Function called when player needs to make a choice |
handleFinish |
FinishHandler |
Function called when script execution completes |
saveData |
SaveData |
The saved game data (typically from interpreter.save())
|
beatName |
String |
Optional beat name to override where to resume from |
options |
InterpreterOptions |
Optional options to configure interpreter behavior |
Returns
Interpreter
The interpreter instance that is running the script
This allows you to continue a story from the exact point where it was saved, restoring all state variables, choices, and player progress.
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
extractTranslations
public static function extractTranslations(script:Script):Map<String, NStringLiteral>
Extracts translations from a parsed translation script.
| Parameter | Type | Description |
|---|---|---|
script |
Script |
The parsed translation script (result from parse() on a .XX.lor file)
|
Returns
Map<String, NStringLiteral>
A translations map to pass as InterpreterOptions.translations
Given a translation file parsed with parse(), this returns a translations map that can be passed as options.translations to play() or resume().
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
loadLocale
public static function loadLocale(locale:String, script:Script, ?filePath:String, ?handleFile:ImportsFileHandler, ?callback:(translations:Map<String, NStringLiteral>)->Void):Null<Map<String, NStringLiteral>>
Loads translations for a specific locale, walking the script's full import tree.
| Parameter | Type | Description |
|---|---|---|
locale |
String |
The locale code (e.g. "fr")
|
script |
Script |
The parsed source script (must have been parsed with a file path, or filePath must be provided)
|
filePath |
String |
Optional override for where to look for translation files (defaults to script.filePath). Can be a .lor/.lor.txt file path or a directory.
|
handleFile |
ImportsFileHandler |
File handler used to read translation files |
callback |
(translations:Map<String, NStringLiteral>)->Void |
Called with the merged translations map. Required if handleFile is asynchronous.
|
Returns
Null<Map<String, NStringLiteral>>
The merged translations map (synchronously, when handleFile is sync), or null if a translation file exists but is invalid. Missing translation files are still skipped silently. lastError() is only set when a file is present but can't be parsed (broken .lor, malformed .po/.xliff/.csv, etc.).
For each file involved in the script (root + transitively imported), the corresponding translation file is looked up by inserting .<locale> before the extension (e.g. characters.lor -> characters.fr.lor). Missing translation files are silently skipped.
Each translation key is stored under both:
- a global key
<id>(first occurrence wins, root file priority) - a scoped key
<source-rel-path>#<id>(always set per file, allows override)
The interpreter prefers the scoped key when looking up a translation.
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
translationFormat
public static function translationFormat(name:String, enabled:Bool):Void
Enable or disable runtime support for an alternate translation file format.
| Parameter | Type | Description |
|---|---|---|
name |
String |
The format identifier (see above) |
enabled |
Bool |
True to enable the format, false to disable |
Returns
Void
By default, only .<locale>.lor files are tried by loadLocale. Call this to opt in to additional formats. Known names:
"po": GNU gettext PO (.po)"xliff": XLIFF 1.2 / 2.x (.xliff,.xlf)"csv": CSV / TSV (.csv,.tsv)
Unknown names are accepted silently (forward-compat for future formats).
Malformed files in an enabled format (e.g. broken XML in a .xliff, a .po with an unterminated quoted string) surface as loreline.Error out of loadLocale, caught via try/catch in sync mode, or via Loreline.lastError() after a callback fires with null in async mode.
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
lastError
public static function lastError():Null<Error>
Returns the error from the most recent failed parse() or loadLocale() call, or null on success.
Returns
Null<Error>
In async mode (callback supplied) the callback fires with null on failure and this method tells you what went wrong. In sync mode the call throws, and this is set to the same error so it can be inspected after the catch.
Not thread-safe: read immediately after the call returns.
JavaScript TypeScript C# C++ Java PHP Python Lua Haxe
print
public static function print(script:Script, ?indent:String, ?newline:String):String
Prints a parsed script back into Loreline source code.
| Parameter | Type | Description |
|---|---|---|
script |
Script |
The parsed script (result from parse())
|
indent |
String |
The indentation string to use (defaults to two spaces) |
newline |
String |
The newline string to use (defaults to "\n") |
Returns
String
The printed source code as a string
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
update
public static function update(delta:Float):Void
Ticks pending wait() timers. Call this from your game loop every frame. The first call enables non-blocking deferred mode for wait() on sys targets; before this is called, wait() falls back to blocking Sys.sleep() (correct for CLI tools).
| Parameter | Type | Description |
|---|---|---|
delta |
Float |
Time elapsed since last frame in seconds |
Returns
Void
generateTranslationFile
public static function generateTranslationFile(script:Script, ?existing:Map<String, NStringLiteral>, ?format:String, ?locale:String):String
Generates a translation file body for the given source script.
| Parameter | Type | Description |
|---|---|---|
script |
Script |
The parsed source script |
existing |
Map<String, NStringLiteral> |
(optional) Existing translations to preserve when merging |
format |
String |
|
locale |
String |
Returns
String
The translation file body as a string, ready to write to disk
Each translatable string in the source that has an #id marker becomes one entry in the output. If existing is provided (typically the result of extractTranslations on a previously-saved translation file), entries already filled in there are preserved verbatim; otherwise each entry seeds with the source text.
Companion to the loreline translate ... --lang xx CLI command.
insertLocalizationKeys
public static function insertLocalizationKeys(content:String, script:Script, ?includeImports:Bool = true, ?reservedIds:Map<String, Bool>):String
Inserts #id markers after every translatable string in content that doesn't already have one. script must be the AST parsed from the same content. Returns the rewritten content.
| Parameter | Type | Description |
|---|---|---|
content |
String |
|
script |
Script |
|
includeImports |
Bool |
|
reservedIds |
Map<String, Bool> |
Returns
String
When includeImports is false, imported scripts are skipped, their byte offsets refer to other files' contents and would corrupt content. Tooling that walks imports externally should pass false.
When reservedIds is provided, it's used (and mutated) as the shared existing-IDs set across calls, useful for coordinating ID generation across multiple per-file invocations so that file B's auto-IDs avoid every ID already in file A. Existing IDs from this file's hash comments are added to the map; newly-generated IDs are added too.
Equivalent to the --auto-ids flag of the loreline translate CLI.
collectHashIds
public static function collectHashIds(content:String, ?out:Map<String, Bool>):Map<String, Bool>
Lex-only scan of content for every hash-comment identifier (#xxxx). Cheap compared to a full parse. Runs the lexer over the text and pulls out every CommentHash payload. Use to build project-wide reserved-IDs registries.
| Parameter | Type | Description |
|---|---|---|
content |
String |
|
out |
Map<String, Bool> |
Returns
Map<String, Bool>
Fills and returns out (or a fresh map when out is null).
removeLocalizationKeys
public static function removeLocalizationKeys(content:String, script:Script):String
Strips every #id marker emitted by insertLocalizationKeys (or authored manually). The inverse operation. Returns the rewritten content. Equivalent to the --clear flag of the loreline translate CLI.
| Parameter | Type | Description |
|---|---|---|
content |
String |
|
script |
Script |
Returns
String
extractTranslatableEntries
public static function extractTranslatableEntries(script:Script):Array<{ str:NStringLiteral, id:String }>
Returns every #id-tagged translatable string in script paired with its id. Strings WITHOUT an #id marker are filtered out. Use hasUntaggedTranslatableStrings to detect those.
| Parameter | Type | Description |
|---|---|---|
script |
Script |
Returns
Array<{ str:NStringLiteral, id:String }>
hasUntaggedTranslatableStrings
public static function hasUntaggedTranslatableStrings(script:Script):Bool
Returns true if script contains at least one translatable string (text statement, dialogue, or choice option) that has no #id hash comment. Non-mutating, purely an AST inspection. Used by tooling to gate "add tags?" prompts before generating translation files.
| Parameter | Type | Description |
|---|---|---|
script |
Script |
Returns
Bool
Interpreter
Main interpreter class for Loreline scripts. This class is responsible for executing a parsed Loreline script, managing the runtime state, and interacting with the host application through handler functions.
new
public function new(script:Script, handleDialogue:DialogueHandler, handleChoice:ChoiceHandler, handleFinish:FinishHandler, ?options:InterpreterOptions)
Creates a new Loreline script interpreter.
| Parameter | Type | Description |
|---|---|---|
script |
Script |
The parsed script to execute |
handleDialogue |
DialogueHandler |
Function to call when displaying dialogue text |
handleChoice |
ChoiceHandler |
Function to call when presenting choices |
handleFinish |
FinishHandler |
Function to call when execution finishes |
options |
InterpreterOptions |
Additional options |
JavaScript TypeScript C# Java Python Haxe
start
public function start(?beatName:String):Void
Starts script execution from the beginning or a specific beat.
| Parameter | Type | Description |
|---|---|---|
beatName |
String |
Optional name of the beat to start from. If null, execution starts from the first beat or a beat named "_" if it exists. |
Returns
Void
Throws RuntimeError If the specified beat doesn't exist or if no beats are found in the script
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
save
public function save():SaveData
Saves the current state of the interpreter. This includes all state variables, character states, and execution stack, allowing execution to be resumed later from the exact same point.
Returns
SaveData
A SaveData object containing the serialized state
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
restore
public function restore(saveData:SaveData):Void
Restores the interpreter state from a SaveData object. This allows resuming execution from a previously saved state.
| Parameter | Type | Description |
|---|---|---|
saveData |
SaveData |
The SaveData object containing the serialized state |
Returns
Void
Throws RuntimeError If the save data version is incompatible
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
resume
public function resume():Void
Resumes execution after restoring state. This should be called after restore() to continue execution.
Returns
Void
JavaScript TypeScript C# Java PHP Python Lua Haxe
getCharacter
public function getCharacter(name:String):Any
Gets a character by name.
| Parameter | Type | Description |
|---|---|---|
name |
String |
The name of the character to get |
Returns
Any
The character's fields or null if the character doesn't exist
JavaScript TypeScript C# Java PHP Python Lua Haxe
getCharacterField
public function getCharacterField(character:String, name:String):Any
Gets a specific field of a character.
| Parameter | Type | Description |
|---|---|---|
character |
String |
The name of the character |
name |
String |
The name of the field to get |
Returns
Any
The field value or null if the character or field doesn't exist
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
setCharacterField
public function setCharacterField(character:String, name:String, value:Any):Void
Sets a specific field on a character.
| Parameter | Type | Description |
|---|---|---|
character |
String |
The name of the character |
name |
String |
The name of the field to set |
value |
Any |
The value to set |
Returns
Void
JavaScript TypeScript GDScript C++ Java PHP Python Lua Haxe
getStateField
public function getStateField(name:String):Any
Gets a state field by name, resolving from the current scope outward.
| Parameter | Type | Description |
|---|---|---|
name |
String |
The name of the field to get |
Returns
Any
The field value or null if not found
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
setStateField
public function setStateField(name:String, value:Any):Void
Sets a state field by name, resolving from the current scope outward. Walks the execution stack from innermost scope to outermost to find the field, then falls back to the top-level state if not found anywhere.
| Parameter | Type | Description |
|---|---|---|
name |
String |
The name of the field to set |
value |
Any |
The value to set |
Returns
Void
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
getTopLevelStateField
public function getTopLevelStateField(name:String):Any
Gets a field from the top-level state directly.
| Parameter | Type | Description |
|---|---|---|
name |
String |
The name of the field to get |
Returns
Any
The field value or null if the field doesn't exist
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
setTopLevelStateField
public function setTopLevelStateField(name:String, value:Any):Void
Sets a field on the top-level state directly.
| Parameter | Type | Description |
|---|---|---|
name |
String |
The name of the field to set |
value |
Any |
The value to set |
Returns
Void
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
currentNode
public function currentNode():AstNode
Returns the current node being executed. During a dialogue callback, this returns the dialogue statement node. During a choice callback, this returns the choice statement node.
Returns
AstNode
The current AST node or null if no node is being executed
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
currentNodeFilePath
public function currentNodeFilePath(rootPath:String):String
Returns the file path of the file containing the current node. Uses the Lens to walk up through import statements and resolve the path relative to the given root file path.
| Parameter | Type | Description |
|---|---|---|
rootPath |
String |
The file path of the root/main script |
Returns
String
The file path of the file containing the current node, or rootPath if in the root file
JavaScript TypeScript Haxe
translations
public var translations:Null<Map<String, NStringLiteral>>
Optional translations map (localization key -> translated string literal). When set, evaluateString() substitutes tagged text with translated versions.
Returns
Null<Map<String, NStringLiteral>>
stringLiteralProcessors
public var stringLiteralProcessors:Array<(str:NStringLiteral)->NStringLiteral> = []
Pluggable processors that transform string literals before evaluation. Each processor receives an NStringLiteral and returns a (possibly transformed) NStringLiteral.
Returns
Array<(str:NStringLiteral)->NStringLiteral>
resolveBeatByName
public function resolveBeatByName(name:String, ?scopeLevel:Int = -1):Null<NBeatDecl>
Resolves a beat by name against the RUNTIME scope walk (registered nested beats first, then top-level beats). Only used as fallback for node-less contexts (function code, engine helpers); node-anchored resolution goes through resolveBeatRefFromNode (lexical).
| Parameter | Type | Description |
|---|---|---|
name |
String |
|
scopeLevel |
Int |
Returns
Null<NBeatDecl>
resolveBeatRefByName
public function resolveBeatRefByName(name:String):Null<RuntimeBeatRef>
Resolves a beat by name like resolveBeatByName, but also builds the scope chain to capture for a beat reference: the resolution path from the root up to and including the declaring scope (empty for top-level beats). Used to create RuntimeBeatRef values.
| Parameter | Type | Description |
|---|---|---|
name |
String |
Returns
Null<RuntimeBeatRef>
resolveBeatRefFromNode
public function resolveBeatRefFromNode(name:String, node:Node):Null<RuntimeBeatRef>
Resolves a beat by name from the given node's LEXICAL position, using the same resolution as the editor (Lens): innermost enclosing beat outward, order-independent, nested beats shadowing outer and top-level ones. When the resolved beat's declaring scope is live on the stack, the returned reference captures that scope chain (like beat references do), so the beat keeps its lexical context when invoked.
| Parameter | Type | Description |
|---|---|---|
name |
String |
The beat name to resolve |
node |
Node |
The node used as lexical anchor (null in node-less contexts) |
Returns
Null<RuntimeBeatRef>
Falls back to the runtime scope walk only when no node is available (function code and engine helpers).
Script
Represents the root node of a Loreline script AST.
body
public var body:Array<AstNode>
Array of top-level declarations in the script.
Returns
Array<AstNode>
JavaScript TypeScript Haxe
filePath
public var filePath:String = null
The file path this script was parsed from. May be null if the script was parsed without a file path.
Returns
String
JavaScript TypeScript Haxe
fromJson
public static function fromJson(json:Dynamic):Script
Reconstructs a Script from its JSON representation.
| Parameter | Type | Description |
|---|---|---|
json |
Dynamic |
The JSON object (as returned by script.toJson())
|
Returns
Script
The reconstructed Script
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
indentSize
public var indentSize:Int = 2
The detected indentation size of the source (e.g., 2 or 4 spaces).
Returns
Int
new
public function new(id:NodeId, pos:Position, body:Array<AstNode>)
Creates a new script root node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
The node id of this script |
pos |
Position |
Position in source where this script starts |
body |
Array<AstNode> |
Array of top-level declarations |
eachExcludingImported
public function eachExcludingImported(handleNode:(node:Node, parent:Node)->Void):Void
| Parameter | Type | Description |
|---|---|---|
handleNode |
(node:Node, parent:Node)->Void |
Returns
Void
iterator
public function iterator():ScriptBodyIterator
Returns
ScriptBodyIterator
Node
Base class for all AST nodes. Contains position information and basic JSON conversion.
id
public var id:NodeId = NodeId.UNDEFINED
A unique identifier for this node within the AST, used to distinguish it from other nodes in the script.
Returns
NodeId
JavaScript TypeScript C# Java Haxe
pos
public var pos:Position
Source code position where this node appears.
Returns
Position
JavaScript TypeScript Haxe
type
public function type():String
Returns the type of this node.
Returns
String
String representation of node type
JavaScript TypeScript C# C++ Java PHP Python Lua Haxe
toJson
public override function toJson():Dynamic
Converts the script to a JSON representation.
Returns
Dynamic
Dynamic object containing all script data
JavaScript TypeScript C# GDScript C++ Java PHP Python Lua Haxe
fromJson
public static function fromJson(json:Dynamic):Node
Reconstructs an AST Node from its JSON representation.
| Parameter | Type | Description |
|---|---|---|
json |
Dynamic |
The JSON object (as returned by node.toJson())
|
Returns
Node
The reconstructed Node
JavaScript TypeScript C# Java PHP Python Lua Haxe
each
public function each(handleNode:(node:Node, parent:Node)->Void):Void
Traverses all child nodes of this node.
| Parameter | Type | Description |
|---|---|---|
handleNode |
(node:Node, parent:Node)->Void |
Function to call for each child node |
Returns
Void
JavaScript TypeScript Haxe
new
public function new(id:NodeId, pos:Position)
Creates a new AST node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this node appears |
toJson
public function toJson():Dynamic
Converts the node to a JSON representation.
Returns
Dynamic
Dynamic object containing node type and position
InterpreterOptions
Options used to configure the Loreline interpreter behavior
functions
public var functions:FunctionsMap = null
Optional map of additional functions to make available to the script
Returns
FunctionsMap
JavaScript TypeScript C# GDScript C++ Java Haxe
strictAccess
public var strictAccess:Bool = false
Tells whether access is strict or not. If set to true, trying to read or write an undefined variable will throw an error.
Returns
Bool
JavaScript TypeScript C# GDScript C++ Java Haxe
customCreateFields
public var customCreateFields:(interpreter:Interpreter, type:String, node:Node)->Any = null
A custom instanciator to create fields objects.
Returns
(interpreter:Interpreter, type:String, node:Node)->Any
JavaScript TypeScript C# Java Haxe
translations
public var translations:Map<String, NStringLiteral> = null
Optional translations map (localization key -> translated string literal). Built from a parsed translation file using AstUtils.extractTranslations().
Returns
Map<String, NStringLiteral>
JavaScript TypeScript C# GDScript C++ Java Haxe
stringLiteralProcessors
public var stringLiteralProcessors:Array<(str:NStringLiteral)->NStringLiteral> = null
Optional custom string literal processors to add alongside the built-in plural pipe processor. Each processor receives an NStringLiteral and returns a (possibly transformed) NStringLiteral.
Returns
Array<(str:NStringLiteral)->NStringLiteral>
ChoiceOption
Represents a choice option presented to the user.
text
public var text:String
The text of the choice option.
Returns
String
JavaScript TypeScript C# C++ Java PHP Python Haxe
tags
public var tags:Array<TextTag>
Any tags associated with the choice text.
Returns
Array<TextTag>
JavaScript TypeScript C# C++ Java PHP Python Haxe
enabled
public var enabled:Bool
Whether this choice option is currently enabled.
Returns
Bool
JavaScript TypeScript C# C++ Java PHP Python Haxe
TextTag
Represents a tag in text content, which can be used for styling or other purposes.
closing
public var closing:Bool
Whether this is a closing tag.
Returns
Bool
JavaScript TypeScript C# C++ Java PHP Python Haxe
value
public var value:String
The value or name of the tag.
Returns
String
JavaScript TypeScript C# C++ Java PHP Python Haxe
offset
public var offset:Int
The offset in the text where this tag appears.
Returns
Int
JavaScript TypeScript C# C++ Java PHP Python Haxe
DialogueHandler
typedef DialogueHandler = (interpreter:Interpreter, character:String, text:String, tags:Array<TextTag>, callback:()->Void)->VoidHandler type for text output with callback. This is called when the script needs to display text to the user.
ChoiceHandler
typedef ChoiceHandler = (interpreter:Interpreter, options:Array<ChoiceOption>, callback:(index:Int)->Void)->VoidHandler type for choice presentation with callback. This is called when the script needs to present choices to the user.
FinishHandler
typedef FinishHandler = (interpreter:Interpreter)->VoidHandler type to be called when the execution finishes.
FunctionsMap
typedef FunctionsMap = Map<String, Any>Map of function names to their implementations
NodeId
abstract NodeId(Int64)Represents a unique identifier for a node within the AST. Uses a structured ID system with section, branch, block, and node components.
toString
public function toString():String
Converts the NodeId to a string representation.
Returns
String
String in the format "section.branch.block.node"
JavaScript TypeScript C# Haxe
toInt64
public inline function toInt64():Int64
Converts the NodeId to its Int64 representation.
Returns
Int64
The Int64 value of this NodeId
JavaScript TypeScript Haxe
UNDEFINED
public static final UNDEFINED:NodeId = new NodeId(0, 0, 0, 0)
Returns
NodeId
new
public function new(section:Int, branch:Int, block:Int, node:Int)
| Parameter | Type | Description |
|---|---|---|
section |
Int |
|
branch |
Int |
|
block |
Int |
|
node |
Int |
fromInt64
public static function fromInt64(value:Int64):NodeId
| Parameter | Type | Description |
|---|---|---|
value |
Int64 |
Returns
NodeId
fromString
public static function fromString(str:String):NodeId
| Parameter | Type | Description |
|---|---|---|
str |
String |
Returns
NodeId
fromTwoInt32
public static function fromTwoInt32(high:Int, low:Int):NodeId
| Parameter | Type | Description |
|---|---|---|
high |
Int |
|
low |
Int |
Returns
NodeId
section
public var section(get, set):Int
Returns
Int
branch
public var branch(get, set):Int
Returns
Int
block
public var block(get, set):Int
Returns
Int
node
public var node(get, set):Int
Returns
Int
nextSection
public function nextSection():NodeId
Returns
NodeId
nextBranch
public function nextBranch():NodeId
Returns
NodeId
nextBlock
public function nextBlock():NodeId
Returns
NodeId
nextNode
public function nextNode():NodeId
Returns
NodeId
Fields
Base interface to hold loreline values This interface allows to map loreline object fields to game-specific objects.
lorelineCreate
function lorelineCreate(interpreter:Interpreter):Void
Called when the object has been created from an interpreter
| Parameter | Type | Description |
|---|---|---|
interpreter |
Interpreter |
Returns
Void
JavaScript TypeScript C# Haxe
lorelineGet
function lorelineGet(interpreter:Interpreter, key:String):Any
Get the value associated to the given field key
| Parameter | Type | Description |
|---|---|---|
interpreter |
Interpreter |
|
key |
String |
Returns
Any
JavaScript TypeScript C# Haxe
lorelineSet
function lorelineSet(interpreter:Interpreter, key:String, value:Any):Void
Set the value associated to the given field key
| Parameter | Type | Description |
|---|---|---|
interpreter |
Interpreter |
|
key |
String |
|
value |
Any |
Returns
Void
JavaScript TypeScript C# Haxe
lorelineExists
function lorelineExists(interpreter:Interpreter, key:String):Bool
Check if a value exists for the given key
| Parameter | Type | Description |
|---|---|---|
interpreter |
Interpreter |
|
key |
String |
Returns
Bool
JavaScript TypeScript C# Haxe
lorelineFields
function lorelineFields(interpreter:Interpreter):Array<String>
Get all the fields of this object
| Parameter | Type | Description |
|---|---|---|
interpreter |
Interpreter |
Returns
Array<String>
JavaScript TypeScript C# Haxe
lorelineRemove
function lorelineRemove(interpreter:Interpreter, key:String):Bool
Remove the field associated to the given key
| Parameter | Type | Description |
|---|---|---|
interpreter |
Interpreter |
The interpreter instance |
key |
String |
The field key to remove |
Returns
Bool
True if the key was found and removed, false otherwise
C# Haxe
RuntimeState
A state during the runtime execution of a loreline script. States hold field values that can be accessed and modified during script execution.
scope
public var scope:Int = -1
If set to a value > 0, this state is temporary and linked to a scope. Every time we enter a new block node, we enter a new scope identified by a unique integer value. When exiting that scope, the related temporary states are destroyed.
Returns
Int
fields
public var fields(default, null):Any
Fields of this state. Contains the actual data being stored.
Returns
Any
originalFields
public var originalFields(default, null):Any
Original field values, as they are initially declared in the script, as long as they are not dependent on other state values. Used for comparison when serializing to avoid storing unchanged values.
Returns
Any
new
public function new(interpreter:Interpreter, node:Node, fields:Any, originalFields:Any)
Creates a new runtime state with optional initial field values.
| Parameter | Type | Description |
|---|---|---|
interpreter |
Interpreter |
|
node |
Node |
|
fields |
Any |
Initial field values, or null to create empty fields |
originalFields |
Any |
Original field values for comparison, or null to create empty original fields |
clear
public function clear(interpreter:Interpreter, node:Node):Void
Clears all fields in this state.
| Parameter | Type | Description |
|---|---|---|
interpreter |
Interpreter |
|
node |
Node |
Returns
Void
RuntimeCharacter
Runtime state variant specifically used for character states. Characters are special entities in Loreline scripts that can have their own properties and can be referenced in dialogue statements.
new
public function new(interpreter:Interpreter, node:AstNode, fields:Any, originalFields:Any)
Creates a new character runtime state with optional initial field values.
| Parameter | Type | Description |
|---|---|---|
interpreter |
Interpreter |
|
node |
AstNode |
|
fields |
Any |
|
originalFields |
Any |
RuntimeAccess
Represents different ways to access runtime values in a Loreline script. This is used internally by the interpreter to resolve variable accesses, array accesses, character references, and function calls.
FieldAccess
FieldAccess(pos:Position, obj:Any, name:String)
Represents access to a field of an object.
| Parameter | Type | Description |
|---|---|---|
pos |
Position |
Position in the source code where this access occurs |
obj |
Any |
The object being accessed |
name |
String |
The name of the field to access |
ArrayAccess
ArrayAccess(pos:Position, array:Any, index:Int)
Represents access to an array element by index.
| Parameter | Type | Description |
|---|---|---|
pos |
Position |
Position in the source code where this access occurs |
array |
Any |
The array being accessed |
index |
Int |
The index into the array |
CharacterAccess
CharacterAccess(pos:Position, name:String)
Represents access to a character by name.
| Parameter | Type | Description |
|---|---|---|
pos |
Position |
Position in the source code where this access occurs |
name |
String |
The name of the character to access |
FunctionAccess
FunctionAccess(pos:Position, name:String)
Represents access to a built-in or user-defined function.
| Parameter | Type | Description |
|---|---|---|
pos |
Position |
Position in the source code where this access occurs |
name |
String |
The name of the function to access |
BeatAccess
BeatAccess(pos:Position, ref:RuntimeBeatRef)
Represents a beat reference resolved by name.
| Parameter | Type | Description |
|---|---|---|
pos |
Position |
Position in the source code where this access occurs |
ref |
RuntimeBeatRef |
RuntimeScope
Represents a scope in the execution stack of a Loreline script. Every time we enter a new block node, we enter a new scope identified with a unique integer value. When exiting that scope, the related temporary states associated with it are destroyed.
id
public var id:Int = -1
The scope id, a unique integer value in the stack.
Returns
Int
beat
public var beat:NBeatDecl
The parent beat where this scope is located. Can be either a top level beat or a nested beat.
Returns
NBeatDecl
node
public var node:AstNode
The node where this scope is attached.
Returns
AstNode
beats
public var beats:Array<NBeatDecl> = null
The nested beat declarations, if any, found in this scope.
Returns
Array<NBeatDecl>
state
public var state:RuntimeState = null
The temporary state associated with this scope, if any.
Returns
RuntimeState
head
public var head:AstNode = null
If applicable, the node this scope's "reading head" is at. This is used to track the current execution position within the scope.
Returns
AstNode
insertion
public var insertion:RuntimeInsertion = null
If this scope was created from an insertion, this is the insertion runtime data.
Returns
RuntimeInsertion
captured
public var captured:Array<RuntimeScope> = null
If this scope runs a beat invoked through a beat reference, this is the scope chain captured when the reference was created (closure). Name resolution inside this scope walks this chain instead of the scopes below it in the stack, then jumps to top-level.
Returns
Array<RuntimeScope>
beatByName
public function beatByName(name:String):Null<NBeatDecl>
Finds a nested beat declaration with the given name in this scope, if any.
| Parameter | Type | Description |
|---|---|---|
name |
String |
The name of the beat to find |
Returns
Null<NBeatDecl>
The beat declaration if found, null otherwise
RuntimeBeatRef
A first-class beat reference: the beat plus the scope chain captured where the reference was created (from root up to and including the beat's declaring scope; empty for top-level beats). Produced whenever an expression reads an identifier that resolves to a beat.
beat
public var beat(default, null):NBeatDecl
The referenced beat declaration.
Returns
NBeatDecl
stack
public var stack(default, null):Array<RuntimeScope>
The captured scope chain (closure). Empty for top-level beats.
Returns
Array<RuntimeScope>
new
public function new(beat:NBeatDecl, stack:Array<RuntimeScope>)
| Parameter | Type | Description |
|---|---|---|
beat |
NBeatDecl |
|
stack |
Array<RuntimeScope> |
beatOf
public static function beatOf(value:Any):Null<NBeatDecl>
Returns the underlying beat if the given runtime value is a beat declaration or a beat reference, null otherwise.
| Parameter | Type | Description |
|---|---|---|
value |
Any |
Returns
Null<NBeatDecl>
beatNameOf
public static function beatNameOf(value:Any):Null<String>
Returns the name of the beat if the given runtime value is a beat declaration or a beat reference, null otherwise. Used by host bindings, where beat values cross the boundary as their name.
| Parameter | Type | Description |
|---|---|---|
value |
Any |
Returns
Null<String>
RuntimeInsertion
Fata that needs to be hold with a scope when a beat is being inserted within a choice
id
public var id:Int
The insertion id, a unique integer value among all insertions.
Returns
Int
origin
public var origin:NInsertion
The original node causing that insertion
Returns
NInsertion
options
public var options:Array<ChoiceOption> = null
The inserted choice options, or null if nothing is inserted yet
Returns
Array<ChoiceOption>
stack
public var stack:Array<RuntimeScope> = []
The call stack of this insertion, which is used to resume the execution at the correct location when a choice of it has been selected
Returns
Array<RuntimeScope>
parentPartialOptions
public var parentPartialOptions:Array<ChoiceOption> = null
Snapshot of choice options collected for the parent choice BEFORE this insertion started evaluation. Used for save/restore during Phase 1 so that Phase 1 can continue without re-running earlier insertions.
Returns
Array<ChoiceOption>
parentNextOptionIndex
public var parentNextOptionIndex:Int = 0
The next option index in the parent choice after this insertion. Used together with parentPartialOptions to continue Phase 1 from the correct position after restoring.
Returns
Int
new
public function new(id:Int, origin:NInsertion)
| Parameter | Type | Description |
|---|---|---|
id |
Int |
|
origin |
NInsertion |
RuntimeError
Runtime error that can occur during script execution.
new
public function new(message:String, ?pos:Position)
| Parameter | Type | Description |
|---|---|---|
message |
String |
|
pos |
Position |
EvalNext
Helper class for managing the next evaluation step. Used to control whether the next step should be executed synchronously or asynchronously.
sync
public var sync:Bool = true
Whether the next step should be executed synchronously.
Returns
Bool
cb
public var cb:()->Void = null
The callback to execute for the next step.
Returns
()->Void
new
public function new()
Creates a new EvalNext instance.
NodeIdStep
enum abstract NodeIdStep(Int)SECTION
SECTION = 1
Returns
NodeIdStep
BRANCH
BRANCH = 2
Returns
NodeIdStep
BLOCK
BLOCK = 3
Returns
NodeIdStep
NODE
NODE = 4
Returns
NodeIdStep
NodeIdMap
new
public inline function new()
get
public inline function get(key:NodeId):Null<V>
| Parameter | Type | Description |
|---|---|---|
key |
NodeId |
Returns
Null<V>
set
public inline function set(key:NodeId, value:V):Void
| Parameter | Type | Description |
|---|---|---|
key |
NodeId |
|
value |
V |
Returns
Void
remove
public inline function remove(key:NodeId):Void
| Parameter | Type | Description |
|---|---|---|
key |
NodeId |
Returns
Void
exists
public inline function exists(key:NodeId):Bool
| Parameter | Type | Description |
|---|---|---|
key |
NodeId |
Returns
Bool
clear
public inline function clear():Void
Returns
Void
iterator
public inline function iterator():NodeIdMapIterator<V>
Returns
NodeIdMapIterator<V>
keys
public inline function keys():NodeIdMapKeyIterator<V>
Returns
NodeIdMapKeyIterator<V>
keyValueIterator
public inline function keyValueIterator():NodeIdMapKeyValueIterator<V>
Returns
NodeIdMapKeyValueIterator<V>
NodeIdMapKeyVal
typedef NodeIdMapKeyVal<V> = { value:V, key:NodeId }Comment
Represents a comment node in the AST. Contains both the comment content and whether it's a multiline comment.
content
public var content:String
The actual text content of the comment.
Returns
String
multiline
public var multiline:Bool
Whether this is a multiline comment (/* ... */) or single-line comment (//).
Returns
Bool
isHash
public var isHash:Bool
Whether this is a hash comment (#identifier).
Returns
Bool
new
public function new(id:NodeId, pos:Position, content:String, multiline:Bool, ?isHash:Bool = false)
Creates a new Comment node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this comment appears |
content |
String |
The text content of the comment |
multiline |
Bool |
Whether this is a multiline comment |
isHash |
Bool |
Whether this is a hash comment |
toJson
public override function toJson():Dynamic
Converts the comment node to a JSON representation.
Returns
Dynamic
Dynamic object containing comment data
AstNode
Base class for AST nodes that can have associated comments. Extends Node with support for leading and trailing comments.
leadingComments
public var leadingComments:Null<Array<Comment>>
Comments that appear before this node.
Returns
Null<Array<Comment>>
trailingComments
public var trailingComments:Null<Array<Comment>>
Comments that appear after this node.
Returns
Null<Array<Comment>>
new
public function new(id:NodeId, pos:Position, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new node that supports comments.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this node appears |
leadingComments |
Array<Comment> |
Optional array of comments appearing before the node |
trailingComments |
Array<Comment> |
Optional array of comments appearing after the node |
eachComment
public function eachComment(handleComment:(node:AstNode, comment:Comment)->Void):Void
| Parameter | Type | Description |
|---|---|---|
handleComment |
(node:AstNode, comment:Comment)->Void |
Returns
Void
toJson
public override function toJson():Dynamic
Converts the node and its comments to a JSON representation.
Returns
Dynamic
Dynamic object containing node data and associated comments
NExpr
Base class for all expression nodes in the AST.
new
public function new(id:NodeId, pos:Position, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
|
leadingComments |
Array<Comment> |
|
trailingComments |
Array<Comment> |
toJson
public override function toJson():Dynamic
Converts the expression node to a JSON representation.
Returns
Dynamic
Dynamic object containing expression data
NStateDecl
Represents a state declaration node in the AST. States can be either temporary (new state) or permanent.
temporary
public var temporary:Bool
Whether this state is temporary (new state).
Returns
Bool
fields
public var fields:Array<NObjectField>
Fields defined for this state.
Returns
Array<NObjectField>
style
public var style:BlockStyle
Block style of this state
Returns
BlockStyle
new
public function new(id:NodeId, pos:Position, temporary:Bool, fields:Array<NObjectField>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new state declaration node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this state appears |
temporary |
Bool |
Whether this is a temporary state |
fields |
Array<NObjectField> |
Array of property definitions |
leadingComments |
Array<Comment> |
Optional comments before the state |
trailingComments |
Array<Comment> |
Optional comments after the state |
get
public function get(name:String):NExpr
| Parameter | Type | Description |
|---|---|---|
name |
String |
Returns
NExpr
toJson
public override function toJson():Dynamic
Converts the state declaration to a JSON representation.
Returns
Dynamic
Dynamic object containing state data
NObjectField
Represents an object field in the AST (name-value pair).
name
public var name:String
Name of the field.
Returns
String
value
public var value:NExpr
Value expression of the field.
Returns
NExpr
new
public function new(id:NodeId, pos:Position, name:String, value:NExpr, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new object field node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this field appears |
name |
String |
Name of the field |
value |
NExpr |
Value expression for the field |
leadingComments |
Array<Comment> |
Optional comments before the field |
trailingComments |
Array<Comment> |
Optional comments after the field |
toJson
public override function toJson():Dynamic
Converts the object field to a JSON representation.
Returns
Dynamic
Dynamic object containing field data
NCharacterDecl
Represents a character declaration in the AST.
name
public var name:String
Name of the character.
Returns
String
namePos
public var namePos:Position
Position of the name part.
Returns
Position
fields
public var fields:Array<NObjectField>
Fields defined for this character.
Returns
Array<NObjectField>
style
public var style:BlockStyle
Block style of this character
Returns
BlockStyle
new
public function new(id:NodeId, pos:Position, name:String, namePos:Position, fields:Array<NObjectField>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new character declaration node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this character appears |
name |
String |
Name of the character |
namePos |
Position |
|
fields |
Array<NObjectField> |
Array of property definitions |
leadingComments |
Array<Comment> |
Optional comments before the character |
trailingComments |
Array<Comment> |
Optional comments after the character |
get
public function get(name:String):NExpr
| Parameter | Type | Description |
|---|---|---|
name |
String |
Returns
NExpr
toJson
public override function toJson():Dynamic
Converts the character declaration to a JSON representation.
Returns
Dynamic
Dynamic object containing character data
NBeatParam
A single parameter in a beat declaration, e.g. name or mood = "happy" in beat Greet(name, mood = "happy").
name
public var name:String
Name of the parameter.
Returns
String
namePos
public var namePos:Position
Position of the parameter name in source.
Returns
Position
defaultValue
public var defaultValue:Null<NExpr>
Optional default value expression, evaluated when no argument is provided.
Returns
Null<NExpr>
new
public function new(name:String, namePos:Position, ?defaultValue:NExpr)
| Parameter | Type | Description |
|---|---|---|
name |
String |
|
namePos |
Position |
|
defaultValue |
NExpr |
toJson
public function toJson():Dynamic
Returns
Dynamic
NBeatDecl
Represents a beat (scene) declaration in the AST.
name
public var name:String
Name of the beat.
Returns
String
body
public var body:Array<AstNode>
Array of nodes that make up the beat's content.
Returns
Array<AstNode>
style
public var style:BlockStyle
Block style of this beat
Returns
BlockStyle
params
public var params:Null<Array<NBeatParam>> = null
Optional parameters of this beat (null when the declaration has no parens). At runtime they become beat-scoped temporary state fields.
Returns
Null<Array<NBeatParam>>
new
public function new(id:NodeId, pos:Position, name:String, body:Array<AstNode>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new beat declaration node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this beat appears |
name |
String |
Name of the beat |
body |
Array<AstNode> |
Array of nodes comprising the beat's content |
leadingComments |
Array<Comment> |
Optional comments before the beat |
trailingComments |
Array<Comment> |
Optional comments after the beat |
toJson
public override function toJson():Dynamic
Converts the beat declaration to a JSON representation.
Returns
Dynamic
Dynamic object containing beat data
StringPartType
Represents the different types of string parts that can appear in string literals.
Raw
Raw(text:String)
Raw text content.
| Parameter | Type | Description |
|---|---|---|
text |
String |
Expr
Expr(expr:NExpr)
Interpolated expression (${...} or $identifier).
| Parameter | Type | Description |
|---|---|---|
expr |
NExpr |
Tag
Tag(closing:Bool, expr:NStringLiteral)
Text formatting tag (
| Parameter | Type | Description |
|---|---|---|
closing |
Bool |
|
expr |
NStringLiteral |
BlockStyle
enum abstract BlockStyle(Int)Plain
Plain = 0
Returns
BlockStyle
Braces
Braces = 1
Returns
BlockStyle
toString
public function toString():String
Returns
String
ConditionStyle
enum abstract ConditionStyle(Int)Plain
Plain = 0
Returns
ConditionStyle
Parens
Parens = 2
Returns
ConditionStyle
toString
public function toString():String
Returns
String
AlternativeMode
enum abstract AlternativeMode(Int)Represents the mode of an alternative block.
Sequence
Sequence = 0
Returns
AlternativeMode
Cycle
Cycle = 1
Returns
AlternativeMode
Once
Once = 2
Returns
AlternativeMode
Pick
Pick = 3
Returns
AlternativeMode
Shuffle
Shuffle = 4
Returns
AlternativeMode
toString
public function toString():String
Returns
String
NStringPart
Represents a string part that can appear in string literals.
partType
public var partType:StringPartType
The type of string part
Returns
StringPartType
new
public function new(id:NodeId, pos:Position, partType:StringPartType, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new string part node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this string part appears |
partType |
StringPartType |
|
leadingComments |
Array<Comment> |
Optional comments before the string |
trailingComments |
Array<Comment> |
Optional comments after the string |
toJson
public override function toJson():Dynamic
Converts the string part to a JSON representation.
Returns
Dynamic
Dynamic object containing string part data
NStringLiteral
Represents a string literal in the AST, supporting interpolation and tags.
parts
public var parts:Array<NStringPart>
Array of parts that make up this string literal.
Returns
Array<NStringPart>
quotes
public var quotes:Quotes
The type of quotes used for this string literal
Returns
Quotes
new
public function new(id:NodeId, pos:Position, quotes:Quotes, parts:Array<NStringPart>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new string literal node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this string appears |
quotes |
Quotes |
|
parts |
Array<NStringPart> |
Array of string parts (raw text, interpolations, and tags) |
leadingComments |
Array<Comment> |
Optional comments before the string |
trailingComments |
Array<Comment> |
Optional comments after the string |
toJson
public override function toJson():Dynamic
Converts the string literal to a JSON representation.
Returns
Dynamic
Dynamic object containing string data and its parts
NTextStatement
Represents a text statement in the AST.
content
public var content:NStringLiteral
The content of the text statement.
Returns
NStringLiteral
condition
public var condition:Null<NExpr>
Optional condition that must be true for this text to be displayed.
Returns
Null<NExpr>
conditionStyle
public var conditionStyle:ConditionStyle
The style of the condition (plain or parentheses).
Returns
ConditionStyle
conditionPos
public var conditionPos:Null<Position>
Position of the trailing "if condition" clause (from 'if' keyword through condition end).
Returns
Null<Position>
new
public function new(id:NodeId, pos:Position, content:NStringLiteral, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new text statement node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this text appears |
content |
NStringLiteral |
String literal containing the text content |
leadingComments |
Array<Comment> |
Optional comments before the text |
trailingComments |
Array<Comment> |
Optional comments after the text |
toJson
public override function toJson():Dynamic
Converts the text statement to a JSON representation.
Returns
Dynamic
Dynamic object containing text data
NDialogueStatement
Represents a dialogue statement in the AST (character: "text").
character
public var character:String
Name of the speaking character.
Returns
String
characterPos
public var characterPos:Position
Position of the character label
Returns
Position
content
public var content:NStringLiteral
Content of the dialogue.
Returns
NStringLiteral
condition
public var condition:Null<NExpr>
Optional condition that must be true for this dialogue to be displayed.
Returns
Null<NExpr>
conditionStyle
public var conditionStyle:ConditionStyle
The style of the condition (plain or parentheses).
Returns
ConditionStyle
conditionPos
public var conditionPos:Null<Position>
Position of the trailing "if condition" clause (from 'if' keyword through condition end).
Returns
Null<Position>
new
public function new(id:NodeId, pos:Position, character:String, characterPos:Position, content:NStringLiteral, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new dialogue statement node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this dialogue appears |
character |
String |
Name of the speaking character |
characterPos |
Position |
Position of the character label |
content |
NStringLiteral |
String literal containing the dialogue text |
leadingComments |
Array<Comment> |
Optional comments before the dialogue |
trailingComments |
Array<Comment> |
Optional comments after the dialogue |
toJson
public override function toJson():Dynamic
Converts the dialogue statement to a JSON representation.
Returns
Dynamic
Dynamic object containing dialogue data
NChoiceStatement
Represents a choice statement in the AST.
options
public var options:Array<NChoiceOption>
Array of available options in this choice.
Returns
Array<NChoiceOption>
style
public var style:BlockStyle
The block style of the choice statement
Returns
BlockStyle
new
public function new(id:NodeId, pos:Position, options:Array<NChoiceOption>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new choice statement node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this choice appears |
options |
Array<NChoiceOption> |
Array of available choice options |
leadingComments |
Array<Comment> |
Optional comments before the choice |
trailingComments |
Array<Comment> |
Optional comments after the choice |
toJson
public override function toJson():Dynamic
Converts the choice statement to a JSON representation.
Returns
Dynamic
Dynamic object containing choice data
NChoiceOption
Represents a single option within a choice statement.
text
public var text:NStringLiteral
The text displayed for this option.
Returns
NStringLiteral
insertion
public var insertion:NInsertion
Alternatively, instead of text, this could be an insertion
Returns
NInsertion
condition
public var condition:Null<NExpr>
Optional condition that must be true for this option to be available.
Returns
Null<NExpr>
conditionStyle
public var conditionStyle:ConditionStyle
The style of the condition (plain or parentheses).
Returns
ConditionStyle
conditionPos
public var conditionPos:Null<Position>
Position of the trailing "if condition" clause (from 'if' keyword through condition end).
Returns
Null<Position>
body
public var body:Array<AstNode>
Array of nodes to execute when this option is chosen.
Returns
Array<AstNode>
style
public var style:BlockStyle
The block style of the body
Returns
BlockStyle
once
public var once:Bool
Whether this option can only be chosen once (disappears after being selected).
Returns
Bool
new
public function new(id:NodeId, pos:Position, text:NStringLiteral, insertion:NInsertion, condition:Null<NExpr>, conditionStyle:ConditionStyle, body:Array<AstNode>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new choice option node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this option appears |
text |
NStringLiteral |
String literal containing the option text |
insertion |
NInsertion |
|
condition |
Null<NExpr> |
Optional condition for option availability |
conditionStyle |
ConditionStyle |
The style of the condition (plain or parentheses) |
body |
Array<AstNode> |
Array of nodes to execute when chosen |
leadingComments |
Array<Comment> |
Optional comments before the option |
trailingComments |
Array<Comment> |
Optional comments after the option |
toJson
public override function toJson():Dynamic
Converts the choice option to a JSON representation.
Returns
Dynamic
Dynamic object containing option data
NBlock
Represents a block with a sequence multiple nodes
body
public var body:Array<AstNode>
Array of nodes that make up the beat's content.
Returns
Array<AstNode>
style
public var style:BlockStyle
The block style of the body.
Returns
BlockStyle
new
public function new(id:NodeId, pos:Position, body:Array<AstNode>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new block node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this beat appears |
body |
Array<AstNode> |
Array of nodes comprising the block's content |
leadingComments |
Array<Comment> |
Optional comments before the beat |
trailingComments |
Array<Comment> |
Optional comments after the beat |
toJson
public override function toJson():Dynamic
Converts the beat declaration to a JSON representation.
Returns
Dynamic
Dynamic object containing beat data
NIfStatement
Represents an if statement in the AST, with optional else branch.
condition
public var condition:NExpr
The condition to evaluate.
Returns
NExpr
conditionStyle
public var conditionStyle:ConditionStyle
The style of the condition (plain or parentheses).
Returns
ConditionStyle
thenBranch
public var thenBranch:NBlock
Array of nodes to execute if condition is true.
Returns
NBlock
elseBranch
public var elseBranch:Null<NBlock>
Optional array of nodes to execute if condition is false.
Returns
Null<NBlock>
elseLeadingComments
public var elseLeadingComments:Null<Array<Comment>>
Comments that appear before the else keyword.
Returns
Null<Array<Comment>>
elseTrailingComments
public var elseTrailingComments:Null<Array<Comment>>
Comments that appear after the else keyword.
Returns
Null<Array<Comment>>
new
public function new(id:NodeId, pos:Position, condition:NExpr, conditionStyle:ConditionStyle, thenBranch:NBlock, elseBranch:Null<NBlock>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>, ?elseLeadingComments:Array<Comment>, ?elseTrailingComments:Array<Comment>)
Creates a new if statement node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this if statement appears |
condition |
NExpr |
Expression to evaluate |
conditionStyle |
ConditionStyle |
The style of the condition (plain or parentheses) |
thenBranch |
NBlock |
Nodes to execute if condition is true |
elseBranch |
Null<NBlock> |
Optional nodes to execute if condition is false |
leadingComments |
Array<Comment> |
Optional comments before the if |
trailingComments |
Array<Comment> |
Optional comments after the if |
elseLeadingComments |
Array<Comment> |
Optional comments before the else |
elseTrailingComments |
Array<Comment> |
Optional comments after the else |
toJson
public override function toJson():Dynamic
Converts the if statement to a JSON representation.
Returns
Dynamic
Dynamic object containing if statement data
NAlternative
Represents an alternative block (sequence, cycle, once, pick, shuffle).
mode
public var mode:AlternativeMode
The alternative mode (sequence, cycle, once, pick, shuffle).
Returns
AlternativeMode
items
public var items:Array<NBlock>
Array of item blocks. Each item is a block of statements.
Returns
Array<NBlock>
style
public var style:BlockStyle
The block style (indented or braces).
Returns
BlockStyle
separatorComments
public var separatorComments:Null<Array<Array<Comment>>>
Comments that appear before separator tokens.
Returns
Null<Array<Array<Comment>>>
new
public function new(id:NodeId, pos:Position, mode:AlternativeMode, items:Array<NBlock>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new alternative block node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
The node ID |
pos |
Position |
Position in source where this alternative appears |
mode |
AlternativeMode |
The alternative mode |
items |
Array<NBlock> |
Array of item blocks |
leadingComments |
Array<Comment> |
Optional comments before the alternative |
trailingComments |
Array<Comment> |
Optional comments after the alternative |
toJson
public override function toJson():Dynamic
Converts the alternative block to a JSON representation.
Returns
Dynamic
Dynamic object containing alternative data
NCall
Represents a function call expression in the AST.
target
public var target:NExpr
The expression being called.
Returns
NExpr
args
public var args:Array<NExpr>
Array of argument expressions passed to the call.
Returns
Array<NExpr>
new
public function new(id:NodeId, pos:Position, target:NExpr, args:Array<NExpr>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new call expression node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this call appears |
target |
NExpr |
Expression being called |
args |
Array<NExpr> |
Array of argument expressions |
leadingComments |
Array<Comment> |
Optional comments before the call |
trailingComments |
Array<Comment> |
Optional comments after the call |
toJson
public override function toJson():Dynamic
Converts the call expression to a JSON representation.
Returns
Dynamic
Dynamic object containing call data
NTransition
Represents a transition to another beat (->).
target
public var target:String
Name of the target beat (null when the target is dynamic, see targetExpr).
Returns
String
targetPos
public var targetPos:Position
Position of the target part of the transition
Returns
Position
targetExpr
public var targetExpr:Null<NExpr> = null
Dynamic target expression, from the -> beat(expr) form. When set, target is null and the expression is resolved at runtime.
Returns
Null<NExpr>
args
public var args:Null<Array<NExpr>> = null
Optional arguments passed to the target beat, from -> SomeBeat(args...) or -> beat(expr, args...).
Returns
Null<Array<NExpr>>
new
public function new(id:NodeId, pos:Position, target:String, targetPos:Position, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new transition node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this transition appears |
target |
String |
Name of the target beat |
targetPos |
Position |
Position of the target part of the transition |
leadingComments |
Array<Comment> |
Optional comments before the transition |
trailingComments |
Array<Comment> |
Optional comments after the transition |
toJson
public override function toJson():Dynamic
Converts the transition to a JSON representation.
Returns
Dynamic
Dynamic object containing transition data
NInsertion
Represents an insertion of another beat (+).
target
public var target:String
Name of the target beat (null when the target is dynamic, see targetExpr).
Returns
String
targetPos
public var targetPos:Position
Position of the target part of the insertion
Returns
Position
targetExpr
public var targetExpr:Null<NExpr> = null
Dynamic target expression, from the + beat(expr) form. When set, target is null and the expression is resolved at runtime.
Returns
Null<NExpr>
args
public var args:Null<Array<NExpr>> = null
Optional arguments passed to the target beat, from + SomeBeat(args...) or + beat(expr, args...).
Returns
Null<Array<NExpr>>
new
public function new(id:NodeId, pos:Position, target:String, targetPos:Position, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new insertion node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this insertion appears |
target |
String |
Name of the target beat |
targetPos |
Position |
Position of the target part of the insertion |
leadingComments |
Array<Comment> |
Optional comments before the insertion |
trailingComments |
Array<Comment> |
Optional comments after the insertion |
toJson
public override function toJson():Dynamic
Converts the insertion to a JSON representation.
Returns
Dynamic
Dynamic object containing insertion data
NBeatCall
Represents a dynamic beat call statement: beat(expr, args...). Runs the resolved beat as a stack-preserving call (like a static SomeBeat(args...) call), with the target resolved at runtime.
targetExpr
public var targetExpr:NExpr
Target expression, resolved at runtime to a beat (a string name, a beat value or a beat reference).
Returns
NExpr
targetPos
public var targetPos:Position
Position of the beat(...) target part.
Returns
Position
args
public var args:Null<Array<NExpr>> = null
Optional arguments passed to the target beat.
Returns
Null<Array<NExpr>>
new
public function new(id:NodeId, pos:Position, targetExpr:NExpr, targetPos:Position, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new dynamic beat call node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this call appears |
targetExpr |
NExpr |
Expression resolving to the target beat |
targetPos |
Position |
Position of the target part |
leadingComments |
Array<Comment> |
Optional comments before the call |
trailingComments |
Array<Comment> |
Optional comments after the call |
toJson
public override function toJson():Dynamic
Converts the beat call to a JSON representation.
Returns
Dynamic
Dynamic object containing beat call data
NFunctionDecl
Represents a callable function in the AST
name
public var name:Null<String>
The function name (if any)
Returns
Null<String>
args
public var args:Array<String>
Argument names
Returns
Array<String>
code
public var code:String
The actual code of the function (including the signature)
Returns
String
external
public var external:Bool
Whether this is an external function (so this is only a declaration without implementation)
Returns
Bool
new
public function new(id:NodeId, pos:Position, name:Null<String>, args:Array<String>, code:String, external:Bool, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new function node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this function appears |
name |
Null<String> |
The function name (if any) |
args |
Array<String> |
Argument names |
code |
String |
The actual code of the function (including the signature) |
external |
Bool |
Whether this is an external function (so this is only a declaration without implementation) |
leadingComments |
Array<Comment> |
Optional comments before the function |
trailingComments |
Array<Comment> |
Optional comments after the function |
toJson
public override function toJson():Dynamic
Converts the literal to a JSON representation.
Returns
Dynamic
Dynamic object containing literal data
NLiteral
Represents literal values in the AST (numbers, booleans, arrays, objects).
value
public var value:Any
The literal value.
Returns
Any
literalType
public var literalType:LiteralType
Type of the literal value.
Returns
LiteralType
new
public function new(id:NodeId, pos:Position, value:Any, literalType:LiteralType, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new literal node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this literal appears |
value |
Any |
The literal value |
literalType |
LiteralType |
|
leadingComments |
Array<Comment> |
Optional comments before the literal |
trailingComments |
Array<Comment> |
Optional comments after the literal |
toJson
public override function toJson():Dynamic
Converts the literal to a JSON representation.
Returns
Dynamic
Dynamic object containing literal data
LiteralType
Possible types for literal values.
Number
Number
Numeric literal
Boolean
Boolean
Boolean literal
Null
Null
Null literal
Array
Array
Array literal
Object
Object(style:BlockStyle)
Object literal
| Parameter | Type | Description |
|---|---|---|
style |
BlockStyle |
NAccess
Represents a field access expression (obj.field).
target
public var target:Null<NExpr>
Optional target object being accessed.
Returns
Null<NExpr>
name
public var name:String
Name of the accessed field.
Returns
String
new
public function new(id:NodeId, pos:Position, target:Null<NExpr>, name:String, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new field access node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this access appears |
target |
Null<NExpr> |
Optional target object expression |
name |
String |
Name of the accessed field |
leadingComments |
Array<Comment> |
Optional comments before the access |
trailingComments |
Array<Comment> |
Optional comments after the access |
toJson
public override function toJson():Dynamic
Converts the field access to a JSON representation.
Returns
Dynamic
Dynamic object containing access data
NAssign
Represents an assignment expression (a = b, a += b, etc).
target
public var target:NExpr
Target expression being assigned to.
Returns
NExpr
op
public var op:TokenType
Assignment operator type.
Returns
TokenType
value
public var value:NExpr
Value being assigned.
Returns
NExpr
new
public function new(id:NodeId, pos:Position, target:NExpr, op:TokenType, value:NExpr, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new assignment node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this assignment appears |
target |
NExpr |
Target expression being assigned to |
op |
TokenType |
Assignment operator type |
value |
NExpr |
Value being assigned |
leadingComments |
Array<Comment> |
Optional comments before the assignment |
trailingComments |
Array<Comment> |
Optional comments after the assignment |
toJson
public override function toJson():Dynamic
Converts the assignment to a JSON representation.
Returns
Dynamic
Dynamic object containing assignment data
NArrayAccess
Represents an array access expression (array[index]).
target
public var target:NExpr
Target array being accessed.
Returns
NExpr
index
public var index:NExpr
Index expression.
Returns
NExpr
new
public function new(id:NodeId, pos:Position, target:NExpr, index:NExpr, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new array access node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this access appears |
target |
NExpr |
Target array expression |
index |
NExpr |
Index expression |
leadingComments |
Array<Comment> |
Optional comments before the access |
trailingComments |
Array<Comment> |
Optional comments after the access |
toJson
public override function toJson():Dynamic
Converts the array access to a JSON representation.
Returns
Dynamic
Dynamic object containing array access data
NBinary
Represents a binary operation expression (a + b, a && b, etc).
left
public var left:NExpr
Left operand expression.
Returns
NExpr
op
public var op:TokenType
Operator type.
Returns
TokenType
right
public var right:NExpr
Right operand expression.
Returns
NExpr
new
public function new(id:NodeId, pos:Position, left:NExpr, op:TokenType, right:NExpr, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new binary operation node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this operation appears |
left |
NExpr |
Left operand expression |
op |
TokenType |
Binary operator type |
right |
NExpr |
Right operand expression |
leadingComments |
Array<Comment> |
Optional comments before the operation |
trailingComments |
Array<Comment> |
Optional comments after the operation |
toJson
public override function toJson():Dynamic
Converts the binary operation to a JSON representation.
Returns
Dynamic
Dynamic object containing operation data
NUnary
Represents a unary operation expression (!x, -x, etc).
op
public var op:TokenType
Operator type.
Returns
TokenType
operand
public var operand:NExpr
Operand expression.
Returns
NExpr
new
public function new(id:NodeId, pos:Position, op:TokenType, operand:NExpr, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new unary operation node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this operation appears |
op |
TokenType |
Unary operator type |
operand |
NExpr |
Operand expression |
leadingComments |
Array<Comment> |
Optional comments before |
trailingComments |
Array<Comment> |
Optional comments after the operation |
toJson
public override function toJson():Dynamic
Converts the unary operation to a JSON representation.
Returns
Dynamic
Dynamic object containing operation data
NTernary
Represents a ternary conditional expression (condition ? trueExpr : falseExpr).
condition
public var condition:NExpr
The condition expression.
Returns
NExpr
trueExpr
public var trueExpr:NExpr
The expression to evaluate if the condition is true.
Returns
NExpr
falseExpr
public var falseExpr:NExpr
The expression to evaluate if the condition is false.
Returns
NExpr
new
public function new(id:NodeId, pos:Position, condition:NExpr, trueExpr:NExpr, falseExpr:NExpr, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new ternary expression node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
Node id |
pos |
Position |
Position in source where this expression appears |
condition |
NExpr |
The condition expression |
trueExpr |
NExpr |
Expression evaluated when condition is true |
falseExpr |
NExpr |
Expression evaluated when condition is false |
leadingComments |
Array<Comment> |
Optional comments before |
trailingComments |
Array<Comment> |
Optional comments after the expression |
toJson
public override function toJson():Dynamic
Converts the ternary expression to a JSON representation.
Returns
Dynamic
Dynamic object containing ternary data
NImportStatement
Represents an import statement
path
public var path:NStringLiteral
The relative path of the file to import
Returns
NStringLiteral
script
public var script:Script
The imported AST
Returns
Script
new
public function new(id:NodeId, pos:Position, path:NStringLiteral, script:Script, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
Creates a new import statement node.
| Parameter | Type | Description |
|---|---|---|
id |
NodeId |
|
pos |
Position |
Position in source where this import appears |
path |
NStringLiteral |
The relative path of the file to import |
script |
Script |
The imported AST |
leadingComments |
Array<Comment> |
Optional comments before |
trailingComments |
Array<Comment> |
Optional comments after the operation |
Generated from Loreline v0.10.0.