A browser based PROLOG interpreter. Try the Live version
Table of Contents
This tool is a self-contained interpreter for the Prolog programming language. It allows users to write and query Prolog programs, tabulate the results, and trace the steps taken to reach a solution, all from within a browser. Unlike other existing online interpreters, this tool is entirely client-based, which means that all queries are executed on the user's machine. This tool is built on top of a WebAssembly (WASM) port of SWI-Prolog, and is designed to provide a Graphical User Interface (GUI) for the language.
- SWI-Prolog: A widely-used Prolog implementation.
- WebAssembly: A binary instruction format for a stack-based virtual machine.
- SWI-Prolog for the browser: A WASM port of SWI-Prolog.
- Treant-js A graph drawing library.
- panzoom library For navigating the tree chart.
- html-to-image To download the tree as a picture or SVG.
- Real-time editing and querying of Prolog programs.
- The code editors have all standard shortcuts,
ctrl-z
/y
,ctrl-c
/x
/v
...Enter
on queries executes them. - Code and queries are persistent across page reloads. A set of examples are available as well.
- Automatic tabulation of results, with indication of whether more results are available.
- Automatic tracing of the steps taken to reach each solution.
- Display the steps taken in a graphical tree form.
- Ability to zoom in and out of the tree.
- Filter tree nodes based on the scope value.
- Download trees as PNG or SVG.
- Implement multi-threaded Prolog queries.
Simply open the editor in your browser, write your Prolog program, write your query, and press Enter
.
A set of examples is provided for testing both the functionality and limits of the tool.
Users can select the number of solutions to compute, and abort the process if necessary.
For greater readability and more concise reading of the tree, users can select a reference scope to ignore nodes above a certain threshold.
It is even possible to download the graphic representation of the displayed tree in svg or png format.
Only the www/ folder is required for the editor to work. A simple File Server in Java is included, but not required. Any other server may be used; The live version for example uses Github Pages with no additional configuration.
If you wish to recompile SWI-Prolog for the browser, please read the Wiki.
While the graphical interface of the tool is functional, its development has been largely independent of typical Prolog workflows. Feedback from experienced Prolog users would be appreciated to improve the tool's functionality and usability, especially in regards to conventional Prolog usages. This editor is not intended to compete with SWISH, nor does it offer a fraction of it's functions. However, the tool's ease of use and real-time local execution of queries might provide a convenient alternative for users who find SWISH cumbersome.
Give credit where due.
- Many tanks to the individuals responsible for getting Prolog running in the browser, and for troubleshooting the many issues that came with it.
Project is: in progress.