Implement a mathematical expression parser and evaluator from scratch without using built-in evaluation libraries.