8000 GitHub - InnoFang/calc: 🎫A simple interpreter & command-line calculator written in Kotlin
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ calc Public

🎫A simple interpreter & command-line calculator written in Kotlin

License

Notifications You must be signed in to change notification settings

InnoFang/calc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

calc

A simple command-line calculator written in Kotlin

PS this is a practice project of an interpreter, to implement a command-line calculator, I design a series of grammar to do so instead of using reverse Polish notation (RPN)

Grammar

expr   : factor (( PLUS | MINUS) factor) *
term   : factor (( MUL  | DIV  ) factor) *
factor : (PLUS | MINUS) factor | INTEGER | LPAREN expr RPAREN

Usage

open your terminal, and type

> $ git clone git@github.com:InnoFang/calc.git
> $ cd calc
> $ gradle build

Then, there is a file named calc-1.0.0.jar in the build/libs

> $ cd build/libs
> $ java -jar calc-1.0.0.jar

Example

you can use like this

calc> 12
12
calc> 34 * 56
1904
calc> 1234 + 87123 - 19283
69074
calc> 22 * 12 - 172 + 56
148
calc> 345 / 5 * ( 234 - 92 ) + 66
9864
calc> 1 ------------ 2
3
calc> 2 ++++-----+++ 3
-1

Reference

this project gave me inspiration and idea, as well as help me a lot, thanks

       Copyright 2018 InnoFang

       Licensed under the Apache License, Version 2.0 (the "License");
       you may not use this file except in compliance with the License.
       You may obtain a copy of the License at

           http://www.apache.org/licenses/LICENSE-2.0

       Unless required by applicable law or agreed to in writing, software
       distributed under the License is distributed on an "AS IS" BASIS,
       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       See the License for the specific language governing permissions and
       limitations under the License.

About

🎫A simple interpreter & command-line calculator written in Kotlin

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0