/COMPILER-LAB-CSL-411-S7

This repository contains all the necessary programs and solutions for the KTU Compiler Lab. Ideal for KTU University students, this collection covers each lab experiment, code examples, and explanations as per the official syllabus.

Primary LanguageC

KTU Compiler Lab Programs

This repository contains a collection of programs for the Compiler Lab course, designed specifically for Kerala Technological University (KTU) students. Each program aligns with the lab experiments outlined in the KTU syllabus, covering key concepts in compiler design.

📜 Table of Contents

  1. Design and Implement a Lexical Analyzer (C Language)
  2. Lexical Analyzer Using Lex Tool
  3. Count Lines, Words, and Characters (Lex Program)
  4. Convert Lowercase to Uppercase (Lex Program)
  5. Count Vowels and Consonants (Lex Program)
  6. Arithmetic Expression Recognition (Yacc)
  7. Identifier Recognition (Yacc)
  8. Calculator Using Lex and Yacc
  9. E-Closure of All States
  10. First and Follow of Given Grammar
  11. Shift-Reduce Parser Implementation
  12. Code Optimization Simulation
  13. Intermediate Code Generation
  14. 8086 Assembly Code Backend Implementation

1. Design and Implement a Lexical Analyzer (C Language)

  • Date: 26/07/24
  • Description: A C program to implement a basic lexical analyzer that identifies tokens in a given input.

2. Lexical Analyzer Using Lex Tool

  • Date: 09/08/24
  • Description: Using Lex, this program builds a lexical analyzer for a specific programming language.

3. Count Lines, Words, and Characters (Lex Program)

  • Date: 16/08/24
  • Description: Lex program that counts lines, words, and characters in an input file.

4. Convert Lowercase to Uppercase (Lex Program)

  • Date: 16/08/24
  • Description: A simple Lex program to convert all lowercase characters to uppercase.

5. Count Vowels and Consonants (Lex Program)

  • Date: 16/08/24
  • Description: This Lex program counts the number of vowels and consonants in the given input.

6. Arithmetic Expression Recognition (Yacc)

  • Date: 23/08/24
  • Description: Yacc specification to recognize and validate arithmetic expressions.

7. Identifier Recognition (Yacc)

  • Date: 23/08/24
  • Description: Yacc specification to recognize identifiers within a code.

8. Calculator Using Lex and Yacc

  • Date: 23/08/24
  • Description: A calculator program built using Lex and Yacc, supporting basic arithmetic operations.

9. E-Closure of All States

  • Date: 09/10/24
  • Description: Program to compute the epsilon-closure of all states in an NFA.

10. First and Follow of Given Grammar

  • Date: 09/10/24
  • Description: This program calculates the first and follow sets of a given grammar.

11. Shift-Reduce Parser Implementation

  • Date: 16/10/24
  • Description: Implements a shift-reduce parser for parsing a given input.

12. Code Optimization Simulation

  • Date: 16/10/24
  • Description: Simulates basic code optimization techniques to improve efficiency.

13. Intermediate Code Generation

  • Date: 18/10/24
  • Description: Generates intermediate code for simple expressions.

14. 8086 Assembly Code Backend Implementation

  • Date: 19/10/24
  • Description: Implements the backend of a compiler that converts three-address code into 8086 assembly language.

  • Install Lex and Yacc tools.

How to Run

  1. Clone the repository:
    git clone https://github.com/yourusername/KTU-Compiler-Lab-Programs.git

2.Navigate to the desired program directory. 3.Compile and run the program using appropriate commands.