-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into represent_function
- Loading branch information
Showing
17 changed files
with
351 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Sample workflow for building and deploying a mdBook site to GitHub Pages | ||
# | ||
# To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html | ||
# | ||
name: Deploy mdBook site to Pages | ||
|
||
on: | ||
# Runs on pushes targeting the default branch | ||
push: | ||
branches: ["main", "dev"] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | ||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
# Build job | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
MDBOOK_VERSION: 0.4.36 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install mdBook | ||
run: | | ||
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh | ||
rustup update | ||
cargo install --version ${MDBOOK_VERSION} mdbook | ||
- name: Setup Pages | ||
id: pages | ||
uses: actions/configure-pages@v4 | ||
- name: Build with mdBook | ||
run: mdbook build docs/language-doc | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v2 | ||
with: | ||
path: ./docs/language-doc/book | ||
|
||
# Deployment job | ||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,5 +22,6 @@ cabal.project.local~ | |
.HTF/ | ||
.ghc.environment.* | ||
compile_commands.json | ||
glados-exe | ||
book/ | ||
glados | ||
glados-exe.cabal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[book] | ||
authors = ["MizuriGit"] | ||
language = "en" | ||
multilingual = false | ||
src = "src" | ||
title = "Documentation of our super language" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Summary | ||
|
||
- [Introduction](./introduction.md) | ||
- [Getting started](./getting_started.md) | ||
- [Hello world!](./hello_world.md) | ||
- [Compile and run your program](./compile_and_run.md) | ||
- [Go further](./syntax.md) | ||
- [Variables](./variables.md) | ||
- [Function that returns a value](./function_with_return.md) | ||
- [Conditions](./conditions.md) | ||
- [If Statements](./if_statements.md) | ||
- [Lists](./lists.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Compile and run your program | ||
|
||
Now that we have our file `main.???`, we'll have to compile it using GLaDOS | ||
|
||
### Compile using GLaDOS | ||
|
||
Compiling is pretty straight forward, all we need to do is to give our file to the GLaDOS program and use the `-c` argument | ||
|
||
Let's compile our file `main.???`: | ||
|
||
```bash | ||
> ./GLaDOS -c main.??? | ||
``` | ||
|
||
Well done! Look, there is a new file in our directory: | ||
|
||
```bash | ||
> ls | ||
main.??? exectuable | ||
``` | ||
|
||
### Run using GLaDOS | ||
|
||
Now that you have your executable, you need to use the VM in the GLaDOS program. | ||
|
||
To do so, use this command: | ||
|
||
```bash | ||
> ./GLaDOS -r executable | ||
Hello world! | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Conditions | ||
|
||
This language cover a various number of operators returning boolean values | ||
|
||
- `a < b` less than | ||
- `a <= b` less than or equal to | ||
- `a > b` greater thané | ||
- `a >= `greater than or equal to b | ||
- `a == b` 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** | ||
|
||
``` | ||
var value = 1 == 2; | ||
// value == false | ||
``` | ||
|
||
As we said earlier, they can be use in **if statements**, check out next page... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Function that returns a value | ||
|
||
As said on the [Hello world! page](./hello_world.md), functions can return value that can be used or stored in a variable. | ||
|
||
#### **`main.???`** | ||
``` | ||
int sum(x, y) | ||
{ | ||
return x + y; | ||
} | ||
int main(argc, argv) | ||
{ | ||
var x = 5; | ||
var y = 8; | ||
var z = sum(x, y); | ||
print(z) | ||
print(z + sum(z, x)) | ||
} | ||
``` | ||
|
||
To learn how to compile the file, [check this out!](./compile_and_run.md) | ||
|
||
``` | ||
> ./GLaDOS -r executable | ||
13 | ||
18 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Getting started |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Hello world! | ||
|
||
We'll start off by writing a simple hello world. | ||
|
||
### But first, we'll learn how to create a function. | ||
|
||
``` | ||
fn foobar(a, b) | ||
{ | ||
... | ||
} | ||
``` | ||
- `fn` tells the code that a function is being created. | ||
- `foobar` is the name of the function, choose whatever you want. | ||
- `(a, b)` are the function arguments, define them using the parenthesis, then give them a name (here `a` and `b`) | ||
- `{ ... }` open the function, that's where your code will go | ||
|
||
Functions can also return a value using the `return` keyword followed by a value (example: `return 4`. | ||
|
||
### Alright, now that you know how to create a function, let's introduce the `main` function. | ||
|
||
The `main` function is the function that is being executed first, so if we want to write a Hello world!, then we'll have to create a main function: | ||
|
||
#### **`main.???`** | ||
``` | ||
fn main(argc, argv) | ||
{ | ||
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# If Statements | ||
|
||
Usage of if statements is pretty straight forward and easy to use. | ||
|
||
``` | ||
if (condition) { | ||
... | ||
} else { | ||
... | ||
} | ||
``` | ||
|
||
If you'd like to see a real example | ||
|
||
#### **`main.???`** | ||
``` | ||
fn main(argc, argv) | ||
{ | ||
if (4 > 9) { | ||
print("It is true!") | ||
} else { | ||
print("It is false!") | ||
} | ||
} | ||
``` | ||
|
||
To learn how to compile the file, [check this out!](./compile_and_run.md) | ||
|
||
```sh | ||
> ./GLaDOS -r executable | ||
It is false! | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Introduction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Lists | ||
|
||
Lists are used to store multiple arguments in 1 variable, in the format of an array. | ||
|
||
#### **`main.???`** | ||
``` | ||
int main(argc, argv) | ||
{ | ||
var littleList = [1, "salut", "hey"]; | ||
print(littleList); | ||
} | ||
``` | ||
|
||
To learn how to compile the file, [check this out!](./compile_and_run.md) | ||
|
||
``` | ||
> ./GLaDOS -r executable | ||
[1, "salut", "hey"] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Go further | ||
|
||
In this page we'll cover some exemple to discover the syntax of this language. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Variables | ||
|
||
To create a variable, you need to use the keyword `var` and set a value. You don't need to precise the type of your variable, the language will process it and guess the type. | ||
|
||
#### **`main.???`** | ||
``` | ||
fn main(argc, argv) | ||
{ | ||
var value = 4; | ||
print(value); | ||
} | ||
``` | ||
|
||
To learn how to compile the file, [check this out!](./compile_and_run.md) | ||
|
||
```sh | ||
> ./GLaDOS -r executable | ||
4 | ||
``` |
Oops, something went wrong.