Git Product home page Git Product logo

rusty_slang's Introduction

rusty_slang

s(imple)lang(uage)

Compiler implementation to compliment compiler construction course.

Credit to Dr Timothy Griffin for slang examples and OCaml reference implementation.

Installation

This compiler is written in Rust, to use it you'll need to install Rust.

In particular, this compiler uses a nightly version of Rust. Once you've installed Rust, switch to a nightly version with:

rustup install nightly
rustup default nightly # this will set your default toolchain to nightly

You may need to add the following directories to your PATH if they aren't added automically:

~/.cargo/bin/
~/.rustup/nightly-{% your triple %}/bin/

To get the compiler clone this repository and install!

git clone https://github.com/doctorn/rusty_slang.git
cd rusty_slang
cargo install --path ./ # add --force to overwrite an existing installation

You should now have an executable called slang installed in ~/.cargo/bin/. This can be used to compile .slang files.

Usage

To compile a slang program to assembly, use the following:

slang my_program.slang

This should generate some assembly code in a file called my_program.s.

Assembly can be pretty cryptic, so I've added an option to generate comments for the assembly:

slang -C my_program.slang

If you want to assemble and link the compiled assembly, you can do so with the -L or --link options:

slang -L my_program.slang

This should give you two files: the first my_program.s (as before), and the second my_program (the linked executable). To execute your linked executable should be as simple as:

./my_program

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.