- Since I didn't find it necessary to support unicode, the interpreter supports UTF-8 only which is better performance wise (fast indexing, smaller size, etc).
- Every program should define
MAIN
function as an entry point. - Function calls should be done by
CALL
instruction and all of them should properly return by usingRETURN
orRETURN_VALUE
. This is necessary because these instructions properly handle the stack and also the frame. - Since memory cell is 4-bytes long, instead of pushing characters one by one and using 4-bytes for 1-byte characters, I implemented
PUSH_STR
andPOP_STR
instructions to fit 4 characters in a memory cell. - All tokens, instructions, etc. uses
&str
instead ofString
. Because usingString
would result in lots of unnecessary copies.
Run traverse directory (question #4) by running:
cargo r --example runner -- examples/traverse_dir.bci
cargo r --example runner -- examples/factorial.bci
You can write a bci program and pass it to runner like above to run it.
cargo test