A Rust compiler for the Remix programming language.
The current state of the compiler is described below.
rremix uses a parsing expression grammar parser generated by pest. The parser implements all lexing (including significant whitespace) so there is no separate lexer step.
Currently the parser can parse all of remix sans objects (create
), but does have edge cases where it will eroneously reject valid programs.
The parse tree is converted into an intermediate representation which is responsible for resolving functions, variables, and reducing some syntactic sugar. This is also where function call/variable name ambiguities are resolved.
The original plan was to generate LLVM IR in a similar manner to the rust compiler, rustc. However, to save time the decision was made to switch to generating C instead. Codegen is in a very early state. Variables, literals, function calls are supported but anonymous blocks and control flow structures are not yet supported.
Error messages relating to experimental function resolution have been implemented, and produce nice suggestions supported by codespan-reporting.
error: ambiguous function call
┌─ program:25:2
│
25 │ show (what)
│ ^^^^^^^^^^^ this function call could refer to multiple definitions
│
┌─ 0:1:1
│
1 │ show (output)
│ ------------- this is a possible choice
│
┌─ 1:1:1
│
1 │ (list) (index)
│ -------------- this is a possible choice
Other error messages produce panics.
rremix is tested primarily using a number of snapshot tests at various stages of the compiler.
These are derived from existing tests and examples in the Red remix interpreter.
Tests can be run with
$ cargo test
to run with specialisation enabled use:
$ cargo test --features experimental_specialisation