This repository hosts a complete compiler implementation designed to translate source code written in SimplePP (Simple-Python-Python)—a custom, simplified dialect of Python—into executable C code.
The SimplePP compiler was developed as a comprehensive exercise in programming language design and compiler construction. It successfully parses and translates core programming constructs, demonstrating the full pipeline from lexical analysis and parsing to semantic analysis and code generation.
| Component | Role | Technology |
|---|---|---|
| Grammar & Parsing | Automated generation of the parser and lexer. | ANTLR4 (Another Tool for Language Recognition) |
| Compiler Logic | Implementation of code generation, semantic checks, and symbol table management. | Java |
| Target Language | The final, generated output. | C |
- Custom Language Support: Implements the full grammar and semantics of the SimplePP language.
- Symbol Table Management: Tracks variables, types, and scope to ensure semantic correctness.
- C Code Generation: Produces clean, readable C code that is functionally equivalent to the input SimplePP program.
- Control Flow Translation: Handles complex Python-like control structures, including nested
ifstatements and loops.
While the core translation functionality is robust, there are a few unresolved issues that may be addressed in future iterations:
- Indentation/Formatting: Tabs in the generated C file may not always align perfectly, though this does not affect execution.
- Comment Handling: Due to the method used for handling leading whitespace (tabs) in the SimplePP input, single-line and block comments may sometimes interfere with parsing.
- Undeclared Variables: The compiler currently accepts program code where a parameter is used without explicit declaration.
For detailed information on the grammar, implementation decisions, and testing, please refer to the attached project documentation.