rscmm

Crates.iorscmm
lib.rsrscmm
version0.3.1
sourcesrc
created_at2022-01-10 06:20:40.29139
updated_at2022-01-10 06:58:15.149695
descriptionA Simple C-interpreter
homepage
repositoryhttps://github.com/mkchaos/rscmm/
max_upload_size
id511206
size81,774
(mkchaos)

documentation

README

RSCMM

  1. A C language Interpreter Library.
  2. A practice project to educate myself.
  3. RSCMM is a combine of Rust & CMM. CMM is contrary to CPP, means less than C.

Pipeline


Including RSCMM in your project

[dependencies]
rscmm = "0.3"

Implementation

src folder

  • parser in src/core/parser
  • semantic_analyzer in src/core/analyzer
  • compiler in src/core/compiler
  • vm in src/core/vm vm is used to run codes after compiling.

functionality

  • ops: + - * / % && || ! == != <= >= < >
  • funcs: declare, impls, recursive
  • types: int, void
  • controls: if & while

Example

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int main() {
    int p = gcd(99, 90);
    p;   // single variable statement means print.
}
// Run example
rscmm::compile_and_run("example/gcd.c").unwrap();
// Get vm codes
rscmm::compile_to_code("example/gcd.c").unwrap();
Commit count: 55

cargo fmt