Skip to content

AsfarHorani/My-Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Certainly! Here's an updated and detailed project description:


Compiler Construction Project Overview:

As part of my comprehensive study in compiler construction, I undertook a project aimed at designing and implementing a compiler for a high-level programming language. This project involved various phases to transform source code into executable machine code. The primary areas covered in this compiler project include:

  1. Lexical Analysis:

    • Objective: Validate Keywords and Identify Tokens
    • Description: The initial phase of the compiler focused on lexical analysis. This involved the creation of a lexer responsible for validating keywords and breaking down the source code into fundamental units called tokens. By employing lexical rules, the lexer ensured the accurate identification and categorization of language elements, such as keywords, operators, identifiers, and literals.
  2. Tokenization:

    • Objective: Token Generation
    • Description: Following successful lexical analysis, the project delved into the tokenization phase. The tokenization process involved creating a set of tokens based on the recognized lexical elements. This step laid the foundation for subsequent phases, providing a structured representation of the source code that could be easily processed in further compilation stages.
  3. Syntax Analysis:

    • Objective: Verify Syntax using Context-Free Grammars (CFG)
    • Description: Syntax analysis, or parsing, played a pivotal role in ensuring that the source code adhered to the specified language syntax. Context-Free Grammars (CFG) were employed to define the syntactic rules of the language. A parser was implemented to construct a syntax tree, representing the hierarchical structure of the program based on the grammar rules. More description about cfg can be found in /CFG directory
  4. Semantic Analysis (researched but not implemented yet let me know if anyone willing to contribute):

    • Objective: Check for Scope and Enforce Semantic Rules
    • Description: The semantic analysis phase focused on verifying the correctness of the program's meaning beyond just syntax. This involved checking for variable scoping, type consistency, and other semantic rules defined by the programming language. A symbol table was utilized to store and manage information about variables, functions, and other program entities, contributing to a more robust analysis of the source code.

The completion of these phases marked significant progress in developing a functional compiler, providing a solid foundation for subsequent stages such as intermediate code generation, optimization, and code generation. The project aimed to enhance understanding and practical skills in compiler construction, enabling the conversion of high-level programming constructs into efficient machine code.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages