Skip to content

Commit

Permalink
feat(docs): Keywords & Convention
Browse files Browse the repository at this point in the history
  • Loading branch information
crnvl committed Jul 16, 2023
1 parent e012d53 commit 7b315b1
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 9 deletions.
28 changes: 28 additions & 0 deletions docs/CONVENTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# NETL2 Language Convention
## Variables
All variables in NETL2 should be in lower snake case. You cannot use reserved keywords as variable names.
Additionally, variable identifiers cannot contain spaces, special characters, or numbers.

Examples:
```rs
v var_name = 2 <- Recommended
v varName = 2 <- Not recommended
v varname = 2 <- Not recommended
v var1 = 2 <- Does not work
```

## Functions
All functions in NETL2 should be in lower snake case. You cannot use reserved keywords as function names.
Additionally, function identifiers cannot contain spaces, special characters, or numbers.

Examples:
```rs
f main {} <- Recommended
f main_function {} <- Recommended
f Main {} <- Not recommended
f mainFunction {} <- Not recommended
f func1 {} <- Does not work
```

## Comments
Comments cannot be written at this time.
26 changes: 26 additions & 0 deletions docs/KEYWORDS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Keywords in NETL2
- `v` - Declare a variable
- `i` - Declare an if statement
- `w` - Declare a while loop
- `f` - Declare a function
- `p` - Print a value

# Expressions in NETL2
- `+` - Add two values
- `-` - Subtract two values
- `*` - Multiply two values
- `/` - Divide two values
- `==` - Check if two values are equal
- `!=` - Check if two values are not equal
- `>` - Check if the first value is greater than the second value
- `<` - Check if the first value is less than the second value
- `>=` - Check if the first value is greater than or equal to the second value
- `<=` - Check if the first value is less than or equal to the second value
- `&` - Check if both values are true
- `|` - Check if either value is true
- `!` - Check if the value is false

# Types in NETL2
- `int` - Signed 32-bit integer
- `str` - String
- `bool` - Boolean
4 changes: 4 additions & 0 deletions docs/LEARN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ To use NETL2, you can simply run the executable with the path to the file you wa
./NETL2 path/to/file.nl
```

# More Resources
- [Keywords](KEYWORDS.md)
- [Convention](CONVENTION.md)

## 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.

Expand Down
12 changes: 3 additions & 9 deletions examples/spec_test.nl
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
v comp_one = 1
v comp_two = 2
v comp_three = 3
v comp_four = 3

i comp_one == comp_two | comp_three != comp_four {
p("worked!")
}
p("done")
i !false {
p("true")
}

0 comments on commit 7b315b1

Please sign in to comment.