Skip to content

bartheart/Lexical-Analyzer-in-C-Honors-College-project-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

unt honors logo

C Compiler Lexical Analyzer πŸš€

πŸ“ Table of Contents

πŸš€ Project Overview

A robust lexical analyzer for C programming language, designed to convert raw source code into meaningful tokens for compiler processing.

lexer workflow

πŸ” Project Background

A lexical analyzer (lexer) is a crucial component of a compiler that performs the following key functions:

  • Scans source code character by character
  • Groups characters into predefined token sets
  • Prepares tokens for syntax analysis in subsequent compiler stages

lexer process

🎯 Project Objectives

The primary goals of this lexical analyzer include:

  • Converting abstract character streams into meaningful tokens
  • Supporting comprehensive C language syntax parsing
  • Providing efficient and accurate token generation
  • Implementing robust error handling and debugging mechanisms

✨ Key Features

Comprehensive Token Recognition

  • Identifies various C language tokens
  • Supports multiple comment styles
  • Handles whitespace and special characters

Flexible Input Handling

  • Supports standard input
  • File-based input processing
  • Debugging mode capabilities

Advanced Parsing Mechanisms

  • Finite state machine implementation
  • Character-level analysis
  • Line and column tracking

πŸ’» Technologies Used

  • Programming Language: C
  • Parsing Technique: Finite State Machine
  • Development Tools:
    • GCC Compiler
    • Valgrind (for memory debugging)
    • Make (build automation)

πŸ›  System Requirements

Hardware Requirements

  • Minimum RAM: 2 GB
  • Processor: x86_64 architecture
  • Disk Space: 100 MB

Software Prerequisites

  • GCC Compiler (version 7.0+)
  • GNU Make
  • Linux/Unix environment (recommended)

Getting Started

Installation

  1. Clone the repository
git clone https://github.com/yourusername/lexical-analyzer.git
cd lexical-analyzer
  1. Compile the project
make

πŸ”§ Usage

Basic Usage

./lexer input_file.c

Debugging Mode

./lexer -d input_file.c

πŸ—οΈ System Architecture

lexer workflow

Lexer Components

Input Buffer

  • Temporary storage for source code
  • Preprocesses input (comment removal)
  • Manages file reading efficiently

Tokenizer

  • Converts character streams to tokens
  • Tracks line and column positions
  • Supports multiple token types

Token Types

  • Identifiers
  • Keywords
  • Operators
  • Literals
  • Special Symbols

Demo Results

Basic Arithmetic Operations

lexer workflow

lexer workflow

Complex Operations

lexer workflow

lexer workflow

Entire Source Code

lexer workflow

Video Demo

[Demo Video] https://www.youtube.com/watch?v=vd4PzbtRP8U

🀝 Contributing

  • Fork the repository
  • Create your feature branch (git checkout -b feature/AmazingFeature)
  • Commit your changes (git commit -m 'Add some AmazingFeature')
  • Push to the branch (git push origin feature/AmazingFeature)
  • Open a Pull Request

πŸ“„ License

Build Status Language License: MIT

Distributed under the MIT License. See LICENSE for more information.

πŸ‘₯ Contact

Bemnet Mekrebu - bemnetmerkebu17@gmail.com

Project Link: https://github.com/yourusername/lexical-analyzer

πŸ™ Acknowledgements

  • Dr. Tejasvi Parupudi (Project Supervisor)
  • CSCE 3600 Class, Spring 2023

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages