it's easier in my experience to build and check these tables if you can do it dynamically. some mappings are more controversial than others (eg, caps lock and ctrl). i don't see that dynamic loading must lead to something complex, if that's what xmodmap is. actually, at the moment i'd be more interested in a description of what the tables need to express to cover all possibilities. i know there are sequences of escapes in the scan codes (because they ran out of bits), and keys that modify subsequent characters by adding accents (on a german keyboard we've driven), and probably much more. is there a concise specification?