Expression Pattern Language (eXPL)

eXPL Resources

There are two types of resources in eXPL -

  • Script resource, provides external eXPL script to be compiled and referenced by an "include resource" statement,
  • Axiom resource, binds an axiom declaration to a provider for the senquential input and/or output of axioms

Script Resource

The script resource format is:

include "file-name";

The import location defaults to the current working directory, but can be programmed to a different location.

Axiom Resource

The provider of an axiom resource can be input-only, output-only or bi-directional. The resource name may be same as the axiom declaration to which it is bound (implicit) or independent and therefore named explicitly. In the following formats, the resource term is either reserved word resource - implying same name as axiom name, or in the case of an independent name, it is a string in quotes eg. "cities" for a "City" database table.

Axiom Resource Input

The declaration for an axiom source bound to a resource has format:

axiom axiom-name ( term-names ) : resource;
  • The term names are mapped by the resource implementation to field names of objects retrieved from the persistence system.
  • In simple cases, the term names may be omitted and field names are used instead. Only fields of type known to eXPL are included.

Here is an example of declaring an axiom name "city", term names of "name" and "altitude", resource name "cities":

axiom city(name, altititude) : "cities";

Axiom Resource Output

The source of axioms to send to a resource are the query solutions generated while a query is in progress. A statement to dispatch axioms consists of a term list declaration to which a resource term is appended:

list<term> list-name ( template-name : resource );

Note a template name is used where previously an axiom name has been specified for a term list declaration. This is because the template is the axiom source, with a solution generated at the end of each successful unify/evaluate step.

Resource Programming

The eXPL runtime requires no additional coding to implement the file include statement. Example code can be found in tutorial5 MegaCities.

Data connections require additional coding to adapt the eXPL runtime to the persistence system being used. The tutorial4 Expressions code example, contains an adapter to provide dictionary entries as axioms.

When robust and scalable persistence is required, a relational database is recommended. An extension library is available here for a Java Persistence API (JPA) standards approach to Object Relational Mapping (ORM).