From 921e167594218fdc93d2a89e33e8fe478f269644 Mon Sep 17 00:00:00 2001 From: Tipbs Date: Sun, 14 Jan 2024 22:44:09 +0100 Subject: [PATCH] [FIX] Some syntax error in mdbook --- docs/language-doc/book.toml | 2 +- docs/language-doc/src/SUMMARY.md | 3 +- docs/language-doc/src/conditions.md | 10 ++++++- docs/language-doc/src/function_with_return.md | 8 ++--- docs/language-doc/src/hello_world.md | 6 +--- docs/language-doc/src/if_statements.md | 11 ++----- docs/language-doc/src/introduction.md | 4 +-- docs/language-doc/src/while_statements.md | 30 +++++++++++++++++++ 8 files changed, 51 insertions(+), 23 deletions(-) create mode 100644 docs/language-doc/src/while_statements.md diff --git a/docs/language-doc/book.toml b/docs/language-doc/book.toml index a8271eb..20b7829 100644 --- a/docs/language-doc/book.toml +++ b/docs/language-doc/book.toml @@ -3,4 +3,4 @@ authors = ["MizuriGit"] language = "en" multilingual = false src = "src" -title = "Documentation of our super language" +title = "Documentation of Kope language" diff --git a/docs/language-doc/src/SUMMARY.md b/docs/language-doc/src/SUMMARY.md index ed03db7..dc2effc 100644 --- a/docs/language-doc/src/SUMMARY.md +++ b/docs/language-doc/src/SUMMARY.md @@ -9,4 +9,5 @@ - [Function that returns a value](./function_with_return.md) - [Conditions](./conditions.md) - [If Statements](./if_statements.md) - - [Lists](./lists.md) + - [While Statements](./while_statements.md) + diff --git a/docs/language-doc/src/conditions.md b/docs/language-doc/src/conditions.md index 90ceaa2..05362a8 100644 --- a/docs/language-doc/src/conditions.md +++ b/docs/language-doc/src/conditions.md @@ -7,7 +7,7 @@ This language cover a various number of operators returning boolean values - `a > b` greater thané - `a >= `greater than or equal to b - `a == b` equal to -- `a != b` not equal to +- `a /= b` not equal to Their use is pretty straight forward, you can get the boolean value and store it as a variable or use it in **if statements** @@ -16,4 +16,12 @@ var value = 1 == 2; // value == false ``` +Condition can be combined thanks to this operator: +- `a && b` and +- `a || b` or +``` +var value = 1 == 2 || true == true; +// value == true +``` + As we said earlier, they can be use in **if statements**, check out next page... diff --git a/docs/language-doc/src/function_with_return.md b/docs/language-doc/src/function_with_return.md index 7139025..17536a9 100644 --- a/docs/language-doc/src/function_with_return.md +++ b/docs/language-doc/src/function_with_return.md @@ -4,19 +4,19 @@ As said on the [Hello world! page](./hello_world.md), functions can return value #### **`main.kop`** ``` -int sum(x, y) +fn sum(x, y) { return x + y; } -int main(argc, argv) +fn main() { var x = 5; var y = 8; var z = sum(x, y); - print(z) - print(sum(z, x)) + print(z); + print(sum(z, x)); } ``` diff --git a/docs/language-doc/src/hello_world.md b/docs/language-doc/src/hello_world.md index 1d44145..63e3228 100644 --- a/docs/language-doc/src/hello_world.md +++ b/docs/language-doc/src/hello_world.md @@ -23,17 +23,13 @@ The `main` function is the function that is being executed first, so if we want #### **`main.kop`** ``` -fn main(argc, argv) +fn main() { print("Hello world!\n"); } ``` There you go, Hello world! -The `main` function takes 2 arguments: -- `argc`, being the number of arguments passed from the command line -- `argv`, being an array containing the arguments passed from the command line - The `print` function takes 1 argument, here a string, that is gonna be written to the screen. The `\n` at the end of the string means that we want to add a new-line at after the text. Now that we have created our `main` function printing "Hello world!" to the terminal, we need to compile and run our code, head up to the next part to learn how! diff --git a/docs/language-doc/src/if_statements.md b/docs/language-doc/src/if_statements.md index bc5dc15..836ae1f 100644 --- a/docs/language-doc/src/if_statements.md +++ b/docs/language-doc/src/if_statements.md @@ -5,9 +5,7 @@ Usage of if statements is pretty straight forward and easy to use. ``` if (condition) { ... -} else { - ... -} +}; ``` If you'd like to see a real example @@ -17,11 +15,8 @@ If you'd like to see a real example fn main(argc, argv) { if (4 > 9) { - print("It is true!") - } else { - print("It is false!") - } -} + print("It is true!"); + }; ``` To learn how to compile the file, [check this out!](./compile_and_run.md) diff --git a/docs/language-doc/src/introduction.md b/docs/language-doc/src/introduction.md index 067e87f..34629f8 100644 --- a/docs/language-doc/src/introduction.md +++ b/docs/language-doc/src/introduction.md @@ -1,5 +1,3 @@ # Introduction -Welcome to the documentation for GLaDOS, a custom language created in Haskell that allows users to write programs in the kope syntax. - -GLaDOS simplifies the process of creating and running programs by seamlessly translating kope-syntax-coded programs into WebAssembly, an industry-standard binary instruction format. This allows for cross-platform compatibility and efficient execution of code. +Welcome to the documentation for Kope, our language inspired by C and javascript and compiled in WebAssembly by our GlaDOS Project. diff --git a/docs/language-doc/src/while_statements.md b/docs/language-doc/src/while_statements.md new file mode 100644 index 0000000..68c0ae1 --- /dev/null +++ b/docs/language-doc/src/while_statements.md @@ -0,0 +1,30 @@ +# While Statements + +Usage of while statements is pretty straight forward and easy to use. + +``` +while (condition) { + ... +}; +``` + +If you'd like to see a real example + +#### **`main.kop`** +``` +fn main(argc, argv) +{ + var i = 0 + print("Here are all digit: ") + While (i < 10) { + print(i); + print(" "); + }; +``` + +To learn how to compile the file, [check this out!](./compile_and_run.md) + +```sh +> ./GLaDOS -r executable +Here are all digit: 1 2 3 4 5 6 7 8 9 +```