More formatter work.

Implement functions, add test.

Functions don't hugely need to be optional, we can just carry on
if the function is invalid.
Merge pull request #118 from csmith/master

More formatter work.