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

TypeMembers
Loreline parse play resume extractTranslations loadLocale translationFormat lastError print update generateTranslationFile insertLocalizationKeys collectHashIds removeLocalizationKeys extractTranslatableEntries hasUntaggedTranslatableStrings
Interpreter new start save restore resume getCharacter getCharacterField setCharacterField getStateField setStateField getTopLevelStateField setTopLevelStateField currentNode currentNodeFilePath translations stringLiteralProcessors resolveBeatByName resolveBeatRefByName resolveBeatRefFromNode
Script body filePath fromJson indentSize new eachExcludingImported iterator
Node id pos type toJson fromJson each new toJson
InterpreterOptions functions strictAccess customCreateFields translations stringLiteralProcessors
ChoiceOption text tags enabled
TextTag closing value offset
DialogueHandler
ChoiceHandler
FinishHandler
FunctionsMap
NodeId toString toInt64 UNDEFINED new fromInt64 fromString fromTwoInt32 section branch block node nextSection nextBranch nextBlock nextNode
Fields lorelineCreate lorelineGet lorelineSet lorelineExists lorelineFields lorelineRemove
RuntimeState scope fields originalFields new clear
RuntimeCharacter new
RuntimeAccess FieldAccess ArrayAccess CharacterAccess FunctionAccess BeatAccess
RuntimeScope id beat node beats state head insertion captured beatByName
RuntimeBeatRef beat stack new beatOf beatNameOf
RuntimeInsertion id origin options stack parentPartialOptions parentNextOptionIndex new
RuntimeError new
EvalNext sync cb new
NodeIdStep SECTION BRANCH BLOCK NODE
NodeIdMap new get set remove exists clear iterator keys keyValueIterator
NodeIdMapKeyVal
Comment content multiline isHash new toJson
AstNode leadingComments trailingComments new eachComment toJson
NExpr new toJson
NStateDecl temporary fields style new get toJson
NObjectField name value new toJson
NCharacterDecl name namePos fields style new get toJson
NBeatParam name namePos defaultValue new toJson
NBeatDecl name body style params new toJson
StringPartType Raw Expr Tag
BlockStyle Plain Braces toString
ConditionStyle Plain Parens toString
AlternativeMode Sequence Cycle Once Pick Shuffle toString
NStringPart partType new toJson
NStringLiteral parts quotes new toJson
NTextStatement content condition conditionStyle conditionPos new toJson
NDialogueStatement character characterPos content condition conditionStyle conditionPos new toJson
NChoiceStatement options style new toJson
NChoiceOption text insertion condition conditionStyle conditionPos body style once new toJson
NBlock body style new toJson
NIfStatement condition conditionStyle thenBranch elseBranch elseLeadingComments elseTrailingComments new toJson
NAlternative mode items style separatorComments new toJson
NCall target args new toJson
NTransition target targetPos targetExpr args new toJson
NInsertion target targetPos targetExpr args new toJson
NBeatCall targetExpr targetPos args new toJson
NFunctionDecl name args code external new toJson
NLiteral value literalType new toJson
LiteralType Number Boolean Null Array Object
NAccess target name new toJson
NAssign target op value new toJson
NArrayAccess target index new toJson
NBinary left op right new toJson
NUnary op operand new toJson
NTernary condition trueExpr falseExpr new toJson
NImportStatement path script new

Loreline

class

The main public API for Loreline runtime. Provides easy access to the core functionality for parsing and running Loreline scripts.

parse

method

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.

ParameterTypeDescription
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

method

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.

ParameterTypeDescription
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

method

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.

ParameterTypeDescription
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

method

public static function extractTranslations(script:Script):Map<String, NStringLiteral>

Extracts translations from a parsed translation script.

ParameterTypeDescription
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

method

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.

ParameterTypeDescription
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

method

public static function translationFormat(name:String, enabled:Bool):Void

Enable or disable runtime support for an alternate translation file format.

ParameterTypeDescription
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

method

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

method

public static function print(script:Script, ?indent:String, ?newline:String):String

Prints a parsed script back into Loreline source code.

ParameterTypeDescription
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

method

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).

ParameterTypeDescription
delta Float Time elapsed since last frame in seconds

Returns Void

C# C++ Java PHP Python Lua Haxe

generateTranslationFile

method

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.

ParameterTypeDescription
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

method

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.

ParameterTypeDescription
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

method

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.

ParameterTypeDescription
content String
out Map<String, Bool>

Returns Map<String, Bool>

Fills and returns out (or a fresh map when out is null).

removeLocalizationKeys

method

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.

ParameterTypeDescription
content String
script Script

Returns String

extractTranslatableEntries

method

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.

ParameterTypeDescription
script Script

Returns Array<{ str:NStringLiteral, id:String }>

hasUntaggedTranslatableStrings

method

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.

ParameterTypeDescription
script Script

Returns Bool

Interpreter

class

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

constructor

public function new(script:Script, handleDialogue:DialogueHandler, handleChoice:ChoiceHandler, handleFinish:FinishHandler, ?options:InterpreterOptions)

Creates a new Loreline script interpreter.

ParameterTypeDescription
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

method

public function start(?beatName:String):Void

Starts script execution from the beginning or a specific beat.

ParameterTypeDescription
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

method

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

method

public function restore(saveData:SaveData):Void

Restores the interpreter state from a SaveData object. This allows resuming execution from a previously saved state.

ParameterTypeDescription
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

method

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

method

public function getCharacter(name:String):Any

Gets a character by name.

ParameterTypeDescription
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

method

public function getCharacterField(character:String, name:String):Any

Gets a specific field of a character.

ParameterTypeDescription
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

method

public function setCharacterField(character:String, name:String, value:Any):Void

Sets a specific field on a character.

ParameterTypeDescription
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

method

public function getStateField(name:String):Any

Gets a state field by name, resolving from the current scope outward.

ParameterTypeDescription
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

method

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.

ParameterTypeDescription
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

method

public function getTopLevelStateField(name:String):Any

Gets a field from the top-level state directly.

ParameterTypeDescription
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

method

public function setTopLevelStateField(name:String, value:Any):Void

Sets a field on the top-level state directly.

ParameterTypeDescription
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

method

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

method

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.

ParameterTypeDescription
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

property

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

property

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

method

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).

ParameterTypeDescription
name String
scopeLevel Int

Returns Null<NBeatDecl>

resolveBeatRefByName

method

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.

ParameterTypeDescription
name String

Returns Null<RuntimeBeatRef>

resolveBeatRefFromNode

method

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.

ParameterTypeDescription
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

class

Represents the root node of a Loreline script AST.

body

property

public var body:Array<AstNode>

Array of top-level declarations in the script.

Returns Array<AstNode>

JavaScript TypeScript Haxe

filePath

property

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

method

public static function fromJson(json:Dynamic):Script

Reconstructs a Script from its JSON representation.

ParameterTypeDescription
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

property

public var indentSize:Int = 2

The detected indentation size of the source (e.g., 2 or 4 spaces).

Returns Int

new

constructor

public function new(id:NodeId, pos:Position, body:Array<AstNode>)

Creates a new script root node.

ParameterTypeDescription
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

method

public function eachExcludingImported(handleNode:(node:Node, parent:Node)->Void):Void
ParameterTypeDescription
handleNode (node:Node, parent:Node)->Void

Returns Void

iterator

method

public function iterator():ScriptBodyIterator

Returns ScriptBodyIterator

Node

class

Base class for all AST nodes. Contains position information and basic JSON conversion.

id

property

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

property

public var pos:Position

Source code position where this node appears.

Returns Position

JavaScript TypeScript Haxe

type

method

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

method

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

method

public static function fromJson(json:Dynamic):Node

Reconstructs an AST Node from its JSON representation.

ParameterTypeDescription
json Dynamic The JSON object (as returned by node.toJson())

Returns Node The reconstructed Node

JavaScript TypeScript C# Java PHP Python Lua Haxe

each

method

public function each(handleNode:(node:Node, parent:Node)->Void):Void

Traverses all child nodes of this node.

ParameterTypeDescription
handleNode (node:Node, parent:Node)->Void Function to call for each child node

Returns Void

JavaScript TypeScript Haxe

new

constructor

public function new(id:NodeId, pos:Position)

Creates a new AST node.

ParameterTypeDescription
id NodeId
pos Position Position in source where this node appears

toJson

method

public function toJson():Dynamic

Converts the node to a JSON representation.

Returns Dynamic Dynamic object containing node type and position

InterpreterOptions

class

Options used to configure the Loreline interpreter behavior

functions

property

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

property

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

property

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

property

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

property

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

class

Represents a choice option presented to the user.

text

property

public var text:String

The text of the choice option.

Returns String

JavaScript TypeScript C# C++ Java PHP Python Haxe

tags

property

public var tags:Array<TextTag>

Any tags associated with the choice text.

Returns Array<TextTag>

JavaScript TypeScript C# C++ Java PHP Python Haxe

enabled

property

public var enabled:Bool

Whether this choice option is currently enabled.

Returns Bool

JavaScript TypeScript C# C++ Java PHP Python Haxe

TextTag

class

Represents a tag in text content, which can be used for styling or other purposes.

closing

property

public var closing:Bool

Whether this is a closing tag.

Returns Bool

JavaScript TypeScript C# C++ Java PHP Python Haxe

value

property

public var value:String

The value or name of the tag.

Returns String

JavaScript TypeScript C# C++ Java PHP Python Haxe

offset

property

public var offset:Int

The offset in the text where this tag appears.

Returns Int

JavaScript TypeScript C# C++ Java PHP Python Haxe

DialogueHandler

type alias

typedef DialogueHandler = (interpreter:Interpreter, character:String, text:String, tags:Array<TextTag>, callback:()->Void)->Void

Handler type for text output with callback. This is called when the script needs to display text to the user.

ChoiceHandler

type alias

typedef ChoiceHandler = (interpreter:Interpreter, options:Array<ChoiceOption>, callback:(index:Int)->Void)->Void

Handler type for choice presentation with callback. This is called when the script needs to present choices to the user.

FinishHandler

type alias

typedef FinishHandler = (interpreter:Interpreter)->Void

Handler type to be called when the execution finishes.

FunctionsMap

type alias

typedef FunctionsMap = Map<String, Any>

Map of function names to their implementations

NodeId

class

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

method

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

method

public inline function toInt64():Int64

Converts the NodeId to its Int64 representation.

Returns Int64 The Int64 value of this NodeId

JavaScript TypeScript Haxe

UNDEFINED

property

public static final UNDEFINED:NodeId = new NodeId(0, 0, 0, 0)

Returns NodeId

new

constructor

public function new(section:Int, branch:Int, block:Int, node:Int)
ParameterTypeDescription
section Int
branch Int
block Int
node Int

fromInt64

method

public static function fromInt64(value:Int64):NodeId
ParameterTypeDescription
value Int64

Returns NodeId

fromString

method

public static function fromString(str:String):NodeId
ParameterTypeDescription
str String

Returns NodeId

fromTwoInt32

method

public static function fromTwoInt32(high:Int, low:Int):NodeId
ParameterTypeDescription
high Int
low Int

Returns NodeId

section

property

public var section(get, set):Int

Returns Int

branch

property

public var branch(get, set):Int

Returns Int

block

property

public var block(get, set):Int

Returns Int

node

property

public var node(get, set):Int

Returns Int

nextSection

method

public function nextSection():NodeId

Returns NodeId

nextBranch

method

public function nextBranch():NodeId

Returns NodeId

nextBlock

method

public function nextBlock():NodeId

Returns NodeId

nextNode

method

public function nextNode():NodeId

Returns NodeId

Fields

interface

Base interface to hold loreline values This interface allows to map loreline object fields to game-specific objects.

lorelineCreate

method

function lorelineCreate(interpreter:Interpreter):Void

Called when the object has been created from an interpreter

ParameterTypeDescription
interpreter Interpreter

Returns Void

JavaScript TypeScript C# Haxe

lorelineGet

method

function lorelineGet(interpreter:Interpreter, key:String):Any

Get the value associated to the given field key

ParameterTypeDescription
interpreter Interpreter
key String

Returns Any

JavaScript TypeScript C# Haxe

lorelineSet

method

function lorelineSet(interpreter:Interpreter, key:String, value:Any):Void

Set the value associated to the given field key

ParameterTypeDescription
interpreter Interpreter
key String
value Any

Returns Void

JavaScript TypeScript C# Haxe

lorelineExists

method

function lorelineExists(interpreter:Interpreter, key:String):Bool

Check if a value exists for the given key

ParameterTypeDescription
interpreter Interpreter
key String

Returns Bool

JavaScript TypeScript C# Haxe

lorelineFields

method

function lorelineFields(interpreter:Interpreter):Array<String>

Get all the fields of this object

ParameterTypeDescription
interpreter Interpreter

Returns Array<String>

JavaScript TypeScript C# Haxe

lorelineRemove

method

function lorelineRemove(interpreter:Interpreter, key:String):Bool

Remove the field associated to the given key

ParameterTypeDescription
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

class

A state during the runtime execution of a loreline script. States hold field values that can be accessed and modified during script execution.

scope

property

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

property

public var fields(default, null):Any

Fields of this state. Contains the actual data being stored.

Returns Any

originalFields

property

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

constructor

public function new(interpreter:Interpreter, node:Node, fields:Any, originalFields:Any)

Creates a new runtime state with optional initial field values.

ParameterTypeDescription
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

method

public function clear(interpreter:Interpreter, node:Node):Void

Clears all fields in this state.

ParameterTypeDescription
interpreter Interpreter
node Node

Returns Void

RuntimeCharacter

class

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

constructor

public function new(interpreter:Interpreter, node:AstNode, fields:Any, originalFields:Any)

Creates a new character runtime state with optional initial field values.

ParameterTypeDescription
interpreter Interpreter
node AstNode
fields Any
originalFields Any

RuntimeAccess

enum

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

constant

FieldAccess(pos:Position, obj:Any, name:String)

Represents access to a field of an object.

ParameterTypeDescription
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

constant

ArrayAccess(pos:Position, array:Any, index:Int)

Represents access to an array element by index.

ParameterTypeDescription
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

constant

CharacterAccess(pos:Position, name:String)

Represents access to a character by name.

ParameterTypeDescription
pos Position Position in the source code where this access occurs
name String The name of the character to access

FunctionAccess

constant

FunctionAccess(pos:Position, name:String)

Represents access to a built-in or user-defined function.

ParameterTypeDescription
pos Position Position in the source code where this access occurs
name String The name of the function to access

BeatAccess

constant

BeatAccess(pos:Position, ref:RuntimeBeatRef)

Represents a beat reference resolved by name.

ParameterTypeDescription
pos Position Position in the source code where this access occurs
ref RuntimeBeatRef

RuntimeScope

class

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

property

public var id:Int = -1

The scope id, a unique integer value in the stack.

Returns Int

beat

property

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

property

public var node:AstNode

The node where this scope is attached.

Returns AstNode

beats

property

public var beats:Array<NBeatDecl> = null

The nested beat declarations, if any, found in this scope.

Returns Array<NBeatDecl>

state

property

public var state:RuntimeState = null

The temporary state associated with this scope, if any.

Returns RuntimeState

head

property

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

property

public var insertion:RuntimeInsertion = null

If this scope was created from an insertion, this is the insertion runtime data.

Returns RuntimeInsertion

captured

property

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

method

public function beatByName(name:String):Null<NBeatDecl>

Finds a nested beat declaration with the given name in this scope, if any.

ParameterTypeDescription
name String The name of the beat to find

Returns Null<NBeatDecl> The beat declaration if found, null otherwise

RuntimeBeatRef

class

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

property

public var beat(default, null):NBeatDecl

The referenced beat declaration.

Returns NBeatDecl

stack

property

public var stack(default, null):Array<RuntimeScope>

The captured scope chain (closure). Empty for top-level beats.

Returns Array<RuntimeScope>

new

constructor

public function new(beat:NBeatDecl, stack:Array<RuntimeScope>)
ParameterTypeDescription
beat NBeatDecl
stack Array<RuntimeScope>

beatOf

method

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.

ParameterTypeDescription
value Any

Returns Null<NBeatDecl>

beatNameOf

method

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.

ParameterTypeDescription
value Any

Returns Null<String>

RuntimeInsertion

class

Fata that needs to be hold with a scope when a beat is being inserted within a choice

id

property

public var id:Int

The insertion id, a unique integer value among all insertions.

Returns Int

origin

property

public var origin:NInsertion

The original node causing that insertion

Returns NInsertion

options

property

public var options:Array<ChoiceOption> = null

The inserted choice options, or null if nothing is inserted yet

Returns Array<ChoiceOption>

stack

property

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

property

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

property

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

constructor

public function new(id:Int, origin:NInsertion)
ParameterTypeDescription
id Int
origin NInsertion

RuntimeError

class

Runtime error that can occur during script execution.

new

constructor

public function new(message:String, ?pos:Position)
ParameterTypeDescription
message String
pos Position

EvalNext

class

Helper class for managing the next evaluation step. Used to control whether the next step should be executed synchronously or asynchronously.

sync

property

public var sync:Bool = true

Whether the next step should be executed synchronously.

Returns Bool

cb

property

public var cb:()->Void = null

The callback to execute for the next step.

Returns ()->Void

new

constructor

public function new()

Creates a new EvalNext instance.

NodeIdStep

enum

enum abstract NodeIdStep(Int)

SECTION

constant

SECTION = 1

Returns NodeIdStep

BRANCH

constant

BRANCH = 2

Returns NodeIdStep

BLOCK

constant

BLOCK = 3

Returns NodeIdStep

NODE

constant

NODE = 4

Returns NodeIdStep

NodeIdMap

class

new

constructor

public inline function new()

get

method

public inline function get(key:NodeId):Null<V>
ParameterTypeDescription
key NodeId

Returns Null<V>

set

method

public inline function set(key:NodeId, value:V):Void
ParameterTypeDescription
key NodeId
value V

Returns Void

remove

method

public inline function remove(key:NodeId):Void
ParameterTypeDescription
key NodeId

Returns Void

exists

method

public inline function exists(key:NodeId):Bool
ParameterTypeDescription
key NodeId

Returns Bool

clear

method

public inline function clear():Void

Returns Void

iterator

method

public inline function iterator():NodeIdMapIterator<V>

Returns NodeIdMapIterator<V>

keys

method

public inline function keys():NodeIdMapKeyIterator<V>

Returns NodeIdMapKeyIterator<V>

keyValueIterator

method

public inline function keyValueIterator():NodeIdMapKeyValueIterator<V>

Returns NodeIdMapKeyValueIterator<V>

NodeIdMapKeyVal

type alias

typedef NodeIdMapKeyVal<V> = { value:V, key:NodeId }

Comment

class

Represents a comment node in the AST. Contains both the comment content and whether it's a multiline comment.

content

property

public var content:String

The actual text content of the comment.

Returns String

multiline

property

public var multiline:Bool

Whether this is a multiline comment (/* ... */) or single-line comment (//).

Returns Bool

isHash

property

public var isHash:Bool

Whether this is a hash comment (#identifier).

Returns Bool

new

constructor

public function new(id:NodeId, pos:Position, content:String, multiline:Bool, ?isHash:Bool = false)

Creates a new Comment node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the comment node to a JSON representation.

Returns Dynamic Dynamic object containing comment data

AstNode

class

Base class for AST nodes that can have associated comments. Extends Node with support for leading and trailing comments.

leadingComments

property

public var leadingComments:Null<Array<Comment>>

Comments that appear before this node.

Returns Null<Array<Comment>>

trailingComments

property

public var trailingComments:Null<Array<Comment>>

Comments that appear after this node.

Returns Null<Array<Comment>>

new

constructor

public function new(id:NodeId, pos:Position, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new node that supports comments.

ParameterTypeDescription
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

method

public function eachComment(handleComment:(node:AstNode, comment:Comment)->Void):Void
ParameterTypeDescription
handleComment (node:AstNode, comment:Comment)->Void

Returns Void

toJson

method

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

class

Base class for all expression nodes in the AST.

new

constructor

public function new(id:NodeId, pos:Position, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)
ParameterTypeDescription
id NodeId
pos Position
leadingComments Array<Comment>
trailingComments Array<Comment>

toJson

method

public override function toJson():Dynamic

Converts the expression node to a JSON representation.

Returns Dynamic Dynamic object containing expression data

NStateDecl

class

Represents a state declaration node in the AST. States can be either temporary (new state) or permanent.

temporary

property

public var temporary:Bool

Whether this state is temporary (new state).

Returns Bool

fields

property

public var fields:Array<NObjectField>

Fields defined for this state.

Returns Array<NObjectField>

style

property

public var style:BlockStyle

Block style of this state

Returns BlockStyle

new

constructor

public function new(id:NodeId, pos:Position, temporary:Bool, fields:Array<NObjectField>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new state declaration node.

ParameterTypeDescription
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

method

public function get(name:String):NExpr
ParameterTypeDescription
name String

Returns NExpr

toJson

method

public override function toJson():Dynamic

Converts the state declaration to a JSON representation.

Returns Dynamic Dynamic object containing state data

NObjectField

class

Represents an object field in the AST (name-value pair).

name

property

public var name:String

Name of the field.

Returns String

value

property

public var value:NExpr

Value expression of the field.

Returns NExpr

new

constructor

public function new(id:NodeId, pos:Position, name:String, value:NExpr, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new object field node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the object field to a JSON representation.

Returns Dynamic Dynamic object containing field data

NCharacterDecl

class

Represents a character declaration in the AST.

name

property

public var name:String

Name of the character.

Returns String

namePos

property

public var namePos:Position

Position of the name part.

Returns Position

fields

property

public var fields:Array<NObjectField>

Fields defined for this character.

Returns Array<NObjectField>

style

property

public var style:BlockStyle

Block style of this character

Returns BlockStyle

new

constructor

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.

ParameterTypeDescription
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

method

public function get(name:String):NExpr
ParameterTypeDescription
name String

Returns NExpr

toJson

method

public override function toJson():Dynamic

Converts the character declaration to a JSON representation.

Returns Dynamic Dynamic object containing character data

NBeatParam

class

A single parameter in a beat declaration, e.g. name or mood = "happy" in beat Greet(name, mood = "happy").

name

property

public var name:String

Name of the parameter.

Returns String

namePos

property

public var namePos:Position

Position of the parameter name in source.

Returns Position

defaultValue

property

public var defaultValue:Null<NExpr>

Optional default value expression, evaluated when no argument is provided.

Returns Null<NExpr>

new

constructor

public function new(name:String, namePos:Position, ?defaultValue:NExpr)
ParameterTypeDescription
name String
namePos Position
defaultValue NExpr

toJson

method

public function toJson():Dynamic

Returns Dynamic

NBeatDecl

class

Represents a beat (scene) declaration in the AST.

name

property

public var name:String

Name of the beat.

Returns String

body

property

public var body:Array<AstNode>

Array of nodes that make up the beat's content.

Returns Array<AstNode>

style

property

public var style:BlockStyle

Block style of this beat

Returns BlockStyle

params

property

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

constructor

public function new(id:NodeId, pos:Position, name:String, body:Array<AstNode>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new beat declaration node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the beat declaration to a JSON representation.

Returns Dynamic Dynamic object containing beat data

StringPartType

enum

Represents the different types of string parts that can appear in string literals.

Raw

constant

Raw(text:String)

Raw text content.

ParameterTypeDescription
text String

Expr

constant

Expr(expr:NExpr)

Interpolated expression (${...} or $identifier).

ParameterTypeDescription
expr NExpr

Tag

constant

Tag(closing:Bool, expr:NStringLiteral)

Text formatting tag ( or ).

ParameterTypeDescription
closing Bool
expr NStringLiteral

BlockStyle

enum

enum abstract BlockStyle(Int)

Plain

constant

Plain = 0

Returns BlockStyle

Braces

constant

Braces = 1

Returns BlockStyle

toString

method

public function toString():String

Returns String

ConditionStyle

enum

enum abstract ConditionStyle(Int)

Plain

constant

Plain = 0

Returns ConditionStyle

Parens

constant

Parens = 2

Returns ConditionStyle

toString

method

public function toString():String

Returns String

AlternativeMode

enum

enum abstract AlternativeMode(Int)

Represents the mode of an alternative block.

Sequence

constant

Sequence = 0

Returns AlternativeMode

Cycle

constant

Cycle = 1

Returns AlternativeMode

Once

constant

Once = 2

Returns AlternativeMode

Pick

constant

Pick = 3

Returns AlternativeMode

Shuffle

constant

Shuffle = 4

Returns AlternativeMode

toString

method

public function toString():String

Returns String

NStringPart

class

Represents a string part that can appear in string literals.

partType

property

public var partType:StringPartType

The type of string part

Returns StringPartType

new

constructor

public function new(id:NodeId, pos:Position, partType:StringPartType, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new string part node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the string part to a JSON representation.

Returns Dynamic Dynamic object containing string part data

NStringLiteral

class

Represents a string literal in the AST, supporting interpolation and tags.

parts

property

public var parts:Array<NStringPart>

Array of parts that make up this string literal.

Returns Array<NStringPart>

quotes

property

public var quotes:Quotes

The type of quotes used for this string literal

Returns Quotes

new

constructor

public function new(id:NodeId, pos:Position, quotes:Quotes, parts:Array<NStringPart>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new string literal node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the string literal to a JSON representation.

Returns Dynamic Dynamic object containing string data and its parts

NTextStatement

class

Represents a text statement in the AST.

content

property

public var content:NStringLiteral

The content of the text statement.

Returns NStringLiteral

condition

property

public var condition:Null<NExpr>

Optional condition that must be true for this text to be displayed.

Returns Null<NExpr>

conditionStyle

property

public var conditionStyle:ConditionStyle

The style of the condition (plain or parentheses).

Returns ConditionStyle

conditionPos

property

public var conditionPos:Null<Position>

Position of the trailing "if condition" clause (from 'if' keyword through condition end).

Returns Null<Position>

new

constructor

public function new(id:NodeId, pos:Position, content:NStringLiteral, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new text statement node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the text statement to a JSON representation.

Returns Dynamic Dynamic object containing text data

NDialogueStatement

class

Represents a dialogue statement in the AST (character: "text").

character

property

public var character:String

Name of the speaking character.

Returns String

characterPos

property

public var characterPos:Position

Position of the character label

Returns Position

content

property

public var content:NStringLiteral

Content of the dialogue.

Returns NStringLiteral

condition

property

public var condition:Null<NExpr>

Optional condition that must be true for this dialogue to be displayed.

Returns Null<NExpr>

conditionStyle

property

public var conditionStyle:ConditionStyle

The style of the condition (plain or parentheses).

Returns ConditionStyle

conditionPos

property

public var conditionPos:Null<Position>

Position of the trailing "if condition" clause (from 'if' keyword through condition end).

Returns Null<Position>

new

constructor

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.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the dialogue statement to a JSON representation.

Returns Dynamic Dynamic object containing dialogue data

NChoiceStatement

class

Represents a choice statement in the AST.

options

property

public var options:Array<NChoiceOption>

Array of available options in this choice.

Returns Array<NChoiceOption>

style

property

public var style:BlockStyle

The block style of the choice statement

Returns BlockStyle

new

constructor

public function new(id:NodeId, pos:Position, options:Array<NChoiceOption>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new choice statement node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the choice statement to a JSON representation.

Returns Dynamic Dynamic object containing choice data

NChoiceOption

class

Represents a single option within a choice statement.

text

property

public var text:NStringLiteral

The text displayed for this option.

Returns NStringLiteral

insertion

property

public var insertion:NInsertion

Alternatively, instead of text, this could be an insertion

Returns NInsertion

condition

property

public var condition:Null<NExpr>

Optional condition that must be true for this option to be available.

Returns Null<NExpr>

conditionStyle

property

public var conditionStyle:ConditionStyle

The style of the condition (plain or parentheses).

Returns ConditionStyle

conditionPos

property

public var conditionPos:Null<Position>

Position of the trailing "if condition" clause (from 'if' keyword through condition end).

Returns Null<Position>

body

property

public var body:Array<AstNode>

Array of nodes to execute when this option is chosen.

Returns Array<AstNode>

style

property

public var style:BlockStyle

The block style of the body

Returns BlockStyle

once

property

public var once:Bool

Whether this option can only be chosen once (disappears after being selected).

Returns Bool

new

constructor

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.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the choice option to a JSON representation.

Returns Dynamic Dynamic object containing option data

NBlock

class

Represents a block with a sequence multiple nodes

body

property

public var body:Array<AstNode>

Array of nodes that make up the beat's content.

Returns Array<AstNode>

style

property

public var style:BlockStyle

The block style of the body.

Returns BlockStyle

new

constructor

public function new(id:NodeId, pos:Position, body:Array<AstNode>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new block node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the beat declaration to a JSON representation.

Returns Dynamic Dynamic object containing beat data

NIfStatement

class

Represents an if statement in the AST, with optional else branch.

condition

property

public var condition:NExpr

The condition to evaluate.

Returns NExpr

conditionStyle

property

public var conditionStyle:ConditionStyle

The style of the condition (plain or parentheses).

Returns ConditionStyle

thenBranch

property

public var thenBranch:NBlock

Array of nodes to execute if condition is true.

Returns NBlock

elseBranch

property

public var elseBranch:Null<NBlock>

Optional array of nodes to execute if condition is false.

Returns Null<NBlock>

elseLeadingComments

property

public var elseLeadingComments:Null<Array<Comment>>

Comments that appear before the else keyword.

Returns Null<Array<Comment>>

elseTrailingComments

property

public var elseTrailingComments:Null<Array<Comment>>

Comments that appear after the else keyword.

Returns Null<Array<Comment>>

new

constructor

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.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the if statement to a JSON representation.

Returns Dynamic Dynamic object containing if statement data

NAlternative

class

Represents an alternative block (sequence, cycle, once, pick, shuffle).

mode

property

public var mode:AlternativeMode

The alternative mode (sequence, cycle, once, pick, shuffle).

Returns AlternativeMode

items

property

public var items:Array<NBlock>

Array of item blocks. Each item is a block of statements.

Returns Array<NBlock>

style

property

public var style:BlockStyle

The block style (indented or braces).

Returns BlockStyle

separatorComments

property

public var separatorComments:Null<Array<Array<Comment>>>

Comments that appear before separator tokens.

Returns Null<Array<Array<Comment>>>

new

constructor

public function new(id:NodeId, pos:Position, mode:AlternativeMode, items:Array<NBlock>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new alternative block node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the alternative block to a JSON representation.

Returns Dynamic Dynamic object containing alternative data

NCall

class

Represents a function call expression in the AST.

target

property

public var target:NExpr

The expression being called.

Returns NExpr

args

property

public var args:Array<NExpr>

Array of argument expressions passed to the call.

Returns Array<NExpr>

new

constructor

public function new(id:NodeId, pos:Position, target:NExpr, args:Array<NExpr>, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new call expression node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the call expression to a JSON representation.

Returns Dynamic Dynamic object containing call data

NTransition

class

Represents a transition to another beat (->).

target

property

public var target:String

Name of the target beat (null when the target is dynamic, see targetExpr).

Returns String

targetPos

property

public var targetPos:Position

Position of the target part of the transition

Returns Position

targetExpr

property

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

property

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

constructor

public function new(id:NodeId, pos:Position, target:String, targetPos:Position, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new transition node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the transition to a JSON representation.

Returns Dynamic Dynamic object containing transition data

NInsertion

class

Represents an insertion of another beat (+).

target

property

public var target:String

Name of the target beat (null when the target is dynamic, see targetExpr).

Returns String

targetPos

property

public var targetPos:Position

Position of the target part of the insertion

Returns Position

targetExpr

property

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

property

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

constructor

public function new(id:NodeId, pos:Position, target:String, targetPos:Position, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new insertion node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the insertion to a JSON representation.

Returns Dynamic Dynamic object containing insertion data

NBeatCall

class

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

property

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

property

public var targetPos:Position

Position of the beat(...) target part.

Returns Position

args

property

public var args:Null<Array<NExpr>> = null

Optional arguments passed to the target beat.

Returns Null<Array<NExpr>>

new

constructor

public function new(id:NodeId, pos:Position, targetExpr:NExpr, targetPos:Position, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new dynamic beat call node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the beat call to a JSON representation.

Returns Dynamic Dynamic object containing beat call data

NFunctionDecl

class

Represents a callable function in the AST

name

property

public var name:Null<String>

The function name (if any)

Returns Null<String>

args

property

public var args:Array<String>

Argument names

Returns Array<String>

code

property

public var code:String

The actual code of the function (including the signature)

Returns String

external

property

public var external:Bool

Whether this is an external function (so this is only a declaration without implementation)

Returns Bool

new

constructor

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.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the literal to a JSON representation.

Returns Dynamic Dynamic object containing literal data

NLiteral

class

Represents literal values in the AST (numbers, booleans, arrays, objects).

value

property

public var value:Any

The literal value.

Returns Any

literalType

property

public var literalType:LiteralType

Type of the literal value.

Returns LiteralType

new

constructor

public function new(id:NodeId, pos:Position, value:Any, literalType:LiteralType, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new literal node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the literal to a JSON representation.

Returns Dynamic Dynamic object containing literal data

LiteralType

enum

Possible types for literal values.

Number

constant

Number

Numeric literal

Boolean

constant

Boolean

Boolean literal

Null

constant

Null

Null literal

Array

constant

Array

Array literal

Object

constant

Object(style:BlockStyle)

Object literal

ParameterTypeDescription
style BlockStyle

NAccess

class

Represents a field access expression (obj.field).

target

property

public var target:Null<NExpr>

Optional target object being accessed.

Returns Null<NExpr>

name

property

public var name:String

Name of the accessed field.

Returns String

new

constructor

public function new(id:NodeId, pos:Position, target:Null<NExpr>, name:String, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new field access node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the field access to a JSON representation.

Returns Dynamic Dynamic object containing access data

NAssign

class

Represents an assignment expression (a = b, a += b, etc).

target

property

public var target:NExpr

Target expression being assigned to.

Returns NExpr

op

property

public var op:TokenType

Assignment operator type.

Returns TokenType

value

property

public var value:NExpr

Value being assigned.

Returns NExpr

new

constructor

public function new(id:NodeId, pos:Position, target:NExpr, op:TokenType, value:NExpr, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new assignment node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the assignment to a JSON representation.

Returns Dynamic Dynamic object containing assignment data

NArrayAccess

class

Represents an array access expression (array[index]).

target

property

public var target:NExpr

Target array being accessed.

Returns NExpr

index

property

public var index:NExpr

Index expression.

Returns NExpr

new

constructor

public function new(id:NodeId, pos:Position, target:NExpr, index:NExpr, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new array access node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the array access to a JSON representation.

Returns Dynamic Dynamic object containing array access data

NBinary

class

Represents a binary operation expression (a + b, a && b, etc).

left

property

public var left:NExpr

Left operand expression.

Returns NExpr

op

property

public var op:TokenType

Operator type.

Returns TokenType

right

property

public var right:NExpr

Right operand expression.

Returns NExpr

new

constructor

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.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the binary operation to a JSON representation.

Returns Dynamic Dynamic object containing operation data

NUnary

class

Represents a unary operation expression (!x, -x, etc).

op

property

public var op:TokenType

Operator type.

Returns TokenType

operand

property

public var operand:NExpr

Operand expression.

Returns NExpr

new

constructor

public function new(id:NodeId, pos:Position, op:TokenType, operand:NExpr, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new unary operation node.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the unary operation to a JSON representation.

Returns Dynamic Dynamic object containing operation data

NTernary

class

Represents a ternary conditional expression (condition ? trueExpr : falseExpr).

condition

property

public var condition:NExpr

The condition expression.

Returns NExpr

trueExpr

property

public var trueExpr:NExpr

The expression to evaluate if the condition is true.

Returns NExpr

falseExpr

property

public var falseExpr:NExpr

The expression to evaluate if the condition is false.

Returns NExpr

new

constructor

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.

ParameterTypeDescription
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

method

public override function toJson():Dynamic

Converts the ternary expression to a JSON representation.

Returns Dynamic Dynamic object containing ternary data

NImportStatement

class

Represents an import statement

path

property

public var path:NStringLiteral

The relative path of the file to import

Returns NStringLiteral

script

property

public var script:Script

The imported AST

Returns Script

new

constructor

public function new(id:NodeId, pos:Position, path:NStringLiteral, script:Script, ?leadingComments:Array<Comment>, ?trailingComments:Array<Comment>)

Creates a new import statement node.

ParameterTypeDescription
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.