PolyCalc is a simple interpreter for a formal language designed to perform operations on polynomial expressions. It allows users to define polynomials, perform arithmetic operations such as addition, subtraction, multiplication, division (by a constant), and exponentiation, as well as evaluate polynomials for given variable values.
This project was created using flex
and bison
for lexical and syntactical analysis, and C
for the implementation of the interpreter logic.
├── Makefile
├── README.md
├── correct.poly
├── lexer.l
├── parser.y
├── polynomial.c
├── polynomial.h
├── report.pdf
└── test.poly
README.md
: This file, providing an overview of the project.Makefile
: Contains instructions for compiling the project.lexer.l
: flex file defining the lexical analyzer.parser.y
: bison file defining the syntactical analyzer and semantic actions.polynomial.h
: Header file declaring the data structures and function prototypes for polynomial manipulation.polynomial.c
: C source file containing the implementation of polynomial operations and the interpreter logic.correct.poly
: Test file containing correct polynomial expressions to demonstrate the functionality of the interpreter.test.poly
: Another test file for additional testing.report.pdf
: PDF file containing a detailed report on the project's design, implementation details, algorithms, and testing results.
- Polynomial Definition: Assign polynomial expressions to variables.
- Arithmetic Operations: Perform addition, subtraction, multiplication, division (by constant values), and exponentiation on polynomials.
- Evaluation: Evaluate polynomial expressions by assigning values to variables.
- Output: Display polynomial expressions in a readable format.
- Error Handling: Provides informative error messages for lexical, syntactical, and semantic errors.
flex
bison
gcc
or another C compilermake
-
Clone the repository:
git clone [repository URL]
-
Compile the program using
make
:make
To run the interpreter, use the following command:
./polycalc < <input_file>
where <input_file>
is a file containing polynomial expressions and commands.