replace regular expression with tokenizer

This change lays the groundwork for the addition of Python's format
specification mini-language. Incidentally, it fixes the handling of
unmatched, unescaped curly brackets.
throw a KeyError in resolve if key not of object
work in progress