Bug is a stack-based programming language with a functional paradigm, developed for educational purposes.
The program written in bug language is compiled by the bug compiler (bugc
) to an intermediate bytecode and serialized to a file, then the Bug Virtual Machine (bvm
) loads the file containing the bytecode and execute.
hello.bug
f main -> "Hello, world!" .write;
sum two integers
f sum(int lhs, int rhs) int ->
lhs rhs ;
f main ->
34 35 .sum .write;
print Fibonacci sequence
fib(int x, int y, int stop) ->
y stop > if -> return;
y .write
y x y stop .fib;
f main -> 0 1 150 .fib;
To use this language your can download a release for you platform or go through the source code.
- Download a release for you platform here
- Unpack and give execution permissions
unzip <your_platform>-bug-toolkit.zip
chmod x <your_platform>-bugc
chmod x <your_platform>-bvm
- clone the repository
git clone https://github.com/edilson258/bug.git
- Compile and run a bug program
cargo run --bin bugc <some_program>.bug
cargo run --bin bvm out.bin
Now see Examples for help. Happy hacking!
Feel free to fork and play with it. PRs are welcome!💯