From d0000f52adf555638f5325aa07163e13ffb8edff Mon Sep 17 00:00:00 2001 From: KPMGE Date: Sat, 23 Mar 2024 16:48:33 -0300 Subject: [PATCH] :page_facing_up: update readme --- README.md | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 38f7a95..9428403 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,80 @@ # kl-rs That's an implementation of a interpreter for my own programming language, -called kl-rs(kevin's language), the postfix is of course, cuz i'll be using -rust! +called kl-rs(kevin's language), the postfix is of course because i will be using +rust as its host language! + +## Language +This language is hightly expression-based, but there are 2 types of statements +in it: `return` statements and `let` statements. Everything else is an +expression! + +That has some interesting implications, we can bind any expresion to a name +using the `let` statement, so we can do stuff like this for example: + +```bash +let result = if () { } else { } +``` + +This works because the if statement itself is an expression, so the block of +code that is evaluated generates an expresion value, which is in turn binded to +the result variable! + +### Keywords +This is a really simple language with just a few keywords: `let`, `return`, +`fn`, `else`, `if`, `false`, `true`. + +#### Defining functions +To define a function, as it is an expresion, we can just use a bind: + +```bash +let foo = fn(params...) { } +``` + +but we can also create clojures quite easily: + +```bash +let foo = fn(params...) { } +foo(fn(...) {}) +``` + +In the example above, we're defining the `foo` function and running it with an +unnamed function, a clojure. + + +## How to run it? +In order to run this project on you machine, first make sure you got [rust](https://www.rust-lang.org/) +correctly installed. + +Then, you can run it directly using cargo with the following command: + +```bash +cargo run +``` + +Afterwards, a REPL will appear and you can start writing kl-rs code! + +There are a couple flags that you can use to inspect this program, you can see +all of them using the command: + +```bash +cargo run -- -h +``` + + +## How to build it? +Building this project is extremely straightforward, you just run: + +```bash +cargo build --release +``` + +After that, an executable will be generated in the folder +`target/release/kl-rs`, then you can just use it like normal + + +## TODOS +- [ ] Add standard library +- [ ] Add loops +- [ ] Add support for arrays +- [ ] Add build in functions +- [ ] Add support for hashes