Right now, the GrammarToken allows users to define (a) the means by which a token replaces itself and (b) the way in which a token acts on an entity.
At the time of this writing, implementing classes must define both operations in the same class. This is inherently inflexible, and inhibits code-reuse.
To resolve the problem, GrammarTokens should define the way in which a token replaces itself. Rather than inheriting the act method, users should be able to pass an act method to a GrammarToken as a higher-order-function.
This change would allow stochrammar to include provide several standard GrammarToken implementations for different ways of replacing tokens with other tokens, along with unified APIs on top of them.
Right now, the GrammarToken allows users to define (a) the means by which a token replaces itself and (b) the way in which a token acts on an entity.
At the time of this writing, implementing classes must define both operations in the same class. This is inherently inflexible, and inhibits code-reuse.
To resolve the problem,
GrammarTokens
should define the way in which a token replaces itself. Rather than inheriting theact
method, users should be able to pass anact
method to a GrammarToken as a higher-order-function.This change would allow stochrammar to include provide several standard
GrammarToken
implementations for different ways of replacing tokens with other tokens, along with unified APIs on top of them.