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

125 lines
2.9 KiB
Markdown
Raw Normal View History

2022-03-11 20:52:24 -06:00
# Hazure
2022-03-15 19:36:39 -05:00
Programming language that compiles to Typescript!
2022-02-25 02:59:17 -06:00
2022-03-12 17:47:31 -06:00
```sml
2022-03-15 19:36:39 -05:00
fun main: void = do
2022-03-15 19:57:28 -05:00
@write("Hello, World!");
2022-03-11 19:39:37 -06:00
end;
```
2022-03-18 21:53:33 -05:00
or with the pipeline operator:
2022-03-12 17:47:31 -06:00
```sml
2022-03-15 19:36:39 -05:00
fun main: void = do
2022-03-12 17:46:50 -06:00
"Hello, World!\n"
2022-03-12 23:49:00 -06:00
|> @write(_);
2022-03-12 17:46:50 -06:00
end;
```
2022-03-12 19:45:58 -06:00
2022-03-06 14:53:44 -06:00
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)
2022-02-12 08:28:56 -06:00
2022-03-15 19:36:39 -05:00
# Prerequistie
- `deno`
- Rust (if you're going to build from source)
2022-03-13 04:21:33 -05:00
# 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
Steps to build:
1) Clone this repo `https://github.com/azur1s/hazure.git`
2022-03-15 19:36:39 -05:00
2) Build executable `cargo build`
3) Try running some examples! `path/to/executable compile path/to/file.hz`
2022-03-13 04:21:33 -05:00
2022-03-18 22:32:15 -05:00
# 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;
```
is the same as
```sml
fun main: void = do @write("Hello, World!"); end;
2022-03-13 00:14:13 -06:00
```
2022-03-18 22:32:15 -05:00
Hazure is also [expression-oriented](https://en.wikipedia.org/wiki/Expression-oriented_programming_language) like OCaml. There are currently 10 expressions:
1) Comment
```
-- Comment!
-{ Block Comment }-
```
2) Values / Types
```sml
1
true
"string"
variable
```
3) Unary and Binary
```sml
1 + 2
!true
```
4) Call and Intrinsic. Intrinsic starts with a `@`
```sml
@write("Hello")
foo("bar")
```
5) Pipeline
```sml
"Hello, World" |> @write(_)
```
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;
2022-03-11 18:14:01 -06:00
```
2022-02-25 04:03:55 -06:00
# License
2022-03-15 19:36:39 -05:00
Hazure is licensed under both [MIT license](https://github.com/azur1s/hazure/blob/master/LICENSE-MIT) and [Apache License](https://github.com/azur1s/hazure/blob/master/LICENSE-APACHE)