The Interpreter
Deciphering the ancient runes of power directly on the blockchain.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Interpreter
ARCANUM SCHOOL: Divination // Decoding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// IMMUTABLE DECENTRALIZED PACT //
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IRuneExpression {
function interpret(string memory context) external pure returns (bool);
}
contract BloodRune is IRuneExpression {
function interpret(string memory context) external pure override returns (bool) {
return keccak256(abi.encodePacked(context)) == keccak256(abi.encodePacked("BLOOD"));
}
}
contract VoidRune is IRuneExpression {
function interpret(string memory context) external pure override returns (bool) {
return keccak256(abi.encodePacked(context)) == keccak256(abi.encodePacked("VOID"));
}
}
contract OrExpression is IRuneExpression {
IRuneExpression public expr1;
IRuneExpression public expr2;
constructor(address _e1, address _e2) {
expr1 = IRuneExpression(_e1);
expr2 = IRuneExpression(_e2);
}
function interpret(string memory context) external view override returns (bool) {
return expr1.interpret(context) || expr2.interpret(context);
}
}
To understand the maddening runes of the ancients, the Interpreter constructs an abstract syntax tree of smart contracts. Each contract evaluates a fragment of the linguistic context, allowing the decentralized ledger to parse expressions of true magical power.
Runic Tags:
#solidity
#behavioral
#interpreter