Skip to content

Design of a simple compiler for a simplified Java language using ANTLR v4.10.1.

Notifications You must be signed in to change notification settings

OleJorgenKnoph/Compiler-INSA

Repository files navigation

Compiler

Design of a simple compiler for a simplified Java language using ANTLR v4.10.1. Part of a project during my semester abroad the spring of 2022 at INSA Toulouse, France.

Testing

Display of the testing of the two test-files attached. With the code, output and generated parsetree.

TestFile1.txt

public static void main(String[] args){
    int a,b,c = 0;
    b=1;
    c=2;

    int d = (c*c)+(c*b);

   System.out.println(a);
   System.out.println(b);
   System.out.println(c);
   System.out.println(d);
 }

Output

Output alongside given assembly code

Skjermbilde 2022-06-03 kl  01 41 56

ParseTree

ParseTree generated after running main

parseTree1

TestFile2.txt

public static void main(String[] args){
    int a_1, b_2, c_3 = 0;

    a_1 = 10.5;
    b_2 = 20;
    c_3 = 15;

    if ( a_1 < b_2){
        System.out.println(c_3);
    }
    else {
        System.out.println(b_2);
    }

    System.out.println(a_1);
}

Output

Output alongside given assembly code

Output 1 - Output with code equal to displayed over

Skjermbilde 2022-06-03 kl  01 52 08

Output 2 - Output when '<' is switched in code to ensure if/else works as supposed

if ( a_1 > b_2)

Skjermbilde 2022-06-03 kl  01 52 23

ParseTree

ParseTree generated after running main

parseTree2

About

Design of a simple compiler for a simplified Java language using ANTLR v4.10.1.

Topics

Resources

Stars

Watchers

Forks