Skip to content

Commit

Permalink
More documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Luukdegram committed Sep 1, 2020
1 parent 530342c commit a3394d5
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Linux
name: Windows

on:
push:
Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTING
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
All contributions are welcome, both small and large. Before creating a Pull Request, please first check openstanding issues and other PR's to ensure nobody else is already working on it.
Checking issues also helps fixing bugs faster, which allows me to work on new features.

All contributions towards the Luf language require tests. If a bug was found and fixed, a test is required to verify its functionality but also ensures all edge cases are handled.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Luf is a statically typed embeddable scripting language written in [Zig](https:/
The goal of this project is to create a simple, expressive scripting language that can be used to implement new ideas. As most of it is experimental, I would currently not recommend this for any serious use.

## Resources
- Examples (TODO)
- Documentation (TODO)
- [Examples](examples/README.md)
- [Documentation](docs/README.md)
- [Building from source](#building-from-source)
- Contributing (TODO)
- [Contributing](CONTRIBUTING)
- [Editor Support](#editor-support)

## Building from source
Expand Down
75 changes: 75 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Introduction
Currently this is a living document as there's still alot to define and write down regarding the Luf language. However, here you can find the basic internal information regarding its its defintion.
- [Introduction](#introduction)
- [Precedence](#precedence)
- [Arithmetic](#arithmetic)
- [Bytecode](#bytecode)
- [Types](#types)

# Precedence
The order of which expressions are executed is as follow where the highest precedence is executed before a lower precedence.

| Name | Tokens |
| ------------ | ---------------------------- |
| lowest | Expressions not defined here |
| range | `..` |
| or | `or` |
| and | `and` |
| assign | `=`, `+=`, `-=`, `*=`, `/=` |
| equals | `==`, `!=`, |
| less_greater | `<`, `>`, `<=`, `>=` |
| bitwise_or | `|` |
| bitwise_xor | `^` |
| bitwise_and | `&` |
| shift | `<<`, `>>` |
| sum | `+`, `-` |
| product | `%`, `/`, `*` |
| prefix | `!`, `-` (negation), `~` |
| call | `some_function()` |
| index | `.` i.e list.len |

# Arithmetic
Please note that not all arithmetic has yet been implemented. There's still a few assign-and-op shorthands missing

| Name | Syntax | Types |
| ------------------ | ------------- | ----------------------- |
| Addition | a + b, a += b | `int`, `string` |
| Substraction | a - b, a -= b | `int` |
| Multiplication | a * b, a *= b | `int` |
| Division | a / b, a =/ b | `int` |
| Remainder division | a % b | `int` |
| Negation | -a | `int` |
| Bitwise xor | a ^ b | `int` |
| Bitwise or | a &#124; b | `int` |
| Bitwise and | a & b | `int` |
| Bitwise not | ~a | `int` |
| Shift left | a << b | `int` |
| Shift right | a >> b | `int` |
| and | a and b | `bool` |
| or | a or b | `bool` |
| not bool | !a | `bool` |
| equal | a == b | `bool`, `int`, `string` |
| Not equal | a != b | `bool`, `int`, `string` |
| Greater than | a > b, a >= b | `int` |
| Less than | a < b, a <= b | `int` |

# Bytecode

All VM instructions are 24 bits.
The first bit of the instruction contains the opcode,
where the remaining 16 bits can be used to point to another instruction or define a parameter. For example, it can contain the value `2` to the opcode `make_array` to specify its length.

All instructions with its definitions will be documented here soon™.

# Types

Currently the following types are implemented.
| syntax | Notes |
| -------------- | ---------------------------------------------------- |
| int | 64 bit **signed** integer |
| string | utf-8 encoded list of characters |
| bool | native zig boolean (u1) |
| [5]type | list of type of length 5 |
| [5]type1:type2 | map with type1 as key and type2 as value of length 5 |

In the future users can specify their own Types using composable Structs.
14 changes: 14 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Examples

This folder contains simple examples.
Each example can be run by specifying the file name without the `.luf` extension:
```
zig build examples -Dexample=example_file_name
```

For example, to run the loops example use the following command:
```
zig build examples -Dexample=loops
```

More complex and feature-rich examples will be added as the language evolves. Feel free to submit a PR if you have an example you'd like to share.

0 comments on commit a3394d5

Please sign in to comment.