Skip to content

Latest commit

 

History

History
103 lines (58 loc) · 3.08 KB

README.md

File metadata and controls

103 lines (58 loc) · 3.08 KB

Pybicc💯

A Class-C Compiler with Graphical Interface + Assembly Code Interpreter

version course

madewithlove

简体中文 | English

China University of Petroleum (East China)-Compiler Theory Course Design-Group Two

GUI-Preview


Still Under Active Construction 🔨...

The project is inspired by Chibicc, thanks to rui314 for the open-source project 💖.

The graphical interface adopts Fluent 2 design style and is implemented using PyQt6 and PyQt-Fluent-Widgets 🌟.


Incomplete version, lacking interpreter implementation.

Supported variable types: int, char, int*, char*, int[], char[]

Run literal constants.

Supported operators: + - * / % == != < <= > >= && || ! = & ^

Supports pointers, dereferencing, function definition, and function invocation.

Supports IF-ELSE, FOR, WHILE statements

Project Objectives 🎯:

Implement a class C compiler mimicked by Python that can compile C language code into Intel 80x86 assembly code, equipped with an interpreter to interpret and execute assembly code to obtain computation results. The project also provides a graphical interface, offering some Integrated Development Environment (IDE) functionalities.

Code Structure ✨:

- main.py           Compiler program entry

- compiler\tokenize.py       Lexical analysis, converting source code into Token stored in linked list

- compiler\parse.py:         Syntax analysis, converting Token into Abstract Syntax Tree

- compiler\codegen.py        Semantic generation, converting Abstract Syntax Tree into assembly code

- compiler\simulator.py      Assembly code interpreter

- gui\fluent.py      Graphical interface entry

How to Run This Project ❓

  1. Install Python, this project is developed using Python 3.12.0.

  2. Install dependencies

    pip install -r requirements.txt
  3. main.py, provides examples of using the compiler and interpreter.

    python main.py
  4. interface\fluent.py, provides Pybicc's graphical interface

    python interface\fluent.py

Input Sample References 👾:

   int main() { int i=0; int j=0; for (i=0; i<=10; i=i+1) j=i+j; return j; }
   int main() { int a=3; int z=5; return a+z; }
   int main() { int x=3;int y=5; *(&x+8)=7; return y; }