Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tteeoo/aetg
➗ Arithmetic expression tree generator (essentially a simple calculator in the command line)
https://github.com/tteeoo/aetg
arithmetic calculator command-line go golang math parser syntax-tree tree tree-structure
Last synced: about 2 months ago
JSON representation
➗ Arithmetic expression tree generator (essentially a simple calculator in the command line)
- Host: GitHub
- URL: https://github.com/tteeoo/aetg
- Owner: tteeoo
- License: mit
- Created: 2020-06-21T23:22:38.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-23T00:31:53.000Z (over 4 years ago)
- Last Synced: 2024-06-20T19:20:29.713Z (7 months ago)
- Topics: arithmetic, calculator, command-line, go, golang, math, parser, syntax-tree, tree, tree-structure
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aetg
Inspired by [this video](https://www.youtube.com/watch?v=7tCNu4CnjVc).
`aetg` is essentially just a simple calculator with an annoying syntax.
This is mainly just a small project I made to get experience with making trees (and parsing) in Go.
# Usage
`aetg` parses arithmetic expressions into a tree of sub expressions that it then evaluates.Since I am new to writing lexers/parsers, `aetg` uses a very strict format to notate expressions that is easy to tokenize.
Run the compiled `aetg` binary to enter a shell in which you can type expressions.
Notation is as follows:
`( operator )`
Examples:
`(5 * (3 - 6))`
`(((8.11 + -7) ^ 3) - ((2 | 4) * (5.23 / (5 % 2))))`
The following operators are supported:
* `+` Addition
* `-` Subtraction
* `*` Multiplication
* `/` Division
* `^` Exponentiation
* `%` Modulus
* `|` Radical (`(2 | number)` for square root, etc.)### Flags
* `--version` Display version information
* `--verbose` Print expressions after parsing
* `--file ` Read and run an expression from a file
* `--expr ` Run a specific expression without going into the shell# Installation
It's just a single binary.
You can compile with `go build`.
A [Linux binary](https://github.com/tteeoo/aetg/releases/download/0.1.0/aetg-linux) is provided.
# License
All files are licensed under the MIT License