The PL/0 Compiler is a custom compiler I implemented to translate and execute programs written in the PL/0 language. This project deepened my understanding of compiler design, including lexical analysis, parsing, code generation, and error handling.
Purpose: Create a functional compiler for the PL/0 language to understand the core concepts of compiler design.
Technology Used: C
Key Features:
Lexical analysis to tokenize input code
Syntax and semantic analysis using a recursive descent parser
Intermediate code generation for a virtual machine
Error detection and reporting
The compiler consists of multiple stages, each responsible for a specific part of the compilation process:
Lexical Analysis: Scans the source code and converts it into a stream of tokens.
Parsing: Uses a recursive descent parser to analyze the syntax structure.
Semantic Analysis: Ensures valid variable declarations, assignments, and operations.
Code Generation: Produces intermediate code that can be executed by a virtual machine.
Execution: Simulates the virtual machine to run the compiled code.
Recursive Descent Parsing: Implemented efficient parsing methods for grammar rules.
Error Handling: Developed meaningful error messages for easier debugging.
Code Generation: Created an optimized intermediate code representation for execution.
Implement optimization techniques for faster code execution.
Expand the PL/0 language with additional language features.
Add detailed debugging and visualization tools.
This project was a challenging but rewarding experience that significantly improved my understanding of compiler theory and low-level programming. If you'd like to discuss compiler design, feel free to reach out!