Garnish Compiler

Table Of Contents

About The Project

The development of compilers plays a crucial role in translating high-level programming languages into machine-readable code. In this project, we present the design and implementation of a compiler with all six phases using the Python programming language and the Tkinter library for creating a graphical user interface (GUI). The compiler is designed to support the translation of a high-level programming language into executable code, following the classic six-phase compilation process: lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization, and code generation. The lexical analysis phase involves breaking down the input program into a sequence of tokens, each representing a meaningful unit of the programming language. The tokens are identified using regular expressions and stored in a token stream. The syntax analysis phase parses the token stream and verifies whether the program adheres to the specified grammar rules. This phase utilizes a context-free grammar and constructs a parse tree to represent the syntactic structure of the input program. In the semantic analysis phase, the compiler performs type checking, scope resolution, and other semantic validations. It ensures that the program's semantics are consistent and conform to the language's rules. The intermediate code generation phase translates the parse tree into an intermediate representation (IR) code, which is a platform-independent and easier-to-optimize representation of the program. This phase aims to capture the essential operations and control flow of the program. The code optimization phase enhances the intermediate code by applying various techniques to improve its efficiency, such as constant folding, common subexpression elimination, and loop optimization.

Built With

The objective of this project is to design and implement a Python-based compiler with a graphical user interface (GUI) using the Tkinter library. The compiler will encompass all six phases of the compilation process: lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization, and code generation.

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Installation

Install .exe and run

Usage

The compilation process proceeds through the six phases seamlessly. The lexical analysis phase scans the source code and generates a token stream, which is then passed to the syntax analysis phase. The syntax analysis verifies the correctness of the code's structure by constructing a parse tree or abstract syntax tree (AST).

Contributing

Creating A Pull Request

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See [LICENSE](https://github.com//Garnish Compiler/blob/main/LICENSE.md) for more information.

Authors

  • Abhi Patel

Acknowledgements