The Interpreter: Parsing the Glyphs
Defining a grammar for statistical queries.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Interpreter
ARCANUM SCHOOL: Divination // Grammar
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// R PATTERN //
library(R6)
# Abstract Expression
Expression <- R6Class("Expression",
public = list(
interpret = function(context) stop("Not implemented")
)
)
# Terminal Expression
RuneExpression <- R6Class("RuneExpression", inherit = Expression,
private = list(
data = NULL
),
public = list(
initialize = function(data) {
private$data <- data
},
interpret = function(context) {
return(grepl(private$data, context))
}
)
)
# Non-terminal Expression
OrExpression <- R6Class("OrExpression", inherit = Expression,
private = list(
expr1 = NULL,
expr2 = NULL
),
public = list(
initialize = function(expr1, expr2) {
private$expr1 <- expr1
private$expr2 <- expr2
},
interpret = function(context) {
return(private$expr1$interpret(context) || private$expr2$interpret(context))
}
)
)
The Interpreter translates esoteric grammar—such as combining queries of Runes and Glyphs—into true/false revelations within a given context string.
Runic Tags:
#R6
#Divination
#Behavioral
#Interpreter