https://github.com/frozen/sprout
Assignment:
https://github.com/frozen/sprout
Last synced: about 1 year ago
JSON representation
Assignment:
- Host: GitHub
- URL: https://github.com/frozen/sprout
- Owner: Frozen
- Created: 2020-07-24T16:29:01.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-24T17:51:36.000Z (almost 6 years ago)
- Last Synced: 2025-01-30T09:41:39.105Z (over 1 year ago)
- Language: Rust
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
```bash
rustup override set nightly
cargo run
```
#### tokenize.rs
Splits input string into tokens
#### base1.rs
Evaluation logic for exprs like `A && B && !C => H = M`
#### base2.rs
Logic for exprs like `H = M => K = D + (D * E / 10)`
#### expr.rs
combines Base1 and Base2
1) Incoming string `A && B && !C => H = M` parses into intermidiate representation like
```rust
vec![Token::A, Token::And, Token::B]; // and so on
```
2) Then it converts into second called `Executable`. Internally it is https://en.wikipedia.org/wiki/Reverse_Polish_notation
3) Is executes...
base1 expressions (a && b) compared by `vec![Token]`
base2 expression (D / F) compares by `H = M`
Api examples in main.rs test mod.
GET: http://localhost:8000/true/true/true/1.0/52/1
POST: http://localhost:8000/true/true/true/1.0/52/1 with data
```json
{"exprs": ["A && B && !C => H = P"]}
```