POPEYE - A Linear Logic Programming Language that Translates to Java Authors ------- Dale Miller and Alex Betis Mostly worked on this during Summer and Fall 1999 The Language and its foundations are exposed in details in Alex's Master's Thesis, available for download at http://www.cse.psu.edu/~dale/betis/ Current distribution -------------------- Requirements ------------ You need a working version of SML of New Jersey, with the Terzo Lambda Prolog distribution built onto it. This distribution, as well as instructions on how to install it, are available at http://www.cse.psu.edu/~dale/ Modules ------- The Popeye system makes use of the following modules: popeye.sig : Signature file for the Popeye language java.sig : Signature file for some Java-specific commands. interp.mod : Interpreter for the language tchecker.mod : Type-inferer/checker for the language spinach.mod : Java code generator For running the interpreter, only the first three files are needed. For the typeckecker, the first four. For the Java code generator, all of them must be loaded in Terzo. We also provide examples. The trivial switch is given in: switch.pop.mod : Switch example This file must also be loaded in Terzo if we want to use switches in the system. Usually, though, each object foo is represented by three (and not only one) files. - The foo.pop.sig contains the Lambda Prolog signature of the object - The foo.pop.mod contains the code for the object - The foo.pop.spi contains the type-checking rules and the code generation rules. We provide the following objects (which are all detailled in the MS Thesis): cell.pop.* : A simple cell to be put into a queue queue.pop.* : A FIFO queue using cells wire.pop.* : An object representing an electrical wire. gate.pop.* : An abstract mother class for logical gates. unigate.pop.* : An abstract mother class for logical gates with only one input. Inherits gate.pop.*. bigate.pop.* : An abstract mother class for logical gates with two inputs. Inherits gate.pop.*. notgate.pop.* : A NOT gate object. Inherits unigate.pop.* andgate.pop.* : A AND gate object. Inherits bigate.pop.* Finally, we provide a few starters to automate the load process in Terzo. go : #load all the files related to logical gates as well as those needed for the system to work (that is, all the base Popeye modules). qgo : Same as above but for the queue object. Examples -------- Interpreter ----------- This is a few examples of what can be done in the interpreter. With the queue -------------- #query queue, cell, queuespi, cellspi, interpreter, typechecker, spinach. ?- interp nil nil (new queue q\ enqueue q (pint 1)) end. solved ?- interp nil nil (new queue q\ enqueue q (pint 1) >> enqueue q (pint 2) >> dequeue q C) end. C = pint 1; no more solutions. ?- interp nil nil (new queue q\ enqueue q (pint 1) >> enqueue q (pint 2) >> dequeue q C >> dequeue q D ) end. C = pint 1 D = pint 2; no more solutions. ?- tcheck nil queue nil tmod nil. loc context prog clause t-check empty prog pi pi clause t-check t-check . . . t-check t-check t-check t-check branch branch t-check solved ?- spinach nil nil queue Java. clause t-check empty . . . branch branch t-check !!!!!!!!!!!!!!! Java = "public class Queue extends Object{ Cell head; Queue(){ . . . obj=newQ.dequeue();} } return obj; } } " ?- With the gates -------------- #query list, listspi, gate, gatespi, unigate, unigatespi, notgate, notgatespi, bigate, bigatespi, andgate, andgatespi, interpreter, typechecker, spinach. ?- interp nil nil ( new wire a\ new wire b\ new wire c\ new andgate a b c g\ set_signal a (pcst wire on) >> set_signal b (pcst wire off) >> get_state g S) end. S = (pcst wire off) ?- Of course, what can also try backtracking but it made my Celeron explode. Typechecker and Spinach are used in a similar fashion to the queue. ?- tcheck nil andgate nil tmod nil. . . . solved ?- spinach nil nil andgate Java. Java = . . . solved Additionnal stuff ----------------- We put the java code generated with some testing code in the java/ subdirectory. You need Java 1.7 and higher to compile the code. The code for the Prolog-like list object in Java (PopList.java) was not generated but hand-written, for the motives exposed in the "examples" section of the thesis. It was tested but is not considered optimum. Its coding was necessary for the logical gates example to work. TO DO ----- This work is very alpha, very fault-intolerant and as a consequence requires a lot of tolerance from the potential user. :) An effort should be made to provide a better environment for all this. A better parser for the language Automatic .spi file generation or "on-the-fly" extraction Lots o' stuff... (See MS thesis) Alex - 20/01/00