This repository contains my workings for the lab assignments of the compiler design course at IIT (BHU).
Every lab is a small program written in C++, LEX or YACC. Each one comes with its input, the exact commands to build and run it, and a screenshot of what the terminal printed.
A compiler is a pipeline: source → preprocessed file → assembly → object code → executableThe lexer reads characters and groups them into lexemes, each one tagged as a tokenTop-down parsers grow the parse tree from the start symbol towards the inputBottom-up parsers shift input onto a stack and reduce it back to the start symbolLEX hands tokens to YACC, and YACC runs an action whenever a grammar rule matches
(id+id)*id+id
id*(id+id)
The color_*.cpp builds of Labs 4–6 print in 256 colours. The colours mean:
git clone https://github.com/repsick3r/CSE425_Compiler_Design_Lab.git
cd CSE425_Compiler_Design_Lab/Lab6
g++ canonicalLRParser.cpp -o clp
./clp input.txt
Labs 3 and 7 also need flex and bison (sudo apt-get install bison flex). Each lab page has its exact commands.