AlphaCompiler is a full-fledged compiler and virtual machine implementation for the Alpha programming language, developed as part of the CS-340 course at the University of Crete. The project showcases end-to-end compiler design, from lexical and syntax analysis to intermediate and target code generation, and execution via a virtual machine.
- 🌟 Features
- 🛠️ Technologies Used
- 🚀 Getting Started
- 🧩 Usage
- 📄 Project Structure
- 👥 Contributors
- 📜 License
- Lexical Analysis using Flex
- Syntax Analysis with Bison
- Intermediate Code Generation (quad generation)
- Target Code Generation for binary output
- Alpha Virtual Machine (AVM) for executing compiled binaries
- Flex: For lexical analysis
- Bison: For syntax parsing
- C: For core compiler and VM implementation
Ensure you have the following installed:
- GCC compiler
- Flex and Bison
- Make utility
Install dependencies on Ubuntu:
sudo apt-get install build-essential flex bison
-
Clone the repository:
git clone https://github.com/aangelakis/AlphaCompiler.git cd AlphaCompiler
-
Build the compiler and virtual machine:
make
Navigate to the correct directory and compile the project:
cd Paradoseis/phase_4_5
make
./a.out name_of_test_file
After compiling the compiler, compile and run the Alpha Virtual Machine (AVM):
cd avm
make
./avm.out
Note: The instructions are printed to the file instructions_output.txt
.
AlphaCompiler/
├── Paradoseis/
│ └── phase_4_5/
│ ├── avm/ # Alpha Virtual Machine
│ ├── libs/ # Libraries
│ ├── testMains/ # Test main files
│ ├── tests/Phase4-5/ # Test cases
│ ├── Makefile # Build automation
│ ├── README.txt # Additional documentation
│ ├── expression.c # Expression handling code
│ ├── expression.h # Expression handling header
│ ├── instruction.c # Instruction handling code
│ ├── instruction.h # Instruction handling header
│ ├── parser.y # Syntax parser (Bison)
│ ├── quads.c # Quad generation code
│ ├── quads.h # Quad generation header
│ ├── scanner.l # Lexical analyzer (Flex)
│ ├── syntaxanal.c # Syntax analysis code
│ └── yacc_utilities.h # YACC utility functions
└── README.md # Project documentation
- Alexandros Angelakis, Christos Zarkos, Theodoros Chalkidis (contributed equally)
This project is licensed under the MIT License. See the LICENSE file for details.