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:
-
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.
-
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.
-
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
-
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.