Is there a reason we can't just make the signature of apply be the same for context free and context sensitive, and then get the context in a different way? I once again feel funny about doing all this switching on the class of objects. Shouldn't it be possible to pass an object into this somehow that you can call a method on if you want to compute the context? Then you might not even need a distinction between ContextFreeRule and ContextSensitiveRule, except a basic check that says that if you call computeContext() from a ContextFreeRule then it fails an assertion.