A simple parser for mathematical terms