Skip to content
/ rremix Public

An experimental compiler for the Remix programming language

Notifications You must be signed in to change notification settings

zacps/rremix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Remix Compiler

A Rust compiler for the Remix programming language.

Current State

The current state of the compiler is described below.

Parser

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.

Semantic Analysis

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.

Codegen

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.

Errors

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.

Testing

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

About

An experimental compiler for the Remix programming language

Topics

Resources

Stars

Watchers

Forks