/featherweight-muse

An implementation of a featherweight muse interpreter written in Rust.

Primary LanguageRust

Featherweight muse

An implementation of a featherweight muse interpreter written in Rust.

Featherweight muse is a subset of muse, a programming language that I'm working on. It is designed to test and evaluate the type system of muse, which implements compile-time memory management through borrow checking. The formalisation of featherweight muse can be seen in this paper.

Currently, featherweight muse supports the following:

  • Variable declarations
  • Function declarations
  • Function calls
  • Assignment
  • Heap allocation
  • Mutable/Immutable references
  • Borrow checking system
  • Ownership system
  • Lifetime system
  • Auto-dereferencing

Getting Started

Pre-requisites

Install

cargo install

Usage

cargo run -- <options> <file>

Options

Options:
        -h, -help       Display help
        -l, -lex        Display lexer output
        -p, -parse      Display parser output
        -t, -typecheck  Display typecheck output
        -e, -eval       Display eval output

Test

To run all tests:

cargo test

Example

cargo run tests/swap.mu

Syntax

fn swap(mut ref a: int, mut ref b: int) {
    let mut tmp = a
    a = b
    b = tmp
}

let mut x = 10
let mut y = 20

swap(x, y)

let mut heap_x = box x