This is a comprehensive compiler project developed for the CST 8152 - Compilers course at Algonquin College. The project implements a complete frontend compiler for the Neon programming language, built incrementally through multiple assignments that each focus on a specific phase of the compilation process.
The project is organized into multiple phases, each corresponding to a different assignment:
- Assignment 1: Coder (Step 1) - Basic encoding/decoding functionality
- Assignment 2: Reader (Step 2) - File reading and buffer management
- Assignment 3: Scanner (Step 3) - Lexical analysis and tokenization
- Assignment 4: Parser (Step 4) - Syntax analysis and parsing
- Assignment 5: Writer (Step 5) - Complete frontend compiler with simulated execution of variable assignment, console output , arithmetic expressions
Assignment 5 contains the complete frontend compiler implementation, which includes all previous phases plus the final writer component that can execute Neon code.
Neon is a simple programming language with the following features:
number- Numeric values (supports arithmetic operations)text- String literalsboolean- True/False valuesimage- image datatypeaudio- audio datatypeembedding- vector embeddings
load model "gemini"
load model "claude"
load model "openai-tts"
load model "openai-embeddings"
text document_text = doc("paper.pdf", PDF)
image illustrations = doc("paper.pdf", PDF)
text summary = generate("summarize this document", document_text)
using "gemini":
text extracted_text = ask("What does this image say?", illustrations)
cache(extracted_text)
using "claude":
text haiku = generate("Write a haiku about the above", extracted_text)
cache(haiku)
using "openai-tts":
audio spoken = generate("Convert haiku to audio", haiku)
save(spoken, "haiku.wav")
stream_out(haiku, console)
audio mic_input = stream_in(mic, WAV)
text translated = generate("Translate spoken audio to French", mic_input)
embedding doc_embed = embed(document_text)
embedding input_embed = embed(translated)
stream_out(translated, console)
# for test purposes #
number x = 2 + 4 * 3
text greeting = "Hi Mom"
- Arithmetic operations:
+,-,*,/ - Parenthesized expressions:
(x + y) * (x - y) - Variable assignments and references
- Console output with
output()function
- GCC compiler
- CMake (optional, for IDE support)
- Windows environment (for batch scripts)
-
Compile the project:
gcc compilers.c main1coder.c step1coder.c main2reader.c step2reader.c main3scanner.c step3scanner.c main4parser.c step4parser.c main5writer.c step5writer.c -o compilers
-
Run the complete compiler (Assignment 5):
# Using the batch script A5.bat # Or directly compilers 5 testFiles/sm.neo
-
Run individual phases:
# Coder (Phase 1) compilers 1 input_file # Reader (Phase 2) compilers 2 input_file # Scanner (Phase 3) compilers 3 input_file # Parser (Phase 4) compilers 4 input_file # Writer (Phase 5) - Complete frontend compilers 5 input_file
mkdir build
cd build
cmake ..
make
./Compilers 5 ../testFiles/sm.neoCompilers.c/h- Main compiler entry point and shared definitionsStep1Coder.c/h- Encoding/decoding functionalityStep2Reader.c/h- File reading and buffer managementStep3Scanner.c/h- Lexical analysis and tokenizationStep4Parser.c/h- Syntax analysis and parsingStep5Writer.c/h- Code execution simulation
Main1Coder.c- Coder phase entry pointMain2Reader.c- Reader phase entry pointMain3Scanner.c- Scanner phase entry pointMain4Parser.c- Parser phase entry pointMain5Writer.c- Writer phase entry point (complete compiler)
testFiles/sm.neo- Sample Neon source codetestFiles/sm.eneo- Encoded test file
A5.bat- Windows batch script for Assignment 5CMakeLists.txt- CMake configuration
- Basic encoding/decoding functionality
- File format conversion
- File input/output operations
- Buffer management
- Memory-efficient file processing
- Lexical analysis
- Token generation
- Error handling for lexical errors
- Syntax analysis
- Parse tree construction
- Grammar validation
- Variable management and storage
- Expression evaluation
- Arithmetic operations (+, -, *, /)
- String handling
- Console output functionality
- Code execution and interpretation
- Dynamic variable creation and management
- Support for multiple data types (numeric, string, boolean)
- Variable scope and lifetime management
- Arithmetic expression parsing and evaluation
- Operator precedence handling
- Parenthesized expression support
- Variable reference resolution
- Console output functionality
- String literal output
- Variable value output
- Formatted numeric output
- Robust error detection and reporting
- Graceful handling of invalid expressions
- Memory management and cleanup
The project includes test files in the testFiles/ directory:
sm.neo- Contains valid Neon code for testing the complete compilersm.eneo- Encoded version for testing earlier phases
# Run the complete compiler on the test file
compilers 5 testFiles/sm.neo
# Expected output includes:
# - Variable assignments
# - Expression evaluations
# - Console output
# - Final variable state- Language: C
- Compiler: GCC (MS Visual Studio 2022 compatible)
- Course: CST 8152 - Compilers
- Professor: Paulo Sousa
- Student: Ikeoluwa Oladele
- Term: Summer 2025
The project uses Git branches to organize different assignments:
assignment2- Reader implementationassignment3- Scanner implementationassignment4- Parser implementationassignment5- Complete frontend compiler (current)cleanup-writer- Additional writer improvementscode-exam- Exam-related codetest- Testing branch
This is an academic project for CST 8152 at Algonquin College. The complete implementation is in Assignment 5, which provides a fully functional frontend compiler for the Neon programming language.
This project is developed for educational purposes as part of the CST 8152 Compilers course at Algonquin College.