NanoProlog-0.2.1: Very small interpreter for a Prolog-like language




Running the Interpreter

The main interpreter

run :: IO ()Source

The main program prompt for a file with Prolog rules and call the main interpreter loop

loop :: [Rule] -> IO ()Source

loop ask for a goal, and enuartes all solutions found, each preceded by a trace conatining the rules applied in a tree-like fashion

printSolutions :: Result -> IO ()Source

printSolutions takes the result of a treewalk, which constructs all the proofs, and pairs them with their final substitutions. Alternative approaches in printing are to print the raw proofs, i.e. without applying the final substitution (remove the subst env ). This nicely shows how the intermediate variables come into life. By including the test on the length the facts directly stemming from the data base are not printed. This makes the proofs much shorter, but a bit less complete.