Skip to content

Commit

Permalink
feat(docs): Edit documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
crnvl committed Jul 16, 2023
1 parent e86a2d3 commit 0704a8f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,24 @@ streamlined, so that anti-patterns are difficult to write and the language is ea
Get started [here](./docs/LEARN.md)

## Code examples
```nl
v var_name = 2
```rs
f test_fn {
v test = 20

w var_name == 2 {
p("Hello World!")
var_name = 3
}
w test > 0 {
p(test)
test = test - 1

f main {
p("Main function!")
i test == 10 {
p("test is 10")
}
}
}

i var_name != 2 {
main!
f nested_fn {
v test = 3
p(test)
test_fn!
}
nested_fn!
```
16 changes: 8 additions & 8 deletions docs/LEARN.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ To use NETL2, you can simply run the executable with the path to the file you wa
## Scope
Each file is its own scope, and variables are global to the file. This means that you can access variables from anywhere in the file.

```nl
```rs
v var_name = 2
p(var_name)
```

Variables within a function are not global to the file, but are global to the function. This means that you can access variables from anywhere in the function.

```nl
```rs
f main {
v var_name = 2
p(var_name)
Expand All @@ -53,15 +53,15 @@ Variables within a function are not global to the file, but are global to the fu

Variables are declared with the `v` keyword, followed by the variable name, an equals sign, and the value.

```nl
```rs
v var_name = 2
```

## If statements

If statements are declared with the `i` keyword, followed by the condition, and then the code block.

```nl
```rs
i var_name == 2 {
p("Hello World!")
}
Expand All @@ -71,7 +71,7 @@ If statements are declared with the `i` keyword, followed by the condition, and

While loops are declared with the `w` keyword, followed by the condition, and then the code block.

```nl
```rs
w var_name == 2 {
p("Hello World!")
var_name = 3
Expand All @@ -82,7 +82,7 @@ While loops are declared with the `w` keyword, followed by the condition, and th

Functions are declared with the `f` keyword, followed by the function name, and then the code block.

```nl
```rs
f main {
p("Main function!")
}
Expand All @@ -92,14 +92,14 @@ Functions are declared with the `f` keyword, followed by the function name, and

Functions are called with the `!` operator.

```nl
```rs
main!
```

## Printing

Printing is done with the `p` keyword, followed by the value to print.

```nl
```rs
p("Hello World!")
```
2 changes: 1 addition & 1 deletion examples/spec_test.nl
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ f nested_fn {
p(test)
test_fn!
}
nested_fn!
nested_fn!

0 comments on commit 0704a8f

Please sign in to comment.