Coder Social home page Coder Social logo

compiler-insa's Introduction

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

compiler-insa's People

Contributors

olejorgenknoph avatar

Stargazers

 avatar

Watchers

 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.