Skip to content

Implementation of the calculus Featherweight Java (Principles and Paradigms of Programming Languages a.y. 2018/2019).

License

Notifications You must be signed in to change notification settings

A-725-K/Featherweight-Java-FJ-Calculus

Repository files navigation

Interactive Interpreter for FJ Calculus

Implementation of an interactive interpreter for the calculus Featherweight Java.

Info

This project was entirely developed under Parrot OS operating system, in GNU-Emacs text-editor, with the well-known software engineering technique Test First. The aim of this project is part of the exam Principles and Paradigms of Programming Languages that took place at the University of Genoa, during the second semester of the academic year 2018/2019 for the Master Degree in Computer Science. The code is written in Haskell with the only exception of the tests, since they are written in Bash.

Getting started

First of all you have to clone or download this repository, with the command:

git clone https://github.com/A-725-K/Featherweight-Java-FJ-Calculus.git

The Makefile has been thought to simplify the life of the end user. So to compile the project it is sufficient to execute the following command:

make

The tests have been written exploiting a framework for unit testing of the Bash language which is called Bats. This choice is due to the fact that to load a class table as a context for the execution of your FJ program is quite a long work. It is simpler to wirte all the class definitions in a file and then load it into the interpreter. Moreover the command line of a GNU/Linux system offers some useful tools to check the results generated by the execution of the program.
If you haven't already installed it on your system and for more information about Bash Automatic Testing System you can click here and check on the main page of the project.

Finally, once you have compiled the project and installed Bats, you have two choices:

1. Run the tests, with the command:

make tests

2. Launch the interpreter, with the command:

./FJ_Interpreter.exe

and then follow the instructions inside the program.

How to use the interactive interpreter

  • Starts the interpreter
  • Give a file that contains the class declarations in input
    • If the file does not exist, it will be notified
    • The parser tries to create an AST starting from the content of the input file
    • A typechecking operation of the class table takes place
    • If an error arises during these two phases, the user receive a notification
  • Give an expression to the interpreter
    • Again the expression is parsed and then typechecked
    • If it is statically correct than it is interpreted, otherwise an error is given in output

Brief description of files

  • MainFJ.hs: the main of the interactive interpreter
  • MonadicParserFJ.hs: all the parsers for the input
  • TypeCheckerFJ.hs: functions related to typechecking
  • InterpreterFJ.hs: interpreter ans substitution function
  • DataTypesFJ.hs: all the user defined data types used in the program
  • UtilitiesFJ.hs: a bunch of functions useful and some pre-loaded program for testing inside the interpreter
  • unit_test.sh: definition of all unit testing
  • Makefile: contains the real commands to compile the program and execute the tests

Grammar

p   ::= cd_1 ... cd_n
cd  ::= class C extends C' { fds mds }
fds ::= fd_1 ... fd_n
fd  ::= C f;
mds ::= md_1 ... md_n
md  ::= C_0 m(C_1 x_1, ..., C_n x_n) { return e; }
e   ::= x | e.f | e_0.m(e_1, ..., e_n) | new C(e_1, ..., e_n) | (C)e | ( e )

Author

  • Andrea Canepa - Computer Science, UNIGE - Principles and Paradigms of Programming Languages a.y. 2018/2019

About

Implementation of the calculus Featherweight Java (Principles and Paradigms of Programming Languages a.y. 2018/2019).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published