Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Shatur/calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calculator

A console application for mathematical calculations using parsing. Created for educational purposes.

Examples:

> 2 + 2 * 2
= 6

> x=4, y=2, (x+y)^x
= 4, 2, 1296

> x=sin(pi*5), y=2tg(e), x+y - (x * y)
= 6.1232339957367663e-16, -0.90109906813961538, -0.90109906813961416

> 3+3+3^3-pi+e
= 32.576689174869252

> x
   ^
Expected assignment at: 2

> (3+3
      ^
Expected brace at: 5

> sin3 
= 0.14112000805986721

> sin(3+4
         ^
Expected brace at: 8

> e 
= 2.7182818284590451

> e / 0
      ^
Division by zero at: 5

> 2^2^2^2
= 256

Grammar

Command:

Statement

Statement , Command

Statement:

Expression

Undefined variable = Expression

Variable = Expression

Expression:

Term

Term + Expression

Term - Expression

Term:

Primary

Primary Variable

Term ( Expression )

Term sin Primary

Term cos Primary

Term tg Primary

Term ctg Primary

Term sec Primary

Term cosec Primary

Term * Primary

Term / Primary

Term % Primary

Term ^ Primary

Primary:

Number

Variable

( Expression )

sin Primary

cos Primary

tg Primary

ctg Primary

sec Primary

cosec Primary

- Primary

+ Primary

Number:

A floating point number.

Variable or undefined variable:

A text that starts with a letter and can contain letters, numbers, or _.

About

A console application for mathematical calculations using parsing.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published