Mandatory assignment in IN5380: Compiler construction

The mandatory assignment is a two-part assignment, where you implement a compiler:

  • You will work in groups of two or three. (Contact the lecturer if we need to make an exception).
  • The default implementation language is Java, and there is precode that makes the implementation work easier.
  • You can use another implementation language, but it does require you to be more independent. Contact the lecturer if you want to use something other than the default stack.
  • The assignments will be corrected in-person (or over a video-call, if necessary).
  • Tasks are submitted in Devilry.

Part 1

  • Published: February 13th
  • Deadline: March 16th

Groups must be created in Devilry by February 20th. If we have agreed you can work alone, leave a comment in Devilry referring to the email-correspondence by date.

The task is to write the lexer and parser of a compiler for the language Compila 26. The language specification is available here:

The starting point for the assignment is available here:

Requirements

  • Your program must parse tests/fullprograms/complexaddition.cmp correctly.
  • Your program must generate a printed AST that reflects the parsed structure correctly.

A simple sample project

A much simpler project for an expression language using JFlex and CUP with a similar structure as the precode can be studied here:

Part 2

  • Published: April 7th
  • Deadline: May 4th

The task is expand your Compila 26 compiler with semantic analysis and code generation.

The semantic analysis consists of checking rules outlined in the language specification, that is not captured by the parser:

The work consists primarily of implementing a type checker, along with a few other checks (e.g.?declarations must be unique per block), all described in the language specification.

The precode already contains a bytecode interpreter. It is described in detail here:

Your program should produce Compila bytecode that can be interpreted the provided interpreter.

The precode has been patched to support generating bytecode and interpreting Compila bytecode.

You make a similar change in your project.

Requirements

  • Your compiler must accept the programs in /tests/semanticanalysis/noerrors/.
  • Your compiler must reject the programs in /tests/semanticanalysis/errors/.
  • Your compiler must compile tests/fullprograms/runme.cmp correctly.
Published Feb. 13, 2026 3:36 PM - Last modified Apr. 8, 2026 3:40 PM