2021-02-07 16:34:00 +00:00
|
|
|
# sandwich
|
|
|
|
|
|
|
|
`sandwich` is a funny programming language written in Rust.
|
|
|
|
|
|
|
|
## Running
|
|
|
|
|
|
|
|
Use `cargo` to run an input file.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
git clone https://tildegit.org/karx/sandwich
|
|
|
|
cd sandwich
|
|
|
|
cargo run <filename>
|
|
|
|
```
|
|
|
|
|
|
|
|
## Reference
|
|
|
|
|
|
|
|
`sandwich` is comprised of *opcodes*. The syntax looks like this:
|
|
|
|
```
|
|
|
|
opcodeArguments
|
|
|
|
```
|
|
|
|
|
|
|
|
The currently available opcodes are as follows:
|
|
|
|
|
2021-02-07 17:45:13 +00:00
|
|
|
- `p` - print out the arguments: `pHello World!` prints "Hello World!"
|
2021-02-07 16:34:00 +00:00
|
|
|
- `a`, `s`, `m`, `d` - add, subtract, multiply, and divide, respectively: `a2-2` adds 2 + 2.
|
2021-02-07 17:45:13 +00:00
|
|
|
- `l` - declare a variable: `lv9` declares variable `v` with value `9`; doing `p$v` prints out 9.
|
2021-02-07 18:16:02 +00:00
|
|
|
- `#` - comment: the interpreter will skip this line.
|
2021-02-07 17:45:13 +00:00
|
|
|
|
|
|
|
Here's an example "Hello world" program:
|
|
|
|
|
|
|
|
```
|
|
|
|
lhHello
|
|
|
|
lwWorld!
|
|
|
|
p$h $w
|
|
|
|
```
|
2021-02-07 16:34:00 +00:00
|
|
|
|
|
|
|
## Contributing
|
|
|
|
|
|
|
|
|
|
|
|
For major changes, please open an issue first to discuss what you would like to change.
|
|
|
|
Please make sure to update tests as appropriate.
|
|
|
|
|
|
|
|
You can do two things to submit code:
|
|
|
|
|
|
|
|
### Make a pull request
|
|
|
|
- Fork the repo
|
|
|
|
- `git clone https://tildegit.org/yourusername/sandwich`
|
|
|
|
- Make a feature branch: `git checkout -b feature/amazing-feature`
|
|
|
|
- Make your changes and commit them: `git commit -am "My amazing commit message"`
|
|
|
|
- Push changes to your fork: `git push -u origin master`
|
|
|
|
- Create a pull request.
|
|
|
|
|
|
|
|
### Send a patch
|
|
|
|
|
|
|
|
You can send a patch to `karx@tilde.team`.
|
|
|
|
Read [this guide](https://git-send-email.io) for more information.
|
|
|
|
|
2021-02-07 17:45:13 +00:00
|
|
|
## TODO
|
|
|
|
|
2021-02-07 18:10:56 +00:00
|
|
|
- [x] Better documentation
|
2021-02-07 17:45:13 +00:00
|
|
|
- [ ] Ability to explicitly print math output and assign math output to variables
|
2021-02-07 18:16:02 +00:00
|
|
|
- [x] Add support for comments (should be pretty easy)
|
2021-02-07 19:48:03 +00:00
|
|
|
- [x] Unit testing and CI/CD
|
2021-02-07 17:45:13 +00:00
|
|
|
|
2021-02-07 16:34:00 +00:00
|
|
|
## License
|
|
|
|
|
|
|
|
This is free and unencumbered software released into the public domain.
|
|
|
|
|
|
|
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
|
|
distribute this software, either in source code form or as a compiled
|
|
|
|
binary, for any purpose, commercial or non-commercial, and by any
|
|
|
|
means.
|
|
|
|
|
|
|
|
In jurisdictions that recognize copyright laws, the author or authors
|
|
|
|
of this software dedicate any and all copyright interest in the
|
|
|
|
software to the public domain. We make this dedication for the benefit
|
|
|
|
of the public at large and to the detriment of our heirs and
|
|
|
|
successors. We intend this dedication to be an overt act of
|
|
|
|
relinquishment in perpetuity of all present and future rights to this
|
|
|
|
software under copyright law.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
For more information, please refer to <https://unlicense.org>
|