Initialize the project with:
dune init proj tinyrust
Build your code and run the tests interactively with:
dune test --watch
We encourage you to use the data structures provided by the OCaml standard library wherever you see fit. To name a few: Stack, Hashtbl, Array, Result, Option...
Your project may also depend on external opam libraries. For example, to get nice error messages from the parser, you can use the nice-parser library.
The tests make some assumption about the interface of your interpreter and where you put the useful functions. You're free to adapt the tests to work with your implementation, or vice versa.
The tests also depend on the ppx_expect library. Install it with:
opam install ppx_expect
And add ppx_expect
to the dune file of your test directory, after ppx_inline_test
, like this:
(preprocess (pps ppx_inline_test ppx_expect)))
We recommend installing the ocamlformat tool:
opam install ocamlformat
If your project contains the .ocamlformat file, ocamlformat will automatically format your code whenever you save your source file or press Ctrl+S, adding indentation and whitespace where appropriate.
You can also invoke the tool manually with:
dune fmt
Please format your code with the above command before handing in the project.
- The Rust Handbook
- The Rust Reference. Useful for developing the grammar.
- OCaml language guide. Interesting articles:
- ocamllex manual
- Menhir manual
- Setting up Visual Studio Code for OCaml