Browse Source

Add "contributing" docs

github-actions
Garrit Franke 3 years ago
parent
commit
c0fa388a50
  1. 1
      docs/SUMMARY.md
  2. 21
      docs/concepts/datatypes.md
  3. 7
      docs/concepts/variables.md
  4. 1
      docs/developers/SUMMARY.md
  5. 17
      docs/developers/contributing.md
  6. 13
      docs/introduction/hello-world.md

1
docs/SUMMARY.md

@ -8,3 +8,4 @@
- [Data Types](./concepts/datatypes.md) - [Data Types](./concepts/datatypes.md)
- [Developer Resources](./developers/SUMMARY.md) - [Developer Resources](./developers/SUMMARY.md)
- [Backends](./developers/backends.md) - [Backends](./developers/backends.md)
- [Contributing to Sabre](./developers/contributing.md)

21
docs/concepts/datatypes.md

@ -1,21 +1,20 @@
# Datatypes # Datatypes
> **Note:** Due to the fact that Sabre currently emits javascript, static types are not needed, as of yet. They will however be introduced soon, once a statically typed backend is used. Sabre comes with some generic data types.
## The Integer type ## The Integer type
The `integer` datatype represents a number. The JavaScript backend interprets any integer as a `Number` type. The `integer` datatype represents a 4 byte decimal number.
``` ```
fn main() { fn main() {
let sum = 1 + 2 let sum: int = 1 + 2
println("1 + 2 is ", sum) println("1 + 2 is ", sum)
} }
``` ```
``` ```
$ sabre build main.sb -o main.js $ sabre run main.sb
$ node main.js
1 + 2 is 3 1 + 2 is 3
``` ```
@ -25,14 +24,13 @@ A string is a sequence of characters.
``` ```
fn main() { fn main() {
let name = "Jon" let name: string = "Jon"
println("Hello " + name) println("Hello " + name)
} }
``` ```
``` ```
$ sabre build main.sb -o main.js $ sabre run main.sb
$ node main.js
Hello Jon Hello Jon
``` ```
@ -40,11 +38,9 @@ Hello Jon
Arrays represent a sequence of values. They can hold any number of values of a specific type. Arrays represent a sequence of values. They can hold any number of values of a specific type.
> **NOTE:** Currently, there is no type-checking involved when creating arrays. There will be, once a type system is in place, so don't get too attached to mixing and matching element types. ;)
``` ```
fn main() { fn main() {
let fruits = ["Banana", "Apple", "Pineapple"] let fruits: string[] = ["Banana", "Apple", "Pineapple"]
for fruit in fruits { for fruit in fruits {
println(fruit) println(fruit)
@ -53,8 +49,7 @@ fn main() {
``` ```
``` ```
$ sabre build main.sb -o main.js $ sabre run main.sb
$ node main.js
Banana Banana
Apple Apple
Pineapple Pineapple

7
docs/concepts/variables.md

@ -2,13 +2,13 @@
If you are familiar with some other programming language, the way Sabre handles variables won't surprise you. If you are familiar with some other programming language, the way Sabre handles variables won't surprise you.
To declare a variable, the `let` keyword is used. To declare a variable, the `let` keyword is used. The type of the variable is infered, but can be specified explicitly.
``` ```
// variables.sb // variables.sb
fn main() { fn main() {
let x = 10 let x = 10
let y = 5 let y: int = 5
println(x + y) println(x + y)
} }
``` ```
@ -16,7 +16,6 @@ fn main() {
Run this code using the sabre CLI: Run this code using the sabre CLI:
``` ```
$ sabre build variables.sb -o variables.js $ sabre run variables.sb
$ node variables.js
15 15
``` ```

1
docs/developers/SUMMARY.md

@ -0,0 +1 @@
This chapter includes resources that might be helpful for developers hacking on the Sabre compiler.

17
docs/developers/contributing.md

@ -0,0 +1,17 @@
# Contributing
The easiest way to contribute to the Sabre project is by writing code in the language. The more the language is battle-tested, the more bugs can be found and therefore the language becomes more stable.
## Getting in touch
If you want to submit a patch, file a bug, suggest a feature or have questions about something, please send a mail to the [public mailing list](https://lists.sr.ht/~garritfra/sabre) of the project.
## Fixing things and adding features
If you want to contribute to the compiler itself, the easiest way to get started is to look at the `TODO` file at the root of the project. Usually, this is where important todo items are jotted down.
You could also run the tests (`cargo test`) and see if any tests are ignored. Usually, if a bug is found in the wild, a failing but ignored test is written, so that it can be further investigated later.
## Submitting your code
Development should happen on [SourceHut](https://sr.ht/~garritfra/sabre/). If you want to contribute code, please send a patch to the [public mailing list](https://lists.sr.ht/~garritfra/sabre). If you don't feel confortable with the [patch-based workflow](https://slashdev.space/posts/patch-based-git-workflow) yet, you can also open a pull request in the [GitHub mirror](https://github.com/garritfra/sabre).

13
docs/introduction/hello-world.md

@ -25,19 +25,10 @@ fn main() {
} }
``` ```
Save the file and go back to your terminal window. Now, run the following command to compile your program: Save the file and go back to your terminal window. Now, run the following command to compile and run your program:
``` ```
sabre build main.sb -o main.js sabre run main.sb
```
> **Note:** JavaScript is the only currently supported backend for Sabre. There will be more soon.
Now, execute the compiled program with a runtime of your choice. We will be using Node.js for this example.
```
> node main.js
Hello, world!
``` ```
You should see the string `Hello World!` on the screen. Congrats! You have officially written a Sabre Program! You should see the string `Hello World!` on the screen. Congrats! You have officially written a Sabre Program!

Loading…
Cancel
Save