Simple equation parser, ported from http://cogitolearning.co.uk/?p=523