ChocoPy Compiler

Archived

A small-scale compiler for the ChocoPy language.

Stack:PythonLLVMAssemblyC

Solo project

StatusArchived
RoleSolo
Year2022
StackPython, LLVM +24 technologies
ChocoPy Compiler

Problem

As part of a third-year university coursework, I was tasked with implementing a compiler for ChocoPy, a statically-typed subset of Python designed for teaching compiler construction. The objective was to build a complete compilation pipeline that translates high-level source code into LLVM IR, while adhering to a formally defined language specification. This project provided a structured environment to explore the core stages of compilation, including parsing, semantic analysis, and code generation, as well as the challenges of enforcing a static type system and producing correct low-level representations of high-level programs.

Highlights

  • Delivered a fully working compiler as part of assessed coursework
  • Implemented core stages: parsing → AST construction → semantic analysis → LLVM IR generation
  • Followed a formal language specification, ensuring correctness against defined behaviour
  • Implemented static type checking, catching type errors at compile time
  • Designed and implemented compiler optimisation passes beyond coursework requirements ( constant folding, dead code elimination )