Skip to content

alien-aa/PolyCalc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PolyCalc: Polynomial Expression Interpreter

Description

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.

Repository Structure

├── 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.

Features

  • 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.

Building and Running

Prerequisites

  • flex
  • bison
  • gcc or another C compiler
  • make

Building

  1. Clone the repository:

    git clone [repository URL]
    
  2. Compile the program using make:

    make
    

Running

To run the interpreter, use the following command:

./polycalc < <input_file>

where <input_file> is a file containing polynomial expressions and commands.

About

Polynomial Expression Interpreter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published