info-gnuprologjava
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Info-gnuprologjava] GSoC'13 - Prolog for Java


From: Rishabh Garg
Subject: Re: [Info-gnuprologjava] GSoC'13 - Prolog for Java
Date: Tue, 16 Apr 2013 11:55:43 +0530

Dear Sir,

My project was to create a complete interpreter for Prolog written in OCaml, one of my favorite programming languages with Java. This interpreter takes in clauses and returns the answer on a query. I have attached three files out of which the first is a byte file which you can directly run by using the following command: "ocamlrun Run.byte". You need to have OCaml installed in your system to test this project. A very simple sample input and output snippet would be:

(* Facts and rules *)
a(1).
a(2).
b(X,Y) :- a(X), a(Y).

(* Query *)
b(X,Y)
X -> cons 1;Y -> cons 1;True

X -> cons 1;Y -> cons 2;True

X -> cons 2;Y -> cons 1;True

X -> cons 2;Y -> cons 2;True

Cut has also been implemented in the project. The code can be found by unzipping "Prolog Interpreter.zip" which has three files, namely, Afourlex.mll(a lexer for Prolog); Afourparse.mly(the parse for Prolog which contains the Interpreter and backtracking functions) and Maina4.ml(the main function which makes the interpreter work). The complete code where interpretation has been done is, as I mentioned, Afourparse.mly.


Also, I have worked on another project where I created a compiler-cum-interpreter for a sample generic language(which could be familiar to C++, Java or even Prolog). This was an advanced project where the entire compiler, interpreter and the stack machine were written in Prolog itself. This project made me extremely comfortable with Prolog and the intricacies of the language. I also got a feel of how a compiler and an interpreter could be written FOR any language IN any language. The source code of the same can be found in "Prolog.pl" which can be run using SWI Prolog as well as gprolog. I would like to apologize that Prolog.pl is not so well documented and modularized to readability as yet as the project is still not totally complete.

I would like you to take a look at these files, which have been my main stepping stones in the world of compilers and interpreters. Better yet, both these projects involved Prolog helping me gain great insight into the language. I feel I can do this project by rewriting the parser to support UTF-8 with which I am very familiar. Could you tell me which what kind of a patch would you like ? Any other comments or requests are also welcome.

Regards,
Rishabh Garg





On Mon, Apr 15, 2013 at 11:26 PM, Daniel Thomas <address@hidden> wrote:
Hello Rishabh Garg,

Sorry for the slow reply. Looking into rewriting the parser in a more
modern way such that it supports UTF-8 is a good project to do. To
evaluate how well you would be able to do it it would be good to see a
patch against the current GNU Prolog for Java code. Perhaps something
from https://savannah.gnu.org/bugs/?group=gnuprologjava ?

Can I see the Prolog compiler and interpreter you wrote? That sounds
like very applicable experience.

Regards,

Daniel

On Sat, 2013-04-13 at 20:02 +0530, Rishabh Garg wrote:
> This is a follow up to the mail I sent a couple of days ago. I would
> be obliged if I am given some encouragement for this project as I am
> very much familiar with the concept and interested in the same.
>
>
> Regards,
>
> Rishabh Garg
>
>
>
> On Thu, Apr 11, 2013 at 1:51 PM, Rishabh Garg
> <address@hidden> wrote:
>         Hi,
>         I am a sophomore, pursuing Computer Science And Engineering,
>         in the Indian Institute Of Technology Delhi. I found this
>         project 'Prolog for Java' very interesting and I think that I
>         can greatly contribute to it, using my experience in this
>         field.
>         I have done most of my coding projects in Java and I am very
>         thorough and comfortable with the same. I recently made an
>         interpreter as well as a compiler for Prolog so I am very
>         familiar with backtracking and cuts.
>
>         Extending UTF-8 support will be a great benefit to the
>         Computer Science benefit. I have had complex parsing
>         assignments and I am very deeply interested in doing the same.
>
>         A few pointers to start with the project would be greatly
>         appreciated. Also, please let me know if there is a forum
>         where this project is being discussed.
>
>
>
>         Regards,
>         Rishabh Garg
>
>
>
>


Attachment: Run.byte
Description: Binary data

Attachment: Prolog Interpreter.zip
Description: Zip archive

Attachment: Prolog.pl
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]