Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/decaf-lang/decaf
The new Decaf compiler, rewritten in "modern" Java
https://github.com/decaf-lang/decaf
compiler decaf mips object-oriented
Last synced: about 2 months ago
JSON representation
The new Decaf compiler, rewritten in "modern" Java
- Host: GitHub
- URL: https://github.com/decaf-lang/decaf
- Owner: decaf-lang
- Created: 2019-09-15T12:26:15.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-21T16:49:55.000Z (over 4 years ago)
- Last Synced: 2024-08-02T01:26:53.837Z (5 months ago)
- Topics: compiler, decaf, mips, object-oriented
- Language: Java
- Homepage:
- Size: 425 KB
- Stars: 60
- Watchers: 11
- Forks: 28
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# The New Decaf Compiler
[![](https://github.com/decaf-lang/decaf/workflows/Java%20CI%20with%20Gradle/badge.svg?branch=master)](https://github.com/decaf-lang/decaf/actions)
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 14
* Gradle 6.5.1Other dependencies will be automatically downloaded from the maven central repository by the build script.
After git clone, you need to setup submodules by
```
git submodule update --recursive --init
```## Build
Type the standard Gradle build command in your CLI:
```sh
gradle build
```The built jar will be located at `build/libs/decaf.jar`.
Or, import the project in a Java IDE (like IDEA or Eclipse, or your favorite VS Code) and use gradle plugin, if available.
## Run
In your CLI, type
```sh
java -jar build/libs/decaf.jar -h
```to display the usage help.
Possible targets/tasks are:
- PA1: parse source code and output the pretty printed tree, or error messages
- PA1-LL: like PA1, but use hand-coded LL parsing algorithm, with the help of a LL table generator [ll1pg](https://github.com/paulzfm/ll1pg)
- 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
- 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](http://spimsimulator.sourceforge.net), a MIPS32 simulator.
For Mac OS users, simply install `spim` with `brew install spim` and run with `spim -file your_file.s`.## Releases
See https://github.com/decaf-lang/decaf/releases for releases, including separate frameworks for PA1 -- PA3.
## Materials
We have a couple of Chinese documents on the language specification and implementation outlines:
- https://decaf-lang.gitbook.io
- https://decaf-project.gitbook.io## Development & Contribution
In future, we will develop on (possibly variates of) development branches,
and only merge release versions into the master branch.Issues and pull requests for fixing bugs are welcome. However, adding new language features will not be considered, because that's students' work!