Skip to content

A Java Compiler to compile from a custom language to RISC-V code

License

Notifications You must be signed in to change notification settings

CharlieAnthony/Java-Compiler

Repository files navigation

Simple Programming Language Interpreter and RISC-V Code Generator

This repo contains my coursework for the compilers module I took at the University of Sussex. For this coursework, I scored 91%. What follows is copied from the coursework specification, along with my submission.

This project involves two main tasks, creating an interpreter and a RISC-V code generator, for a simple programming language. The language is based on a subset of the standard programming language features, and this project will help you to understand the fundamental concepts of interpreting and code generation.

The project has been split into two main tasks for easier navigation and understanding.

Task 1: Creating an Interpreter

The first task involves creating an interpreter for our simple programming language. You will write a lexer, parser, and a bit of semantic analysis for this task. We'll be using the parser generator ANTLR to ease the creation of this interpreter.

You can find all the details related to this task in the task1.md file.

This file provides a detailed description of:

  • Execution Model of the language
  • Type Deduction Rules
  • Input/Output specifications

In the execution model, you'll understand how to structure the main function and the role of identifiers. The type deduction rules will help you understand the various types of expressions and their implementation. The input/output specification will guide you in understanding how to read a string and implement error handling.

Task 2: RISC-V Code Generator

The second task is to create a code generator targeting RISC-V assembly for the same simple programming language. This task assumes that the input program has passed both the syntax and semantic analysis of the first task.

The code generator will read a string (the input program in our simple programming language from System.in and generate RISC-V assembly code that can be simulated by RARS. You can find all the details related to this task in the task2.md file.

This file provides a detailed description of:

How to Use

To use this project, you need to follow the steps below:

  1. Clone or download this project to your local machine.
  2. Navigate to each task (task1 and task2), and follow the instructions provided in their respective markdown files. You will need to understand the requirements and implement the interpreter and code generator accordingly.
  3. Verify your implementation using the examples provided.

Dependencies

  • The ANTLR parser generator is required for both tasks. You can download it from here.
  • The RARS is required for task 2.

Contact

If you have any questions, feel free to reach out to me. My discord handle is charlieanthony.

Acknowledgements

About

A Java Compiler to compile from a custom language to RISC-V code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages