Skip to content

Commit

Permalink
update: add web build instructions, preview
Browse files Browse the repository at this point in the history
  • Loading branch information
luckasRanarison committed Apr 25, 2023
1 parent 7ab4c97 commit 20bcff6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 145 deletions.
Binary file added .github/img/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 33 additions & 145 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,148 +4,13 @@

Icelang is a minimal, dynamically-typed scripting language inspired by Lua and Rust. It is my first attempt at writing a tree-walking interpreter and also my first Rust project. As you might expect, it was not intended for serious use. It is not fast or efficient, but it is decent enough for basic computation.

Icelang is available online through a Web Assembly port of the interpreter, try it now [here](https://luckasranarison.github.io/icelang/)!
Check out the [website](https://luckasranarison.github.io/icelang/) for more details about the language specifications. Icelang is also available online through a Web Assembly port of the interpreter, try it now [here](https://luckasranarison.github.io/icelang#playground).

## Overview
## Preview

See [examples](./examples/) to see some of the features in action.

```sql
-- icelang syntaxes 🥶
-- Designed to be minimal and concise, inspired by lua and rust

-- inline comment

-- some conventions:
-- filename ends with .ic
-- semicolon ';' is optional
-- both ' and " can be used to create strings
-- sanke case for identifiers

<--
This
is
a
multi
line
comment
-->

-- module system
set default_import = import("module_name"); -- default import
set component = import("module_name").prop; -- import a specific object prop
set component_with_path = import("../module_name"); -- unix like path

-- data types
set string = "Hello World";
set integer = 123;
set float = 1.2;
set bool = true;
set range = 0 to 5; -- non inclusive
set array = [1, 2, 3, 4];
set undefined = null;
set object = {
prop: "value",
another: 1,
method: lambda() {
print(self.prop);
}
}

-- operators
-- arithmetic
-- + - * / % += -= *= /= %=
-- logic
-- ! == != > < >= <= and or

-- function (hoisted)
function hello(name) {
print("Hello " + name);
}

-- lambda function
set lambda_function = lambda(name) {
print("Hello " + name);
}

-- loops
for i in 0 to 5 {
print("Hello World");
}

-- collection loop
-- number, string, array and object
for key, value in object {
print(key + ": " + value);
}

set i = 1;

while(i <= 5) {
print("Hello World");
i += 1;
}

set i = 1;

loop {
i += 1;

if (i >= 5) {
break;
}
}

set cond_1 = true;
set cond_2 = false;

-- conditionals
if (cond_1 and cond_2) {
print("no");
} else if (cond_1) {
print("yes");
} else {
print("yes");
}

-- conditionals are expressions
set n = if (true) { 1 } else { 0 }

set a = 1;

match(a) {
0, 4, 1: a = a + 2,
2: {
print("unreachable");
},
_: {
print("Default");
},
}

-- some builtin functions
-- I/O
print("Hello World");
set input = readline();

-- Utility
type_of(a);
parse_number("1");
length("hello");

-- Math
sqrt(8);
pow(2, 5);
floor(2.5);
round(2.5);
ceil(2.5);

-- module export
set my_var = "some text";

-- only one export per file is allowed
export(my_var);
```
![REPL Preview](./.github/img/preview.png)

## Usage

Expand All @@ -160,23 +25,46 @@ icelang script.ic # to run a file

**NB: You must have the rust tool chain installed.**

Clone the repository and then enter the following commands.
### Icelang executable

To build the icelang executable you have to clone the repository then enter the following commands:

```bash
cargo install --path . # install dependencies
cargo build --release
```

## Todo
### Website and WASM binaries

Some add-ons not directly related to the project itself:
To build the website you must have npm and wasm-pack installed.

```bash
cargo install --path . # install dependencies
cd wasm/
wasm-pack build --target web --out-dir ../website/pkg # build the wasm binaries
cd ../website/
npm install # install dependencies
npm run build # vite build
```

- [x] WASM Playground
You can run `npm run dev` to start a local server at https://localhot:5173

- [ ] Vscode semantic highlight extension
## Testing

You can run the tests by running:

```bash
cargo test --workspace --lib
```

## Todo

Some add-ons not directly related to the project itself:

- [ ] Bytecode interpreter
- [x] WASM Playground

- [ ] Language server and Vscode client
- [ ] Vscode semantic highlight extension

- [ ] Bytecode interpreter

- [ ] Language server and Vscode client

0 comments on commit 20bcff6

Please sign in to comment.