Skip to content

Oh-My-Compiler/Intermediate-Code-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intermediate Code Generator

forthebadge forthebadge forthebadge

Voila, we have reached the last phase ✨. ICG is the third phase of my compiler (Genepiler). It's planned to join my 'Oh My Compiler' project!

The name of this phase is a little bit misleading. The phase compacted the last three phases of a typical compiler (Intermediate Code Generator - Code Optimizer - Target Code Generation).

This phase takes the lexemes from the first phase along with the actions from the second phase and produces java code 🙌


Table of Contents:


Easy Steps:

  • Step one : Token
  • Step two : Parse tree
  • Step three: AST
  • Step Four: IC

Tasks

  • build parsing tree

  • show tree

  • simplify tree

  • add lexemes

  • make sure to delete nodes (free/del)

  • lift operands up

  • build AST

  • swap relop with 2 conditions (>=) --> !(<)

  • IC

  • backpatching

  • remove duplicate labels (at most 2)

  • remove print logs

  • consider module file to add your modules in

  • optimize backpatching

  • add arguments (argparse)

  • consider add directory for input and directory for output

  • report

New Tasks:

  • fix bugs
  • consider generalizing the last phase

Bugs 🐞:

🤔 I believe I've fixed most of the bugs (maybe all of the them).

  • check_type is not working properly in some cases

added a couple of lines to fix it temporarily

  • get_val_2 & get_virtual shall be combined. Yet, some functions are not working then
  • try to add flag
  • let it return a list of virtual nodes to work with separately
  • do not declare multiple (seems to get something wrong) - check logic [not informative]

  • backpatching not working when no labels


Notes

  • what if num is neg (is that handled?)
  • handle range to be general (check phase 1)

Running Jasmin

  1. put your code in .j file
  2. run the folowing command bash java -jar jasmin.jar file.j
  3. now a class file is generated, to run: java file

[Memory] Plan (schedule)

  • Today: 14 May
  • Actual Deadline: 30 May 6 Jun
  • Phase Deadline: 20 May

3 days to just implement this
1 day for the report

Schedule:

  • 14 May 2020 Getting to know what's going on
  • 15 - 20 May 2020 : Build the program

About

Generates byte codes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published