https://github.com/calbabreaker/simple-language-maybe-intepreted
A simple language maybe
https://github.com/calbabreaker/simple-language-maybe-intepreted
Last synced: about 1 year ago
JSON representation
A simple language maybe
- Host: GitHub
- URL: https://github.com/calbabreaker/simple-language-maybe-intepreted
- Owner: Calbabreaker
- License: mit
- Created: 2022-09-08T15:48:22.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-17T05:14:27.000Z (almost 4 years ago)
- Last Synced: 2025-02-12T11:14:23.130Z (over 1 year ago)
- Language: Rust
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple Language Maybe
## Running
Run like this where the first argument would be the file to a slm script:
```sh
cargo run -r hello.slm
```
## Specification
### Syntax
Comments can be declared with `#` where `#` will comment out all the text until the end of the line. Code between `#*` and `*#` will be comments as well:
```slm
# This is comment
#*
This is another comment
This is another comment
*#
```
Variables are created using `=` or `:=` for constants:
```slm
variable = "hello"
gravity := 9.1
```
The seperator for each statement is a linebreak. Use `~` if multiple statement are need on one line with each side of the `~` needing to be a statement:
```slm
var1 = "yes" ~ var2 = "no"
```
Functions are called with arguments being seperated by spaces or a seperator:
```slm
print "Hello World" variable variable2
# Or:
print"Hello World"variable variable2
```
`()` can be used to execute code where the value of the last statement will be returned (or returned with `return`). This can be multiline:
```slm
print (read_file "hello")
print (
user = "Hello"
get_password(user) # or return get_password(user)
)
# Required if doing math like this:
print (1 + 2)
```
Define functions using `func` and set it as a variable:
```slm
say_hello = func arg1 agr2 (
)
```
### Style
Files should end in `.slm`.