Use a simple scope stack. When you enter a new scope, push a new scope representation to the stack, when you leave it - pop it.
The first scope on the stack would be pre-defined and hold things like language constants.
When looking up a reference iterate through the stack from top down.