Interpreter of the Syntax Void
Evaluate domain-specific search expressions against graph context.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Interpreter
ARCANUM SCHOOL: Divination // Linguistic Parsing
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// HACK PATTERN //
<?hh // strict
namespace SocialGraphAlchemy\Interpreter;
interface IQueryExpression {
public function interpret(string $context): bool;
}
class TerminalExpression implements IQueryExpression {
public function __construct(private string $data) {}
public function interpret(string $context): bool {
return \HH\Lib\Str\contains($context, $this->data);
}
}
class OrExpression implements IQueryExpression {
public function __construct(
private IQueryExpression $expr1,
private IQueryExpression $expr2
) {}
public function interpret(string $context): bool {
return $this->expr1->interpret($context) || $this->expr2->interpret($context);
}
}
Translating the Whispers
Querying raw telemetry often involves bespoke, constantly shifting syntaxes. The Interpreter pattern is employed by Archmages to design an abstract syntax tree of expressions (TerminalExpression, OrExpression) capable of dynamically parsing complex logical statements.
When deployed against a stream of context data, the interpreter evaluates the grammar and yields truth—an invaluable tool when sifting the void for specific semantic markers.
Runic Tags:
#hack
#interpreter
#behavioral
#social-graph