ESCInterpreter
Extends: RefCounted
Description
The actual interpreter that processes a parsed ASHES script.
Constants
CURRENT_PLAYER_KEYWORD
const CURRENT_PLAYER_KEYWORD = "CURRENT_PLAYER"
Used to represent the current player character in scripts.
CURRENT_OBJECT
const CURRENT_OBJECT = "THIS"
Members
Methods
cleanup
func cleanup() -> void
get_global_values
func get_global_values() -> Dictionary
The dictionary containing any and all global variables.
Parameters
None.
Returns
Returns the dictionary containing any and all global variables. (Dictionary)
get_channel_name
func get_channel_name() -> String
Gets the event-manager channel this interpreter is executing on.
Parameters
None.
Returns
Returns the channel name associated with this interpreter run. (String)
reset
func reset() -> void
Resets the interpreter, specifically any locally-scoped variables.
Parameters
None.
Returns
Returns nothing.
interrupt
func interrupt() -> void
Issues an interrupt to the currently-running event, if there is one.
Parameters
None.
Returns
Returns nothing.
interpret
func interpret(statements: Variant) -> Variant
The main entry point for the interpreter. Takes one or more statements and begins to interpret them. These usually represent the statements at the top level of the script being processed.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
statements |
|
a single |
yes |
Returns
Returns nothing.
visit_block_stmt
func visit_block_stmt(stmt: ESCGrammarStmts.Block) -> Variant
Executes code relevant to interpreting a statement block.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
stmt |
|
Statement node to interpret. |
yes |
Returns
Returns nothing.
visit_event_stmt
func visit_event_stmt(stmt: ESCGrammarStmts.Event) -> void
Executes code relevant to interpreting an event in ASHES, e.g. :look. Emits the statement’s finished signal upon completion, containing the return code.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
stmt |
|
the |
yes |
Returns
Returns nothing.
visit_expression_stmt
func visit_expression_stmt(stmt: ESCGrammarStmts.ESCExpression) -> Variant
Executes code relevant to interpreting an expression contained in a statement.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
stmt |
|
Statement node to interpret. |
yes |
Returns
Returns nothing.
visit_call_expr
func visit_call_expr(expr: ESCGrammarExprs.Call) -> Variant
Executes code relevant to interpreting a function/method call.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
expr |
|
the expression representing the function/method call to make |
yes |
Returns
Returns nothing.
visit_if_stmt
func visit_if_stmt(stmt: ESCGrammarStmts.If) -> Variant
Executes code relevant to interpreting an if statement.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
stmt |
|
Statement node to interpret. |
yes |
Returns
Returns nothing.
visit_while_stmt
func visit_while_stmt(stmt: ESCGrammarStmts.While) -> Variant
Executes code relevant to interpreting a while loop.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
stmt |
|
Statement node to interpret. |
yes |
Returns
Returns nothing.
visit_pass_stmt
func visit_pass_stmt(_stmt: ESCGrammarStmts.Pass) -> void
Executes code relevant to interpreting a pass statement.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
stmt |
|
Statement node to interpret. |
yes |
Returns
Returns nothing.
visit_stop_stmt
func visit_stop_stmt(stmt: ESCGrammarStmts.Stop) -> Variant
Executes code relevant to interpreting a stop statement. Relevant only to dialogs.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
stmt |
|
Statement node to interpret. |
yes |
Returns
Returns nothing.
visit_var_stmt
func visit_var_stmt(stmt: ESCGrammarStmts.Var) -> Variant
Executes code relevant to interpreting a variable declaration and possible initialization.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
stmt |
|
Statement node to interpret. |
yes |
Returns
Returns nothing.
visit_global_stmt
func visit_global_stmt(stmt: ESCGrammarStmts.Global) -> Variant
Executes code relevant to interpreting a global variable declaration and possible initialization.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
stmt |
|
Statement node to interpret. |
yes |
Returns
Returns nothing.
visit_dialog_stmt
func visit_dialog_stmt(stmt: ESCGrammarStmts.Dialog) -> Variant
Executes code relevant to interpreting a block of dialog.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
stmt |
|
Statement node to interpret. |
yes |
Returns
Returns nothing.
visit_dialog_option_stmt
func visit_dialog_option_stmt(_stmt: ESCGrammarStmts.DialogOption) -> void
Executes code relevant to interpreting a dialog option, although this is more of a placeholder to keep the processing of the syntax tree going since dialog options are handled by the overall dialog block.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
stmt |
|
Statement node to interpret. |
yes |
Returns
Returns nothing.
visit_break_stmt
func visit_break_stmt(stmt: ESCGrammarStmts.Break) -> Variant
Executes code relevant to interpreting a break statement.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
stmt |
|
Statement node to interpret. |
yes |
Returns
Returns nothing.
visit_done_stmt
func visit_done_stmt(stmt: ESCGrammarStmts.Done) -> Variant
Executes code relevant to interpreting a done statement. Only relevant when processing dialogs.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
stmt |
|
Statement node to interpret. |
yes |
Returns
Returns nothing.
visit_assign_expr
func visit_assign_expr(expr: ESCGrammarExprs.Assign) -> Variant
Executes code relevant to interpreting an expression that assigns a value to a variable. Enforces traditional scoping rules.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
expr |
|
Expression node to evaluate. |
yes |
Returns
Returns nothing.
visit_in_inventory_expr
func visit_in_inventory_expr(expr: ESCGrammarExprs.InInventory) -> Variant
Executes code relevant to interpreting an in statement when checking whether an item in Escoria is in the player’s inventory.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
expr |
|
Expression node to evaluate. |
yes |
Returns
Returns nothing.
visit_is_expr
func visit_is_expr(expr: ESCGrammarExprs.Is) -> Variant
Executes code relevant to interpreting an is statement when checking whether an item in Escoria has a particular state and/or is active.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
expr |
|
Expression node to evaluate. |
yes |
Returns
Returns nothing.
visit_binary_expr
func visit_binary_expr(expr: ESCGrammarExprs.Binary) -> Variant
Executes code relevant to interpreting binary expressions, e.g. ==, !=, etc.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
expr |
|
Expression node to evaluate. |
yes |
Returns
Returns nothing.
visit_unary_expr
func visit_unary_expr(expr: ESCGrammarExprs.Unary) -> Variant
Executes code relevant to interpreting unary expressions, e.g. !, -.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
expr |
|
Expression node to evaluate. |
yes |
Returns
Returns nothing.
visit_variable_expr
func visit_variable_expr(expr: ESCGrammarExprs.Variable) -> Variant
Executes code relevant to interpreting variable expressions. Worth noting is that variables prefixed with a $ are treated as global IDs, e.g. $npc_character is interperted as the global ID npc_character.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
expr |
|
Expression node to evaluate. |
yes |
Returns
Returns nothing.
visit_literal_expr
func visit_literal_expr(expr: ESCGrammarExprs.Literal) -> Variant
Executes code relevant to interpreting literal expressions, e.g. "some string", 1234`, etc.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
expr |
|
Expression node to evaluate. |
yes |
Returns
Returns nothing.
visit_logical_expr
func visit_logical_expr(expr: ESCGrammarExprs.Logical) -> Variant
Executes code relevant to interpreting logical expressions, e.g. AND, OR, etc.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
expr |
|
Expression node to evaluate. |
yes |
Returns
Returns nothing.
visit_grouping_expr
func visit_grouping_expr(expr: ESCGrammarExprs.Grouping) -> Variant
Executes code relevant to interpreting grouped expressions, e.g. those surrounded by parentheses.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
expr |
|
Expression node to evaluate. |
yes |
Returns
Returns nothing.
resolve
func resolve(expr: ESCGrammarExpr, depth: int) -> void
Performs resolution of the specified expression by specifying its scope depth.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
expr |
|
the expression requiring access to locally scoped variables |
yes |
depth |
|
the scope depth of the local variables to be used by the expression |
yes |
Returns
Returns nothing.
look_up_variable
func look_up_variable(name: ESCToken, expr: ESCGrammarExpr) -> Variant
Fetches the value of the variable specified by name provided it exists within the applicable scope for the expression expr.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
name |
|
Token representing the variable name to resolve. |
yes |
expr |
|
the expression containing the variable identified by |
yes |
Returns
Returns the value stored for the resolved variable. (Variant)
look_up_global
func look_up_global(name: ESCToken) -> Variant