BS is a stack-based, simple, and predictable programming language. As a matter of fact, there are only 8 instructions!
#: Takes the next two characters in the program, interpreted as two hex digits, and adds it to the stack.: Pops the top value from the stack and prints it as a hex value:: Duplicates the top of the stack~: Pops the second item on the stack and pushes it to the top+: Pops the top two values from the stack, adds them, and pushes the result to the stack-: Subtracts the top of the stack from the second value on the stack, and pushes the result[: Seeks the matching]in the program if the top of the stack is 0]: Seeks the matching[in the program if the top of the stack is NOT 0
BS uses a single stack with an arbitrary, but constant maximum size. Values on the stack are bytes represented by two hex digits. Any non-recognized instructions are ignored, allowing for inline comments anywhere in your program
Code written in BS is very compact. Here's BS's equivalent of the classic Hello World program to demonstrate:
#03#0f~.. prints 03 and 0f to the screen
There are two acceptable styles for writing BS:
- No whitespace/comments (an ending comment is acceptable)
- A newline after every instruction
The extension for BS sources files is .bs
The interpreter hosted in this repository is written in the Odin programming language
To build the binary, in the project directory run odin build bs.odin, This will produce a binary called bs. To run BS, call the binary with one argument, the name of the source file.
The tests folder contains three example programs for learning
No, but nothing is so I wouldn't worry too much
It takes some time and dedication, but with some practice you'll learn it's not too hard
Maybe eventually, but BS is simple enough that tooling isn't really needed Most people can write it unaided