✨ ARCANUM RUNE DIFFICULTY: Archmage Behavioral

The Interpreter: The Sigil Decoder

Define a representation of a grammar and an interpreter to evaluate sentences within it.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Interpreter
ARCANUM SCHOOL: Divination // Linguistics
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
class_name Expression extends RefCounted
func interpret(context: Dictionary) -> bool:
    return false

class_name TerminalExpression extends Expression
var data: String
func _init(d: String) -> void: data = d
func interpret(context: Dictionary) -> bool:
    return context.has(data) and context[data] == true

class_name AndExpression extends Expression
var expr1: Expression
var expr2: Expression
func _init(e1: Expression, e2: Expression) -> void:
    expr1 = e1
    expr2 = e2
func interpret(context: Dictionary) -> bool:
    return expr1.interpret(context) and expr2.interpret(context)

When the fabric of your game requires its own internal logic language—such as a dialogue condition evaluator or custom scripting layer—the Interpreter provides the means. It transforms raw string sigils into a living syntax tree, traversing the nodes to manifest boolean truths from the aether.

Runic Tags: #godot #gdscript #interpreter #parsing #grammar