Skip to content

rahul-bangar/Compiler-Project

Repository files navigation

C/C++ Compiler for while loop with nested while loop and/or if-else constructs.

Simulation of the front-end and back-end phase of a C compiler involving the If-Else, While and nested If-Else-While constructs.
This includes SIX phases of a compiler:

  1. Lexical Analysis- Entering into an Input Table.
  2. Syntactic Analysis- Creation of an Abstract Syntax Tree.
  3. Semantic Analysis- Verifying Type compatability and generating the Intermediate Code.
  4. Intermediate Code Generation - Three Address code generated in Quadruples
  5. Machine Independent Code Optimization - Constant Folding, Common Sub-Expression Elimination, Dead Code Elimination
  6. Assembly Code Generation - Final Target Code

To Run the programs run compile.sh file:

./compile.sh

Few informations about the files -

  • lexer.l is the lexical analyzer which is written in lex.
  • parser.y runs parser which is written in YACC.
  • y.tab.h and y.output (debugger for parser).
  • GenInput.txt - Parser generated Quadruples INPUT to generate Assembly Language.
  • OpInput.txt - Three address code INPUT for Code optimization.
  • Python scripts are used for Assembly code generation from quadruples.
  • Extra 1 python script is given to show separate Code Optimization.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •