Downloadable ContentDownload PDF
Cool compiler using ANTLR and LLVM
Computers are very sophisticated machines and the way we control these machines is through programs that are always written in some programming language. Today, the programs written to control the computers are in a high-level language like C, C++, JAVA, Python and so on; while the machine hardware only understands low-level language like assembly language or binary. A compiler is the tool that translates programs in a high-level language into programs in low-level language. The main goal of this project is to explore the tools ANTLR (ANother Tool for Language Recognition) and LLVM (Low Level Virtual Machine) together for compiler construction. This compiler for COOL (Classroom Object Oriented Language) uses ANTLR version 4 for modules responsible for tokenizing (lexer), checking syntax (parser) and checking semantics (semantic analyzer). The code generation module is implemented using LLVM version 3.7.0. This project demonstrates how the ANTLR 4 features help simplify compiler construction by auto generating methods and providing interfaces for any user defined grammar.