https://github.com/1git2clone/compiler-in-rust
https://github.com/1git2clone/compiler-in-rust
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/1git2clone/compiler-in-rust
- Owner: 1Git2Clone
- License: mit
- Created: 2024-12-14T14:52:12.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-14T14:54:48.000Z (about 1 year ago)
- Last Synced: 2025-04-10T02:48:35.884Z (9 months ago)
- Language: Rust
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Compiler in Rust
[![Build Icon]][Build Status] [![License Icon]][LICENSE]
[Build Icon]: https://img.shields.io/github/actions/workflow/status/1git2clone/compiler-in-rust/rust.yml?branch=main
[Build Status]: https://github.com/1git2clone/compiler-in-rust/actions?query=branch%3Amain
[License Icon]: https://img.shields.io/badge/license-MIT-blue.svg
[LICENSE]: LICENSE
## Description
By some this could be could be considered an interpreter, in fact, you can use
it as one if you want to.
Currently supports the following features:
- [x] Addition
- [x] Subtraction
- [x] Multiplication
- [x] Division
- [x] Parentheses (_`(!) Partially`_)
It **doesn't** support:
- [ ] Nested parentheses
- [ ] Named variables
- [ ] Data types (different from `i32`'s)
### The bottom line
An over-glorified calculator.
## Getting started
You can add it as a git dependency in your `Cargo.toml` file. This project
isn't really meant to be a crate though, so expect breaking changes.
```toml
# /Cargo.toml
[dependencies]
compiler = { git = "https://github.com/1Git2Clone/compiler-in-rust/" }
```
```rs
// /src/main.rs
use compiler::prelude::*;
fn main() -> Result<(), Error> {
println!("{}", compile(&parse(&tokenize("(3 + 2) * 6")?)?.unwrap())); // 30
}
```
> [!NOTE]
> This "compiler" is very limited, first of all it doesn't handle nested
> parentheses, nor named variables, nor any values other than `i32`.