Oxido is an attempt to implement a small subset of Rust. The goal of the project is to explore the theory and implementation of pointer aliasing in Rust. The expected deliverable would comprise of a working parser, type and borrow checker, a compiler, and a virtual machine. Ideally, our final implementation should free/drop any variable who's lifetime is no longer valid. This should be accomplished without a need for any garbage collection. For more information on the project status, please refer to this section.
- Parser is complete, refer to the grammar for more details about its syntax. Additional details are also available under the testing section as well.
- Type checker and borrow checker is currently both partially implemented and integrated. Refer to the v0 release section for more details.
- Compiler presently works for the following:
- Literal Expressions (e.g.
i64
,bool
,()
) - Assignments
- Primitive unary operations (e.g.
!
,-
) - Primitive binary operations (e.g.
+
,-
,*
,/
,==
,!=
,>
,>=
,<
,<=
) - Block expressions
- Function declarations
- Function applications
- String literals
- Strings
- String related operations
- Reference related operations
- Literal Expressions (e.g.
- Virtual Machine is not complete.
Please ensure that you have the latest stable release of Rust installed. Otherwise, do follow the installation instructions here.
Firstly, clone the repository to your local machine.
git clone https://github.com/cs4215-seville/oxido-lang.git
Once you've cloned the repository, proceed to build the project. This will produce a compiled binary in /target/debug/
.
cargo build
To execute the compiled binary, run the command below and supply the path to your program. Your program would then be parsed, type-checked, compiled, and executed. As the virtual machine is currently not fully functional, execution would fail.
โ ๏ธ As the compiler doesn't yet compile for strings, references, and their operations, we recommend that you add the--skip-compile
flag to avoid crashing the program if you're using any of those features.
./target/debug/oxido-lang --file-dir <DIR_TO_RUST_FILE> --heap-size=250
By convention, all tests can be found at the bottom of the file they're written for.
At present, tests are available for the parser and the test files can be found in parse examples. Of the 60 test files, the parser is able to correctly parse 59 syntatically valid programs, and correctly reject one. Basic tests are present for the compiler as well. To run the tests, execute the following in the project root.
cargo test
Parser: parse the Rust-subset langauge input to an AST
(completed, but one word fix required in ast.rs to change push_str
from unary operation to binary operation).
Static Checker: process the AST to output an error message, or a Mapping of line_no : variable_names, that specifies after which line, which variables should be dropped.
(incomplete. Updating of the borrow stack at the instatiation of every variable occurs, but deletion is partial.)
Compiler/VM : runs the code using the AST and mappings of variable drops fed by the static checker. Shows that all allocated memory is cleared at the end of program.