Earley parser: TH's code from 2014-07-07.