O'Reilly logo

Building Parsers with Java™ by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

12.6. Programs and Queries

A program is a collection of axioms, which are facts or rules (which you have yet to meet). A query is a structure that can prove itself against a program. Figure 12.3 shows the Program and Query classes.

Figure 12.3. The Program and Query classes. A program is a collection of axioms and an implementation of the AxiomSource interface. The Query class has a constructor that accepts a source of axioms and a structure to unify with the axioms.

The following Java program creates a logic program, loads it with facts, and uses a query to extract all its results:

 package sjm.examples.engine; import sjm.engine.*; /** * Show ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required