Code Monkey home page Code Monkey logo

javabien's Introduction

The minijavac compiler

pipeline status

A compilation project for Third year students of Telecom Bretagne.

'ocamlbuild Main.byte' (or native) to build the compiler. The main file is Main/Main.ml, it should not be modified. It opens the given file, creates a lexing buffer, initializes the location and call the compile function of the module Main/compile.ml. It is this function that you should modify to call your parser.

'ocamlbuild Main.byte -- ' (or native) to build and then execute the compiler on the file given. By default, the program searches for file with the extension .java and append it to the given filename if it does not end with it.

If you want to reuse an existing ocaml library. Start by installing it with opam. For example, to use colored terminal output you use 'opam install ANSITerminal'. Then you must inform ocamlbuild to use the ocamlfind tool : 'ocamlbuild -use-ocamlfind Main.byte -- tests/UnFichierDeTest.java' et vous devez ajouter au fichier _tags la bibliothèque en question par exemple : true: package(ANSITerminal)

Quickstart

Building is done using the given Makfile:

Create the main binary:

make

# print the Ast tree:
./Main.native -v <java file>

Run the lovely hand crafted suite:

make test-all

More commands

Run the provided JDK tests:

make test-jdk

List existing tests receipes:

make test-list

Create the _build/errors.txt file which list the possible error states:

make list-errors

See Makefile for every make receipes.

Test suite

In order to verify the validity of the parsing process, we have design a simple test suite that helps us track down issues and regressions introduced down the line. These tests can be launched with the make test-all command.

The Test/ folder contains multiple subfolders dedicated to each test suite:

  • block_statements_files: Files to test the block language
  • classes_files: Files to test the classes language
  • expression_files: Files to test the expressions parsing
  • must_fail_files: Contains files that must not compile

Tests can be arbitrarly disabled by appending .disabled to the file name. In which case the test suite will show them as skipped.

For every commit, in order to quickly catch regressions, the test suite is automatically runned by the Gitlab Continuous Integration suite (CI). The builds can be found at the following address: https://gitlab.com/commentjava/commentjava/pipelines

We noticed that some methods and syntaxes were not always working on every Ocaml versions(e.g. commit 9d8ad5560641329ffb42583166cc2f38ab40d96e). We created a script based on Docker to test multiple versions of Ocaml without installing them. See script docker_test.sh for more info.

Quick bash script to spot failures locations in tests:

make test-jdk 2>&1 |\
ag "\Test.*error" |\
awk '{print $2 " " $4}' |\
while read x y read; do;
   echo "> $x Line $y:" ;
   awk "{ if(NR==$y) print \$0 }" $(echo $x | tr -d '"');
   echo "";
done;

Java Specification Language compliance and divergence

TODO:

  • Annotation of annotations
  • Limits on types
  • Limits on cast expressions

Miscellaneous notes

Some jdk tests fail intentionnaly, thoses tests don't follow the JSL for Java SE 6. We specifically decided to follow the specification instead of doing 100% parsing success rate on the provided JDK source code.

Purposefully failing test files:

  • Invalid for constructor:
    • Test/jdk/src/java/text/MergeCollation.java L107
  • Invalid variable name enum:
    • Test/jdk/src/com/sun/corba/se/internal/Activation/RepositoryImpl.java L111
    • Test/jdk/src/com/sun/corba/se/internal/core/ServiceContextRegistry.java L64
    • Test/jdk/src/com/sun/security/auth/PolicyFile.java L472
    • Test/jdk/src/com/sun/security/auth/PolicyParser.java 247
    • Test/jdk/src/java/awt/datatransfer/MimeTypeParameterList.java L45
    • Test/jdk/src/java/awt/geom/Area.java L193
    • Test/jdk/src/java/awt/image/MemoryImageSource.java L332
    • Test/jdk/src/java/security/PermissionCollection.java L161
    • Test/jdk/src/java/security/Permissions.java L507
    • Test/jdk/src/java/security/Security.java L510
    • Test/jdk/src/java/text/RuleBasedBreakIterator.java L1375
    • Test/jdk/src/java/util/jar/JarFile.java L209

javabien's People

Watchers

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