(#18636) Extract named constants for contextual acceptability

The various context checks used to be written inline. This caused a
small amount of duplication and provided no name for when the block
would determine that the token was acceptable. This extracts them all
into constants and places them inside an inner module in order to keep
track of them all. In addition the list of tokens that used to be
constructed for every invocation of several of the blocks are extracted
out and only created once during setup.