Skip to content

Custom alogrithm in C Language to parse multi-bracket mathematical expressions

Notifications You must be signed in to change notification settings

tahseenjamal/maths_expression_parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

This is a custom algorithm written by me in C using linked list to parse mathematical expressions

Space and quotes are internally processed and managed

Supported Numbers: +ve, -ve, decimal

Supported Operators: Multi-Bracket, Divide, Multiply, Plus, Minus

Basic error in case expression is incorrect

Tested on latest - FreeBSD and Debian

gcc -o evaluate evaluate.c

./evaluate "3 * ( 1 + 2 ) * 2 * ( 3.5 + 4.5 )"

./evaluate "3 * ( -1 + 2 ) * -2 * 4.8"

./evaluate "3 * ( 1 + 2 ) + 6 * ( 2 + 3 * ( 3 + 4 ) )"

./evaluate "( 1 + 2 ) ^ 2 + 6 * ( 2 + 3 * ( 3 ^ 2 + 4 ) )"

You can even use & | < > = Currently >= and <= is supported but can be easily implemented

Using greater sign between the two expressions

./evaluate "( 1 + 2 ) ^ 2 > ( 3 ^ 2 + 4 )"

Note space and quotes are ignored so doesn't matter

About

Custom alogrithm in C Language to parse multi-bracket mathematical expressions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages