1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00

Update README.md

This commit is contained in:
Natapat Samutpong 2022-03-19 10:32:15 +07:00
parent d5feadd70b
commit 0288428090

128
README.md
View file

@ -23,50 +23,102 @@ Note: Everything in this project can be changed at anytime! (I'm still finding o
# Contributing # 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 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: Steps to build:
1) Clone this repo `https://github.com/azur1s/hazure.git` 1) Clone this repo `https://github.com/azur1s/hazure.git`
2) Build executable `cargo build` 2) Build executable `cargo build`
3) Try running some examples! `path/to/executable compile path/to/file.hz` 3) Try running some examples! `path/to/executable compile path/to/file.hz`
# How it works # Syntax
> This language is still in development, the syntax can be changed at anytime.
Hazure is a [free-form](https://en.wikipedia.org/wiki/Free-form_language) syntax style, so the indentation is purely for readability.
```sml
fun main: void = do
@write("Hello, World!");
end;
``` ```
Source (.hz)
│ crates/main is the same as
Lexer produce Token ```sml
│ crates/lexer fun main: void = do @write("Hello, World!"); end;
```
Parser produce AST
│ crates/parser Hazure is also [expression-oriented](https://en.wikipedia.org/wiki/Expression-oriented_programming_language) like OCaml. There are currently 10 expressions:
Diagnostic(Parsing) 1) Comment
│ │ crates/diagnostic ```
│ ╰ Fail -> Print error -> Exit -- Comment!
Pass -{ Block Comment }-
```
2) Values / Types
Lowerer(?) produce HIR ```sml
│ crates/hir 1
true
Type Checker (TODO) "string"
│ │ variable
│ ╰ Fail -> Print error -> Exit ```
Pass 3) Unary and Binary
```sml
1 + 2
Diagnostic(Lowering) !true
│ │ crates/diagnostic ```
│ ╰ Fail -> Print error -> Exit 4) Call and Intrinsic. Intrinsic starts with a `@`
Pass ```sml
@write("Hello")
foo("bar")
Codegen produce Typescript ```
│ crates/codegen 5) Pipeline
```sml
Done "Hello, World" |> @write(_)
(filename.ts) ```
6) Variable declaration
```sml
let foo: int = 727;
let bar: string = "Hi";
let baz: boolean = true;
```
7) Function declaration
```sml
fun foo: void = @write("void returns nothing");
fun bar (x: int): int = x + 1;
fun baz (x: int) (y: int): int = x + y;
```
8) If conditions
```sml
let cond: bool = true;
if cond then
@write("True");
else
do
@write("False");
end;
end;
```
9) Case matching
```sml
case 1 + 1 of
| 2 -> @write("Yes");
\ @write("How?");
end;
```
10) Do notation. It allows you to have multiple expression because something like right hand side of the function declaration `fun a: int = ...` can only have 1 expression. Do allows you to bypass that.
```sml
do
@write("Hello, World");
foo(bar);
let baz: int = 6 + 10;
end;
```
Hazure isn't a scripting language, so, you will need a main function.
```sml
fun main: void = do
@write("Hello, World");
@write(34 + 35);
end;
``` ```
# License # License