Add section to README about functions
This commit is contained in:
parent
618a47422e
commit
6788ddbbb6
33
README.md
33
README.md
|
@ -30,6 +30,7 @@ The currently available opcodes are as follows:
|
||||||
- `p` - print out the arguments: `pHello World!` prints "Hello World!"
|
- `p` - print out the arguments: `pHello World!` prints "Hello World!"
|
||||||
- `a`, `s`, `m`, `d` - add, subtract, multiply, and divide, respectively: `a2-2` adds 2 + 2.
|
- `a`, `s`, `m`, `d` - add, subtract, multiply, and divide, respectively: `a2-2` adds 2 + 2.
|
||||||
- `l` - declare a variable: `lv9` declares variable `v` with value `9`; doing `p$v` prints out 9.
|
- `l` - declare a variable: `lv9` declares variable `v` with value `9`; doing `p$v` prints out 9.
|
||||||
|
- `f` - declare a function: see [Functions](#make-a-pull-request) for more info
|
||||||
- `#` - comment: the interpreter will skip this line.
|
- `#` - comment: the interpreter will skip this line.
|
||||||
|
|
||||||
Here's an example "Hello world" program:
|
Here's an example "Hello world" program:
|
||||||
|
@ -40,6 +41,31 @@ lwWorld!
|
||||||
p$h $w
|
p$h $w
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Functions
|
||||||
|
|
||||||
|
*functions* are ways to "pipe" math output to another operation. For example, you could assign the output to a variable, like below:
|
||||||
|
|
||||||
|
```
|
||||||
|
#Declare a function
|
||||||
|
fxa3-3
|
||||||
|
#Call the function and assign it to variable
|
||||||
|
lv*x
|
||||||
|
#will print out 6
|
||||||
|
p$v
|
||||||
|
```
|
||||||
|
|
||||||
|
Or you could print it out directly:
|
||||||
|
|
||||||
|
```
|
||||||
|
#Declare a function
|
||||||
|
fxs30-3
|
||||||
|
#Call it and print it out
|
||||||
|
#Will print out 27
|
||||||
|
p*x
|
||||||
|
```
|
||||||
|
|
||||||
|
Read [the devlog entry for more](https:/tilde.team/~karx/blog/sandwich-devlog-3-function-junction.html) info.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,10 +89,11 @@ Read [this guide](https://git-send-email.io) for more information.
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- [x] Better documentation
|
|
||||||
- [ ] Ability to explicitly print math output and assign math output to variables
|
- [ ] Ability to explicitly print math output and assign math output to variables
|
||||||
- [x] Add support for comments (should be pretty easy)
|
- [ ] Better function parsing (multi-instruction functions?)
|
||||||
- [x] Unit testing and CI/CD
|
- [ ] Importing/Running other files
|
||||||
|
- [ ] "Verbose" or "Debug" mode (environment variable or flag?)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue