Prolog Interpreter in JavaScript!
To begin. First Click anywhere on the Black Screen to the right in order to start typing, and press enter to execute your code. Just like a terminal program!
The parser will correctly parse prolog programs. And has logic implemented for the following:
- Clauses
- Relations of the form atom(terms).
- Example: dad(steve,mary).
- Definitions
- Clauses with a head and a body.
- Example: dad(X,Y) :- male(X), son(Y,X).
- Variables
- Variables in prolog are any character / string that begins with an uppercase character
- Queries / Goals
- In order to query the clauses entered, start a goal with '?-'
- Example: ?-dad(steve,X). Will return X: mary
SHELL COMMANDS: Type these in order to perform commands that are built into the interpreter or prolog.
- clear: clears out all of the clauses so you can start over
- consult: opens a file select window allowing you to pick a file for parsing *NOT YET IMPLEMENTED
- There are some built in examples. For example "consult('montypython')" will load up the witch sketch from Monty Python and the Quest for The Holy Grail.
- write() and nl: useful for echoing to the screen. *NOT YET IMPLEMENTED*