Skip to content

mrfuxi/ast_calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AST Calculator

Simple calculator based on Abstract syntax tree. In this case Python's AST.

Usage

Interactive mode:

./calc.py

One off evaluation from command line:

./calc.py "1 + 2"

Evaluation of all expression in the file:

./calc.py -f input_file

Help, as always:

./calc.py --help

Tests

To run test execute:

python -m unittest discover

Functionality

Allowed

  • All operators defined in ast
  • Functions: log, exp, sqrt, sin, cos
  • Const: pi, e

Not allowed

  • All other things ;) That included executing Python code

About

AST based calculator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages