This project is an arithmetic parser developed using PLY (Python Lex-Yacc). It is capable of parsing and computing both simple and complex arithmetic expressions, providing a powerful tool for mathematical computations.
- Support for Basic Operations: Addition (
+
), subtraction (-
), multiplication (*
), and division (/
). - Advanced Operations: Exponentiation (
^
), modulus (mod
), square root (sqrt()
). - Variable Support: Ability to use variables for storing intermediate results.
- Flexible Grammar: Uses context-free grammar for parsing expressions.
- Interactive Mode: Input and compute expressions in real-time.
To install and run the parser:
- Clone the repository.
- Install dependencies (
pip install -r requirements.txt
). - Run
main.py
for interactive mode.
Simply run main.py
and enter an arithmetic expression. Examples:
2 + 3 * 4
x = 5
y = (x + 15)^4
To run the tests, run unit_tests.py
. This will run the test suite and output the results.