Clone wiki

inf225public / Language Specification in Prolog

(@Anna Maria Eilertsen)

  • What did you do? My project is about structural operational semantics of programming languages. It is also about type checking and Objects. I implemented the type checker of Featherweight Java in Prolog. I almost have it working as a partial evaluator, but then I would have to rephrase the code a bit.

  • Why did you do it? I found the idea of formally defining languages interesting. I also wanted to understand Objects and classes in general, and Featherweight Java proved to be an excellent opportunity for this. I also wanted to work more with Prolog.

  • How did you do it? I had to learn a lot of definitions of structural operational semantics to understand the notation in the FJ article, and then I had to understand the article (or the first two-three chapters of it). Then I tried to translate the definitions into somewhat easily readable Prolog code. I found a Swedish bachelor project where the author had tried to do exactly what I wanted, which helped a bit, until I figured out that not only was his Prolog code really bad, but he had misunderstood the FJ semantics so his type checker did in fact not work. As I said I almost have a partial evaluator, as I wrote this code without the intention of making that, I would have to change a lot to make that work flawlessly, which I haven't.

  • How did it go? My type checker works perfectly. I can also use it for partially evaluating some expressions, but it is not even close to being an evaluator, which is fine considering I did not intend to make that.

  • What did you learn? I learned how to read and write structural operational semantics, how a type checker works, and how to write this in Prolog. I gained a much better understanding of classes and Objects (in Java), and they are now much less magical. I learned how you define abstract syntax and big step/small step-semantics, and how to make the derivation tree of some expression - which is pretty much how Prolog works.

Updated