Starting on support for constant and type defs

This commit is mostly refactoring in preparation for supporting constant
and type definitions in the same contexts as are currently supported for
variable definitions.