Refactor to use an intermediate sexp representation

Superseeds https://github.com/travis-ci/travis-build/pull/274 and https://github.com/travis-ci/travis-build/pull/319

This now produces the exact same build script for ~13K staging and ~43K production worker payloads.

Needs to be tested on staging.