Skip to content

mayanksingh2298/prolog-interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prolog Interpreter

This is a basic implementation of a Prolog interpreter in OCaml with REPL support. The interpreter follows standard Prolog IO syntax where clauses, facts, rules and terms have their usual definition.

Implementation

The implementation consists of a lexer lexer.mll, a parser parser.mly, an REP loop toyprolog.ml and the core unification and substitution engine a6.ml.

How To

  • The project contains a makefile that generates an executable toyprolog.
  • The executable can be run as ./toyprolog inputfile where inputfile should contain all facts and rules to be loaded before execution.
  • The project also contains a sample prolog script based on the Harry Potter universe family trees. Its called hogwarts.pl and contains lots of interesting facts and rules.

An Example

make
./toyprolog sample-prolog-codes/hogwarts.pl
?-brother(X,ginnyWeasley).
X = ronWeasley;
X = georgeWeasley;
X = fredWeasley;
X = percyWeasley;
X = charlieWeasley;
X = billWeasley;
false.

?-ancestor(X,harryPotter).
X = doreaBlack;
X = charlusPotter;
X = violettaBulstrode;
X = cygnusBlack;
X = ursulaFlint;
X = phineasNigellusBlack;
X = lillyPotter;
X = jamesPotter;
false.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published