Is there a straight-forward way of compiling Prolog to C?
Two methods of compiling Prolog to C have been reported in the literature: – WAM-based approaches – Continuation-based approaches The WAM-based approach compiles Prolog programs into a sequence of C function or macro calls to WAM instructions. A brief description of this method and some results are given in the paper: Michael R. Levy and R. Nigel Horspool, “Translating Prolog to C: a WAM-based Approach”, in Proceedings of the Second Compulog Network Area Meeting on Programming Languages, and the Workshop on Logic Languages in Pisa, May 1993. (Available by anonymous ftp from csr.uvic.ca:/pub/mlevy/.) The best tutorial for writing a WAM-based compiler or WAM emulator is Hassan Ait-Kaci’s book, “Warren’s Abstract Machine: A Tutorial Reconstruction” (see [1-3] above). A “quick-and-dirty” method is to implement the WAM functions as described in Ait-Kaci’s tutorial, to label each call with a C case label, and then throw a giant switch(P) statement around the entire sequence of calls, where P