Expression Evaluator

This project is an expression parser and evaluator that takes standard infix arithmetic expressions and computes them while respecting operator precedence and parentheses. It’s built around a two-stack approach, allowing the expression to be evaluated step by step while also checking for invalid or malformed input along the way.

Project Phases

  1. Start by defining how expressions are structured and how they should be broken into tokens.
  2. Build a stack-based evaluation system that correctly handles operator precedence.
  3. Extend the system to support parentheses and nested expressions.
  4. Add validation to catch common errors like missing values, invalid operators, and mismatched parentheses.
  5. Introduce support for implicit multiplication and proper handling of negative numbers.
  6. Handle runtime errors such as division by zero.

Summary of Key Learnings

The evaluator processes expressions in linear time using a stack-based approach. Personally, it was quite nice to see how different data types can be applied to speed up, or make posisble, solving a certain problem. This is a main idea in ADEN but this was the first time I really saw that.

Reflections

Expression Evaluator Reflection
Download PDF

← Back to ADEN Course