Skip to content

ZagkasD/SimplePP-to-C-Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimplePP to C Compiler

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.

Project Overview

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.


Technology Stack

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

Key Features

  • 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 if statements and loops.

Status and Known Issues

While the core translation functionality is robust, there are a few unresolved issues that may be addressed in future iterations:

  1. Indentation/Formatting: Tabs in the generated C file may not always align perfectly, though this does not affect execution.
  2. 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.
  3. 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.

About

A compiler for simplepp (simple-python-python) that translates code into c

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors