Skip to content

AthulSabu2002/S7-Compiler-Lab

Repository files navigation

S7 Compiler Lab

Welcome to the S7 Compiler Lab repository! This collection of experiments is designed to provide hands-on experience with various aspects of compiler design and implementation.

📚 Table of Contents

  1. Lexical Analysis
  2. Syntax Analysis
  3. Code Optimization
  4. Code Generation

🧪 Experiments

Lexical Analysis

  1. Custom Lexical Analyzer (C)

    • Implement a lexical analyzer to recognize valid tokens in an input program
    • Handle spaces, tabs, newlines, and comments
  2. Lex Tool Experiments 2.1. Implement a Lexical Analyzer using Lex 2.2. Count lines, words, and characters in an input text 2.3. Convert substring 'abc' to 'ABC' in an input string 2.4. Count vowels and consonants in an input string

Syntax Analysis

  1. YACC Specifications 3.1. Recognize valid arithmetic expressions (+, -, *, /, parentheses) 3.2. Recognize valid identifiers (letter followed by letters/digits) 3.3. Implement a calculator using LEX and YACC

  2. NFA ε-Closure

    • Find ε-closure of all states in an NFA with ε-transitions
  3. First and Follow Sets

    • Calculate First and Follow sets for a given grammar
  4. Shift-Reduce Parser

    • Construct a Shift-Reduce Parser for a given language

Code Optimization

  1. Code Optimization Techniques
    • Simulate various code optimization techniques

Code Generation

  1. Intermediate Code Generation

    • Generate intermediate code for simple expressions
  2. Backend Compiler Implementation

    • Implement a compiler backend that converts three-address code to 8086 assembly language

🚀 Getting Started

To run these experiments, you'll need:

  • A C compiler (e.g., GCC)
  • Lex/Flex
  • YACC/Bison

📝 Note

This repository is part of the CSL411 Compiler Lab course. Each experiment is designed to reinforce specific Course Outcomes (COs) related to compiler design and implementation.

🤝 Contributing

Feel free to fork this repository and submit pull requests for any improvements or additional experiments you'd like to share!


Happy coding and enjoy your journey into the world of compiler design! 🖥️✨

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published