Change Flex and BYACC usage to be reentrant.

There are still lots of places elsewhere that aren't thread-safe (some
easy to fix, others less so), but this gets rid of a big one.

Other places include:
- Various static variables (trampoline generators, orphan list) that
  need to be deleted or wrapped in a mutex.
- Global / closure data structure access needs locking in order to allow
  both concurrent calls of functions from the same program instance, and
  concurrent calls of functions from different instances when one may
  have been given a function that closed over the other.