Skip to content
Back to work

FEUP · Compilers · 2024

Java-- Compiler

A compiler for a subset of Java, from grammar to JVM bytecode.

The problem

Build a working compiler for Java-- (Jmm), a teaching subset of Java with classes, methods, arrays, imports and control flow, producing code that runs on the Java Virtual Machine.

What was built

  • Grammar written in ANTLR 4, producing an abstract syntax tree annotated through visitors.
  • Symbol table builder for classes, fields, methods, parameters and locals, followed by semantic analysis passes for type checking and undeclared variables.
  • Lowering to OLLIR, the course's intermediate representation, then generation of Jasmin assembly that is assembled into JVM class files.
  • Validated against the course's JUnit checkpoint test suites.

My role

Team of three. According to the team's documented work distribution, I carried 45% of the work.

Technologies

  • Java
  • ANTLR 4
  • OLLIR
  • Jasmin
  • JUnit
  • Gradle