prolog library

Prolog grammar, AST definitions, and unification-based query evaluator.

Based on curiosity-driven.org/prolog-interpreter.

For example:

final db = Database.parse('p(X) :- q(X). q(a).');
final goal = Term.parse('p(a)');
for (final result in db.query(goal)) {
  print(result);
}

Classes

Conjunction
A conjunction of goals (the , operator in Prolog) evaluated sequentially.
Database
An indexed collection of Prolog Rule definitions that can be queried.
Node
Base class for all Prolog AST terms and variables.
PrologParserDefinition
Grammar definition that produces typed Prolog AST structures.
Rule
A Prolog Horn clause consisting of a head term and a body goal.
Term
A compound Prolog term consisting of a functor name and argument arguments.
True
The Prolog true goal, which succeeds unconditionally with no substitutions.
Value
A Prolog atomic constant (atom) with no arguments.
Variable
A named Prolog variable capable of binding during unification.

Properties

rulesParser → Parser<List<Rule>>
A parser that reads Prolog rules into a list of Rule clauses.
final
termParser → Parser<Term>
A parser that reads a Prolog query into a Term.
final