From 40a7d1d3c3fe1f8956dea25f84f8d7da70a88305 Mon Sep 17 00:00:00 2001 From: Natapat Samutpong Date: Sun, 13 Mar 2022 16:21:33 +0700 Subject: [PATCH] some more docs for contributors --- README.md | 15 +++++++++++++++ crates/hir/src/lib.rs | 5 ++++- example/hello_world.hz | 4 ---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8d4f477..57792cf 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,17 @@ end; Note: Everything in this project can be changed at anytime! (I'm still finding out what work best for lots of thing) if you have an idea, feel free to create an issues about it, or even create a PR! (I'd be very happy) +# Contributing +Found a bug? Found a better way to do something? Make a pull request or tell me in the issues tab! Anything contributions helps :D + +Wanna see how it works under the hood? see the [How it works](https://github.com/azur1s/hazure#how-it-works) tab, you should probably understand it a bit more. + +Steps to build: +1) Clone this repo `https://github.com/azur1s/hazure.git` +2) Run `sudo make build-lib` to build the library (for the transpiled output) +3) Build executable `cargo build` +4) Try running some examples! `path/to/executable compile path/to/file.hz` + # How it works ``` Source (.hz) @@ -64,6 +75,10 @@ Note: Everything in this project can be changed at anytime! (I'm still finding o - `make` for Makefile - Rust (if you're going to build from source) +# Problems +This is the problem(s) of the language I found throughout while developing it +- Diagnostics stuff only report one error, maybe because of the early return when errors make it only return after first error. Fix is maybe make an error type and continue doing it stuff even if found the error. (Fixable) + # Configuration You can also configurate Hades compiler (currently you can only change the C++ compiler). Make a new file called `hades.toml` in the current working directory and the compiler will look for it! if there isn't one then it will use the default configuration: ```toml diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 8259bfc..f4df607 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -116,12 +116,13 @@ pub fn expr_to_ir(expr: &Expr) -> (Option, Option) { _ => return (None, Some(LoweringError { span: name.1.clone(), message: "Expected identifier".to_string(), note: None })) }; - // Remove all `Hole`(s) from the args + // Get the index where the `Hole` is at let index = args.0.iter().position(|arg| match arg.0 { Expr::Hole(..) => true, _ => false }); + // If there is no `Hole` in the args then return early if let None = index { return (None, Some(LoweringError { span: rhs.1.clone(), @@ -130,6 +131,7 @@ pub fn expr_to_ir(expr: &Expr) -> (Option, Option) { })); } + // Remove the `Hole` from the args let mut new_args = args.0.clone(); new_args.remove(index.unwrap()); @@ -152,6 +154,7 @@ pub fn expr_to_ir(expr: &Expr) -> (Option, Option) { let mut largs = Vec::new(); for arg in &args.0 { match arg.0 { + // If the arg is a `Hole` then replace it with the lowered IR Expr::Hole(..) => { largs.push(lhs_ir.0.clone().unwrap()); }, diff --git a/example/hello_world.hz b/example/hello_world.hz index 0a20682..5fddf4f 100644 --- a/example/hello_world.hz +++ b/example/hello_world.hz @@ -2,8 +2,4 @@ fun main: int = do -- Normal way of hello world @write("Hello, World!\n"); return 69; - - -- Hello world piped to @write() function - "Hello, World!\n" - |> @write(); end; \ No newline at end of file