Giter Site home page Giter Site logo

compiler-project's Introduction

java-compiler

Project description

The objective of this project is to take a java file and then generate an intermediate java file with injected java statements, when running this file it prints out which blocks are executed and which are not, another output is an HTML for the input java file with highlighted green parts indicating the executed code and highlighted red parts indicating the code that does not execute.

Starting rule

compilationUnit
: packageDeclaration? importDeclaration* typeDeclaration*
| moduleDeclaration EOF
;

Example program

public class Test {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}

Parse tree

Parse tree

Complete example

Test1 code

package Test;
public class Test1 {
    public static void main(String[] args) throws Exception{
        int x=1;
        int y=2;
        if (x>0) {
            if (x == 2)
                System.out.println("IF Block");
        }
        else
                if (y==2)
                    System.out.println("IF Block");
        switch(x) {
            case 5:
                System.out.println("This is a 5");
                break;
            case 1:
                System.out.println("This is a 10");
                break;
        }
        for(int i = 0 ; i<5;i++) {
            for (int j = 0; j < 5; j++)
                if (x > 0)
                    System.out.println("If operations");
                else {
                    System.out.println("Else block");
                }
        }
        int z = 0;
        while (z < 5) {
            if(y==5)
                System.out.println("While loop");
            z++;
        }
    }
}

Intermediate java code

Intermediate java code

Output text file with executed blocks

Output text file

Highlighted HTML output

Highlighted HTML output

compiler-project's People

Contributors

adhamsalama avatar mahmoudmohamed22 avatar mohamed-shafei20 avatar muhammadmohie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.