Giter Site home page Giter Site logo

acharal / wam Goto Github PK

View Code? Open in Web Editor NEW
18.0 3.0 1.0 62 KB

A simple compiler from Prolog to WAM (Warren Abstract Machine) and a runtime for WAM.

License: GNU General Public License v2.0

Haskell 96.99% Prolog 2.44% Makefile 0.48% Raku 0.09%
wam logic-programming warren machine prolog-compiler prolog

wam's Introduction

A Simple PROLOG Compiler to WAM

GitHub license Build Status

WAM (Warren Abstract Machine) is an efficient popular abstract machine to compile Prolog logic programs and is implemented in almost all industrial-strength PROLOG compilers such as SWI-Prolog and YAP.

This interpreter contains the compilation and runtime of WAM instructions based on the definition in Russinoff 1992. The interpreter is developed in Haskell and the purpose of the project is to be used as testbed for various extensions in WAM.

Getting Started

Building

To build the WAM compiler you should have a system with GHC and cabal. The following sequence of commands will build the compiler after installing any dependencies needed.

$ cabal update
$ cabal install --only-dependencies
$ cabal configure && cabal build

Compile an example to WAM

After a successfull build the compiler will reside by default in ./dist/build/wam/wam. You can add the directory to your current path, i.e.

$ export PATH=`pwd`/dist/build/wam:$PATH

To compile a PROLOG program to WAM you should issue:

$ wam -c -i prog.pl -o output.wam

where prog.pl is your initial PROLOG source file, output.wam is the name of the output file that will contain WAM bytecode. The switch -c will only compile the program but not run. On the other hand if you omit -c, namely

$ wam -i prog.pl -o output.wam

the program will also be executed after the compilation.

Features and Limitations

Compilations supports some basic optimizations such as

  • tail execution optimization
  • unsafe variables

Limitations

There are also some features of WAM that are not yet supported such as:

  • There are no special instructions for lists (get_list, put_list).
  • No environment trimming.
  • No indexing at the switch-operators
  • No cut functionality
  • No garbage collection has been implemented.
  • A subset of the ISO-Prolog is supported and compiled. No build-in predicates are supported, neither user-defined operators.

wam's People

Contributors

acharal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

octurion

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.