Adapted from thrift.el provided by the Apache Thrift repository (https://thrift.apache.org/).