Expression Pattern Language (eXPL)

eXPL Scopes

A scope is a query context in which execution is isolated from all other contexts. A scope can also have special text format attributes. A single query can transition between scopes to allow a dynamic response to context-sensitive data. Scope features are:

  • By default, a query is executed in the Global scope, but an optional query parameter allows a different scope to be specified.
  • Scope can be specified in an identifier name by using a two part name, with the scope name first - eg. "german.pallete" for an axiom source that provides German colors in a scope named "german".
  • A scope can also be assigned it's own default locale for international formatting of currency, numbers etc. The locale can be defined according to language, region, variant and script.
  • A special type of term list called a local which is backed by an axiom specific to current scope - useful for word translation (see details opposite).

Format

A scope declaration has format:

scope name [ ( properties ) ]
{
  eXPL-statements
}

A scope has a name and encloses statements in braces {}. Optional properties are specified as a comma-delimited list of key=value pairs. Keys are reserved for specifying the scope locale: "language", "region" and "variant" eg. (language="de", region="DE") specifies the Germany locale.

Scope Term List

All properties assigned to a scope are available in a term list named "scope". From the previous example, scope[language] returns "de". A property value can be text, a number, a boolean ("true"/"false") or reserved word "unknown".

Formatted Numbers

Numbers can be presented in a format suited to the locale of the current scope when enclosed in braces. For example a German formatted number for 1,234,567.89 would be {1.234.567,89}. Note that in an English language locale, {1,234,567} can be used to represent 1234567, which helps with readability.

Local Term Lists

An local term list declaration has format:

local name(axiom-name).

When a local list is declared, then the Global scope must also declare an axiom named axiom-name and every scope which references the local list must declare an axiom with same name and term names, but items to suit the local context.

The Global scope axiom is allowed to be empty if it does not reference the local list. In this case, it is just declaring term names.

The local term list has the same options on how to reference a list item as a Term list. As an example we have a German scope named "german" and a French scope named "french" and we want to translate the word "tax", which is "impôts" in French and "Steuer" in German. The axiom declarations are:

 axiom foreign(tax);
 axiom french.foreign(tax){"impôts"};
 axiom german.foreign(tax){"Steuer"};

The Local list, named "translate" is declared as follows:

local translate(foreign);

This list can now be used is any scope to translate "tax" as follows:

translate[tax]

More terms can be added to the local axioms as required. For example, to add a greeting:

 axiom foreign(tax, greeting);
 axiom french.foreign(tax, greeting){"impôts", "Bienvenue"};
 axiom german.foreign(tax, greeting){"Steuer", "hallo"};

Both the French and German scopes would translate "greeting" as follows:

translate[greeting]