This repository contains a comprehensive collection of compiler design laboratory programs organized by cycles. Each program demonstrates key concepts in compiler construction, from lexical analysis to code generation.
| Cycle | Program | Path | Description |
|---|---|---|---|
| Cycle 1 | p1 | Cycle1/p1 | Epsilon Closure Calculator - Computes ε-closure for finite automaton states |
| Cycle 1 | p2 | Cycle1/p2 | ε-NFA to NFA Converter - Converts ε-NFA to equivalent NFA |
| Cycle 1 | p3 | Cycle1/p3 | NFA to DFA Converter - Implements subset construction algorithm |
| Cycle 1 | p4 | Cycle1/p4 | DFA Minimization - Minimizes DFA using partition refinement |
| Cycle 2 | p5 | Cycle2/p5 | Lexical Analyzer in C - Hand-written scanner implementation |
| Cycle 2 | p6 | Cycle2/p6 | Name Substring Scanner - Flex-based pattern matching |
| Cycle 2 | p7 | Cycle2/p7 | Identifier Validator - Lex/Yacc based identifier syntax checker |
| Cycle 2 | p8 | Cycle2/p8 | Arithmetic Expression Calculator - Lex/Yacc expression evaluator |
| Cycle 2 | p9 | Cycle2/p9 | Intermediate Code Generator - Generates quadruples for C-like code |
| Cycle 2 | p10 | Cycle2/p10 | FOR Loop Validator - Syntax checker for C-style FOR loops |
| Cycle 3 | p11 | Cycle3/p11 | Operator Precedence Parser - Parses expressions using precedence relations |
| Cycle 3 | p12 | Cycle3/p12 | FIRST/FOLLOW Calculator - Computes FIRST and FOLLOW sets for CFGs |
| Cycle 3 | p13 | Cycle3/p13 | Recursive Descent Parsers - Top-down parsing implementations |
| Cycle 3 | p14 | Cycle3/p14 | Shift-Reduce Parser - Bottom-up parsing for arithmetic expressions |
| Cycle 4 | p15 | Cycle4/p15 | Three-Address Code Generator - Generates TAC for expressions |
| Cycle 4 | p16 | Cycle4/p16 | Target Code Generator - Converts intermediate code to assembly |
- Cycle 1: Focuses on finite automata theory and conversions
- Cycle 2: Covers lexical analysis and basic parsing using Lex/Yacc
- Cycle 3: Implements various parsing techniques and grammar analysis
- Cycle 4: Addresses code generation and optimization
Most programs can be built using gcc. For Lex/Yacc programs:
- Generate scanner:
flex file.l - Generate parser:
bison -d file.y - Compile:
gcc lex.yy.c y.tab.c -o program
See individual program READMEs for specific build and run instructions.
For detailed explanations, example inputs, and code walkthrough of any program, check its corresponding README file linked in the table above.