Expressions are the means for specifying relationships and transforming data.
Operators
All the Java operators are supported except for shift operators and the ternary operator. Java precedence also applies along with the use of parentheses to override precedence. A new type of operation called "short circuiting" is also introduced which forces an exit from unification based on evaluation of a binary expression. The Java ternary symbols "?" and ":" are reassigned for short circuiting with operator ? used for "short circuit on false" and operator : (colon) "short circuit on true".
Types
| eXPL Type | Example |
|---|---|
| string | "Australia" |
| integer | 16498 |
| double | 11230.9845 |
| boolean | true |
| decimal | 2.00 |
| currency | $1234.56 |
Text literals are represented by type string and used to match axiom strings to tempate strings.1
integer, double and boolean are the same as Java primitive types long, double and boolean respectively, and are implementented as Java Object-wrappers.
decimal and currency are an arbitrary-precision signed decimal numbers (implemented as Java class java.math.BigDecimal). The currency type is suited for financial transactions. For more details, go to Currency.
Following unification, a template term may contain an object of unknown type. Such a term cannot be used in expressions, except for assignment.
Literals
Literal terms are constants. Java literals are used for strings and numbers, but character literals are not supported.
Single quotes are used to delimit formated numbers eg '1,234,567' for 1234567.
Sets of literals can be placed in {} braces next to a template variable to indicate "match any any literal in the set".
Also used in eXPL are "true", "false", "unkown" and "NaN" (not a number).2
Identifers
Most of the language components, including axioms, templates and variables need an identity for which the Java naming convention is applied: identifiers begin with an alpha character which is followed by any number of alpha or numeric characters or underscore. The convention used in the reference is to use all lower-case names, with words separated by underscores. This gives the eXPL scripts a look which is distinctively and deliberately different from Java.
- Strings - Backslash '\' is used as an escape character the same as in Java.
- Literals - "NaN" in any numeric calculation results in NaN.
