From c0fa388a50c1fa95beb054d62d0aacd057ff2b89 Mon Sep 17 00:00:00 2001 From: Garrit Franke Date: Thu, 17 Dec 2020 16:05:18 +0100 Subject: [PATCH] Add "contributing" docs --- docs/SUMMARY.md | 1 + docs/concepts/datatypes.md | 21 ++++++++------------- docs/concepts/variables.md | 7 +++---- docs/developers/SUMMARY.md | 1 + docs/developers/contributing.md | 17 +++++++++++++++++ docs/introduction/hello-world.md | 13 ++----------- 6 files changed, 32 insertions(+), 28 deletions(-) create mode 100644 docs/developers/contributing.md diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 3ece72c..fc090fc 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -8,3 +8,4 @@ - [Data Types](./concepts/datatypes.md) - [Developer Resources](./developers/SUMMARY.md) - [Backends](./developers/backends.md) + - [Contributing to Sabre](./developers/contributing.md) diff --git a/docs/concepts/datatypes.md b/docs/concepts/datatypes.md index 5bb6bc0..405712f 100644 --- a/docs/concepts/datatypes.md +++ b/docs/concepts/datatypes.md @@ -1,21 +1,20 @@ # 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` 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() { - let sum = 1 + 2 + let sum: int = 1 + 2 println("1 + 2 is ", sum) } ``` ``` -$ sabre build main.sb -o main.js -$ node main.js +$ sabre run main.sb 1 + 2 is 3 ``` @@ -25,14 +24,13 @@ A string is a sequence of characters. ``` fn main() { - let name = "Jon" + let name: string = "Jon" println("Hello " + name) } ``` ``` -$ sabre build main.sb -o main.js -$ node main.js +$ sabre run main.sb 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. -> **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() { - let fruits = ["Banana", "Apple", "Pineapple"] + let fruits: string[] = ["Banana", "Apple", "Pineapple"] for fruit in fruits { println(fruit) @@ -53,8 +49,7 @@ fn main() { ``` ``` -$ sabre build main.sb -o main.js -$ node main.js +$ sabre run main.sb Banana Apple Pineapple diff --git a/docs/concepts/variables.md b/docs/concepts/variables.md index 322424d..9a40b12 100644 --- a/docs/concepts/variables.md +++ b/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. -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 fn main() { let x = 10 - let y = 5 + let y: int = 5 println(x + y) } ``` @@ -16,7 +16,6 @@ fn main() { Run this code using the sabre CLI: ``` -$ sabre build variables.sb -o variables.js -$ node variables.js +$ sabre run variables.sb 15 ``` diff --git a/docs/developers/SUMMARY.md b/docs/developers/SUMMARY.md index e69de29..104fa3d 100644 --- a/docs/developers/SUMMARY.md +++ b/docs/developers/SUMMARY.md @@ -0,0 +1 @@ +This chapter includes resources that might be helpful for developers hacking on the Sabre compiler. diff --git a/docs/developers/contributing.md b/docs/developers/contributing.md new file mode 100644 index 0000000..1545b72 --- /dev/null +++ b/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). diff --git a/docs/introduction/hello-world.md b/docs/introduction/hello-world.md index 7a73a63..4163e03 100644 --- a/docs/introduction/hello-world.md +++ b/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 -``` - -> **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! +sabre run main.sb ``` You should see the string `Hello World!` on the screen. Congrats! You have officially written a Sabre Program!