Skip to content

➗ A command line math expression parser / interpreter.

Notifications You must be signed in to change notification settings

casperboone/calc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

➗ Calc

Build Status

A totally overkill command line math expression parser / interpreter.

Installation

Installation instructions will follow soon.

Usage

For short expressions, the easiest way to use the calculator is by passing a math expression as a command line argument to the application.

Examples:

$ calc 4 * (5 + 3)
// Output: 32
$ calc 4^2 + sqrt 25 - 20
// Output: 1

Language Specification

Program         => Expression+
Expression      => ( Expression ) | UnaryOperation Expression | Expression BinaryOperation Expression | Number

UnaryOperation  => - | sqrt | √
BinaryOperation => + | - | / | * | ^ | % | mod

Number          => Integer | Float
Integer         => Digits
Float           => Digits . Digits | . Digits | Digits .

Digits          => [0-9]+

Notes (not necessarily related to the specification):

The unary operations sqrt and are equivalent.

The binary operations mod and % are equivalent.

In the current version multiple-expression programs are not allowed.

About

➗ A command line math expression parser / interpreter.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages