A comprehensive collection of compiler construction laboratory exercises and projects, implementing lexical analyzers, parsers, and compiler components using Lex and Yacc tools.
- ๐ Documentation: Lab Manuals
- ๐ Report Issues: GitHub Issues
- ๐ค Contributing: Contributing Guidelines
- ๐ License: MIT License
- ๐ Installation
- โก Usage Examples
- โจ Features
- ๐ Folder Structure
- ๐ Tech Stack
- ๐ฆ Dependencies & Packages
- ๐ค Contributing
- ๐ License
- ๐ก Security
- ๐ Code of Conduct
Before you begin, ensure you have the following installed on your system:
- Flex (Fast Lexical Analyzer Generator)
- Bison (Yacc-compatible parser generator)
- GCC (GNU Compiler Collection)
- Git
-
Clone the Repository
git clone https://github.com/H0NEYP0T-466/Compiler_Construction.git cd Compiler_Construction -
Install Flex & Bison
On Ubuntu/Debian:
sudo apt-get update sudo apt-get install flex bison gcc
On macOS:
brew install flex bison
On Windows:
- Download Flex & Bison from GnuWin32
- Add the binaries to your system PATH
-
Verify Installation
flex --version bison --version gcc --version
# Navigate to any lab directory
cd Lab#3/TASK#1
# Generate the lexical analyzer
lex filename.l
# Compile the generated C code
gcc lex.yy.c -o output
# Run the lexical analyzer
./output# Generate the parser
yacc -d filename.y
# Generate the lexical analyzer
lex filename.l
# Compile everything together
gcc y.tab.c lex.yy.c -o parser
# Run the parser
./parsercd Lab#5/Task#2
# Build the calculator
yacc -d parser.y
lex scanner.l
gcc parser.tab.c lex.yy.c -o calc
# Run the calculator
./calc- ๐ฏ Lexical Analysis: Implementation of tokenizers using Flex
- ๐ Syntax Analysis: Parser generation using Bison/Yacc
- ๐งฎ Expression Parsing: Arithmetic expression evaluation
- ๐ Symbol Table Management: Variable and identifier tracking
- ๐ Three-Address Code Generation: Intermediate code representation
- ๐ Comprehensive Lab Materials: Complete lab exercises with documentation
- ๐ Educational Focus: Designed for learning compiler construction concepts
- ๐ง Multiple Implementations: Various compiler components across different labs
Compiler_Construction/
โโโ ๐ Lab#3/ # Lexical Analysis Fundamentals
โ โโโ ๐ Lab#3.l # Main lexical analyzer
โ โโโ ๐ TASK#1/ # Token recognition exercises
โ โโโ ...
โโโ ๐ Lab#4/ # Parser Generation
โ โโโ ๐ TASK#2/ # Basic parser implementation
โ โโโ ๐ TASK#3/ # Grammar rules
โ โโโ ...
โโโ ๐ Lab#5/ # Expression Parsing & Evaluation
โ โโโ ๐ Task#2/ # Calculator implementation
โ โโโ ๐ Task#3/ # Expression handling
โ โโโ ...
โโโ ๐ Lab#6/ # Advanced Parsing Techniques
โ โโโ ๐ Q#3/ # Complex grammar implementation
โ โโโ ๐ Q#4/ # Error handling
โ โโโ ...
โโโ ๐ Lab#7/ # Syntax-Directed Translation
โ โโโ ...
โโโ ๐ Lab#9/ # Code Generation
โ โโโ ๐ Task#3/ # Three-address code
โ โโโ ๐ Task#4/ # Code optimization
โ โโโ ...
โโโ ๐ OEL#1/ # Open Ended Lab - Project 1
โ โโโ ๐ GROUP#1/ # Group project implementations
โ โโโ ๐ GROUP#3/ # Advanced projects
โโโ ๐ OEL#2/ # Open Ended Lab - Project 2
โ โโโ ...
โโโ ๐ QUIZ#1/ # Quiz Solutions
โ โโโ ๐ Q1/ # Quiz 1 solutions
โ โโโ ๐ Q2/ # Quiz 2 solutions
โ โโโ ...
โโโ ๐ Manuals/ # Lab Manuals & Documentation
โ โโโ ๐ Lab4-Manual.pdf
โ โโโ ๐ Lab5-Manual.pdf
โ โโโ ...
โโโ ๐ README.md # This file
This project has no external runtime dependencies. All components are built using standard C libraries and the Flex/Bison toolchain.
- Flex - Fast lexical analyzer generator
- Bison - Parser generator compatible with Yacc
- GCC - GNU Compiler Collection for C compilation
- Make - Build automation tool (optional)
# Ubuntu/Debian
sudo apt-get install flex bison gcc make
# macOS
brew install flex bison
# Windows (using MSYS2)
pacman -S flex bison gcc makeWe welcome contributions! Please see our Contributing Guidelines for details on how to:
- ๐ด Fork and clone the repository
- ๐ง Set up your development environment
- ๐ Follow our code style and conventions
- ๐งช Test your changes
- ๐ค Submit pull requests
This project is licensed under the MIT License. See the LICENSE file for details.
If you discover any security vulnerabilities, please review our Security Policy for responsible disclosure guidelines.
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code.
Made with โค by H0NEYP0T-466