Parser and evaluator for mathematical expressions