Giter Site home page Giter Site logo

kevinrezae / not_quite_java Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3.47 MB

A simple compiler for a subset language of java called not_quite_java.

Lex 0.70% HTML 3.53% CSS 0.22% JavaScript 0.30% TeX 0.88% Java 53.90% LLVM 40.48%
java compiler-construction llvm

not_quite_java's Introduction

not_quite_java compiler

It is a simple compiler for a subset of language java called not_quite_java. Its code will be runnable by JVM.

Analysis

Under the Analysis phase, we tried to cover several topics such as:

  • Name Analysis

    We need to have records of available and visible variables, classes, and functions for name analysis.

  • Field visibility

    At any point in the program, a field will be visible if its name is inside the scope’s registered field names.

  • Field name uniqueness

    When putting a new variable in each scope, we check if the field name is unique

  • Overloading

    A class can have multiple function declarations with the same name and different parameter lists and types.

  • Overriding

    A class that extends some other class can have a function with the same signature as functions in the superclass.

  • Shadowing

    We have two levels of shadowing,

    • A class has a field with the same name as its parent class’s field. It is called Hiding.

    • A block has a field with the same name as its parent class’s field. It is called Shadowing.

  • Obscuring

    A class may have a field with the same name as a class or a class function.

  • Cycle conflict

    It may happen if a class extends itself or another class that extends the first class.

-Name lookup

 When a variable being used, we look if the variable is registered in the current scope.

Type checking

For type checking phase we considered following topics:

  • Variable usage

    We first check the current function or bracket scope for the given name of the used variable; if we found it, we will attach the declaration into the variable use expression.

  • Field access

    We will check if we have such a name registered in the current class at the time of field access.

  • New object creation

    We will check if the class type of new object exists and is registered in our name table.

  • Function call

    We first check if we have a class with the same name and signature in the current class scope or extended classes. If we found a matching function, we will attach the declaration to the function call. If not, we will check global functions for matching signatures.

  • Method call

    We first find the class type for the method’s caller. If we found a correct type for it in our name table, we will attach the declaration to it and check if we have a function with a matching signature inside its scope or its extended scopes.

  • Assignment

    We will find the type of right and left-hand side of the expression.

License

MIT

not_quite_java's People

Contributors

kevinrezae 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.