Skip to content
/ calc Public

C implementation of an operator-precedence parser to evaluate mathematical equations

License

Notifications You must be signed in to change notification settings

lassandro/calc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

calc

This is a C implementation of an operator-precedence parser to evaluate mathematical equations.

Usage

The program executes the mathematical expression passed in via argv or stdin:

$ calc "1+2"
3

$ echo "1+2" | calc
3

Alternatively running the program without arguments enables REPL mode:

$ calc                                                                                                                                
= 1+2
3
= ans+5
8

Supported Operators

Operator Description
+ Addition
- Subtraction / Unary Negative
/ Division
* Multiplication
( Left Parenthesis
) Right Parenthesis

Supported Variables

Name Description
ans Previously Calculated Answer

Caveats

  • No support for non-integer math
  • No support for creating variables
  • No builtin functions
  • No history buffer

About

C implementation of an operator-precedence parser to evaluate mathematical equations

Topics

Resources

License

Stars

Watchers

Forks