Giter Site home page Giter Site logo

decaf-in-scala's Introduction

The Decaf Compiler, in Scala

Decaf is a Java-like, but much smaller programming language mainly for educational purpose. We now have at least three different implementations of the compiler in Java, Scala and Rust. Since the standard language has quite a limited set of language features, students are welcome to add their own new features.

Getting Started

This project requires JDK 12, because the package decaf.lowlevel is shared with Java's.

Other dependencies will be automatically downloaded from the maven central repository by the build script.

Build

Type standard sbt commands after you launch the REPL with sbt.

To compile, type:

sbt:decaf-in-scala> compile

To build a standalone jar, type:

sbt:decaf-in-scala> assembly

To start a scala REPL, type:

sbt:decaf-in-scala> console

Or, import the project in IDEA and use sbt plugin, if available.

Run

In sbt console, type:

sbt:decaf-in-scala> run --help

to show the usage help. Or you first build a standalone jar and run it in CLI.

Possible targets/tasks are:

  • PA1: parse source code and output the pretty printed tree, or error messages
  • PA2: type check and output the pretty printed scopes, or error messages
  • PA3: generate TAC (three-address code), dump it to a .tac file, and then output the execution result using our built-in simulator
  • PA3-JVM: generate JVM bytecode
  • PA4: currently same with PA3, will be reserved for students to do a bunch of optimizations on TAC
  • PA5: (default target) allocate registers and emit assembly code, currently we are using a very brute-force algorithm and only generates MIPS assembly code (with pseudo-ops, and no delayed branches)

To run the MIPS assembly code, you may need spim, a MIPS32 simulator. For Mac OS users, simply install spim with brew install spim and run with spim -file your_file.s.

decaf-in-scala's People

Contributors

hoblovski avatar paulzfm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

decaf-in-scala's Issues

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.