At Ho Chi Minh University of Technology, we computer science students have a required course called "Principles of programming languages" (or PPL for short). This course teaches us about programming language design and implementations. In this course, we are required to write a simple compiler for a simple, JVM-based programming language named 'Zcode'.
The implementation process is divided into 4 phases corresponding to to 4 assignments:
-
Scanning, Parsing: In this phase, we are required to write a parser to check if syntax of the input program is valid.
-
Abstract Syntax Tree (AST) generation: Create the abstract syntax tree from the parse tree generated by the parser.
-
Static checking: Using the generated AST, detect semantic errors occurred in the program.
-
Code generation: The compiler uses the AST to generate JVM bytecodes.
This repository is used to store assignment details and my solution of each assignment.
Python 3
Download ANTLR v4.9.2 and put it in the project directory: https://www.antlr.org/download.html
source ./install_pkg.sh # create virtual environment and install all required Python packages
source ./init.sh # initialize environment variables
cd src
make test
I haven't built the CLI for this compiler yet, but I will do it soon! :)