Re: Compiling Prolog-like languages

"Kurt M. Alonso" <kurt.magnus.alonso@mailbox.swipnet.se>
10 Aug 2002 02:28:29 -0400

          From comp.compilers

Related articles
[6 earlier articles]
Re: Compiling Prolog-like languages rwaltman@verizon.net (Roberto Waltman) (2002-07-04)
Re: Compiling Prolog-like languages thomasl@erix.ericsson.se (Thomas Lindgren) (2002-07-15)
Re: Compiling Prolog-like languages adamo@dblab.ece.ntua.gr (Yiorgos Adamopoulos) (2002-07-15)
Re: Compiling Prolog-like languages ptarau@yahoo.com (Paul Tarau) (2002-07-15)
Re: Compiling Prolog-like languages oz@blue.cs.yorku.ca (ozan s yigit) (2002-07-15)
Re: Compiling Prolog-like languages firefly@diku.dk (Peter Finderup Lund) (2002-07-21)
Re: Compiling Prolog-like languages kurt.magnus.alonso@mailbox.swipnet.se (Kurt M. Alonso) (2002-08-10)
Re: Compiling Prolog-like languages bmd@cs.kuleuven.ac.be (Bart Demoen) (2002-08-14)
Re: Compiling Prolog-like languages Jens_Kilian@agilent.com (Jens Kilian) (2002-08-14)
| List of all articles for this month |

From: "Kurt M. Alonso" <kurt.magnus.alonso@mailbox.swipnet.se>
Newsgroups: comp.lang.prolog,comp.compilers
Date: 10 Aug 2002 02:28:29 -0400
Organization: http://groups.google.com/
References: 02-07-004 02-07-048
Keywords: design
Posted-Date: 10 Aug 2002 02:28:29 EDT

"Paul Tarau" <ptarau@yahoo.com> wrote in message news:02-07-048...
> "Sarah Thompson" <sarah@telergy.com> wrote
>
> > I am in the process of designing and implementing a compiler for a
> > special purpose programming language that is intended to facilitate
> > the implementation of natural language chat systems (chatterbots).
> ....
> > Prolog-like syntax would dovetail neatly with the language's existing
> > syntax (think of something like, lex, yacc and bash glued together,
> > but with much more capable NL parsing functionality, and you'd be
> > somewhere in the right direction).
> ....
> > 3. I currently use C++ as a target language, although this is intended
> > to be an interim step toward a lower level code generator. Is this
> > likely to be good/bad/indifferent as regards implementing a WAM or
> > something similar to it?
>


Actually, if you use goal stacking and classes to represent
predicates, it should be quite easy to compile into C++, or for that
matter, into Java. In fact, I haven't had too much to do at work
these last weeks and I have entertained myself writing a Prolog
compiler in the Perl language that outputs C++ code. Best of all, the
compiler itself is less than 400 lines of code (360 at the moment). I
will be adding some obvious optimizations in the next weeks, like tail
recursion, but I don't expect to exceed 500 lines of perl for the
whole thing. Naturally, I have also had to write a few support
classes.


Regarding the WAM, I never really liked it. If you are going to go the
interpreter way, I would recommend you to take a look at the VAM
(Vienna Abstract Machine) instead. As I remember it, it was many times
simpler than the WAM, and probably superior in performance. Sorry, no
references, it's been more than 10 years since I looked into the
subject.






By the way, is there a PD prolog parser anywhere on the net? If I am
not mistaken, Richard O'Keefe had made a prolog lexer of his available
to the community. Does anyone know where it can be found? I might
want to rewrite the compiler at a later stage, but this time in
Prolog.




Kurt


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.