Lexical structure

Before EFX text is read, it is divided into its smallest parts, called tokens: keywords, identifiers, literals, operators and punctuation. This page gives the rules for writing them: which characters you can use, where spaces and line breaks matter, how you write comments, how upper and lower case are used, and what identifiers look like. The same rules apply to single expressions, template files and rules files. Where template files follow other rules, the entries say so.

Characters and encoding

EFX is written with ASCII characters: all its keywords, identifiers, operators and punctuation use them. You can use other characters, such as accented or Greek letters, in three places only: inside a text literal, in the text that a template displays, and in comments. Template files and rules files are read as UTF-8.

So 'Πρόσκληση' is a valid text literal, but $café is not a valid variable name.

Examples

WITH ND-Root COMPUTE BT-00-Text == 'Πρόσκληση για υποβολή προσφορών'

A text literal with Greek characters.

WITH BT-00-Text DISPLAY Título: ${BT-00-Text};

A template line whose text contains an accented letter.

White space and line ends

Spaces, tabs and line breaks separate tokens. In an expression and in a rules file, they have no other meaning: you can write an expression or a rule on one line or over several lines, and indent it as you like.

You need white space only where two tokens would otherwise be read as one. This matters most for the minus sign, because identifiers can contain hyphens: BT-00-Number - 1 subtracts 1 from a field, but BT-00-Number-1 is one identifier. For the same reason, you cannot put a space between a prefix, such as $ or ?, and the name after it: $total is a variable, but $ total is an error.

Template files are different, because there the layout of the text has a meaning. The indentation at the start of a template line gives the line its place in the hierarchy (see Indentation), and the spaces inside the text are displayed (see Text).

Examples

WITH ND-Root
  COMPUTE BT-00-Number
    + BT-11-Number

A single expression over three lines.

--- STAGE 1a ---
WITH ND-Root ASSERT BT-00-Number > 0 AS ERROR R-AB1-C2D FOR BT-00-Number IN *;

A rule on one line. Written over several lines, it means the same.

Comments

A comment is a note for human readers. It starts with two slashes, //, runs to the end of the line, and does not change the meaning of the EFX text.

A comment can stand on a line of its own or follow EFX text on the same line, in single expressions, template files and rules files alike. EFX has no comments over several lines, such as /* … */.

Two slashes inside a text literal are part of the text: 'a // b' contains no comment. In the text of a template, two slashes start a comment only after a space or a tab, so you can display web addresses such as https\://example.com. The colon of a web address is written \: (see Caption). Because a comment runs to the end of the line, write the semicolon that ends a template line before the comment, not after it.

Examples

WITH ND-Root COMPUTE BT-00-Number // the base amount
  + BT-11-Number                  // plus the additional amount

Comments inside a single expression.

// Greeting shown at the top of the notice
WITH ND-Root DISPLAY Hello; // a comment after the line

A comment line, and a comment at the end of a template line.

// Rules of stage 1a
--- STAGE 1a ---
WITH ND-Root // every notice
  ASSERT BT-00-Number > 0 // must be positive
    AS ERROR R-AB1-C2D
    FOR BT-00-Number
    IN *;

Comments in a rules file.

EFX-1 allowed comments in template files only. EFX-2 allows them everywhere, also inside an expression.

Case sensitivity

EFX distinguishes upper-case and lower-case letters. You must write identifiers and keywords exactly as they are defined.

For identifiers, this means that $total and $Total are two different variables, and that bt-00-text does not refer to the field BT-00-Text.

For keywords, the case shows what kind of word you are reading. The keywords that form a statement, such as a single expression, a declaration, a template line or a rule, are in upper case: WITH, COMPUTE, LET, DISPLAY, ASSERT and so on. They stand out from the expression inside the statement, whose keywords are in lower case: and, in, if, every and so on. The indicator literals TRUE, FALSE, ALWAYS and NEVER are in upper case. You write the field properties as one word, with an upper-case letter at the start of each part after the first, such as rawValue. The appendix Keywords gives the case of each keyword.

A word in another case is not a keyword: with ND-Root compute 1 is not a single expression, and true is not an indicator. So a statement keyword in lower case is an ordinary word, and you can use it as a name, for example for a callable template: --- TEMPLATE display ---.

Four words exist in both cases, with different meanings: IN and in, FOR and for, EVERY and every, AT and at. In upper case, they belong to a statement: in a rule, IN introduces the notice subtypes and FOR the target of the rule; after WITH in a rule-set, EVERY applies the rules to every occurrence of a field or node; and in an API endpoint declaration, AT introduces the address of the service. In lower case, they belong to an expression: in tests membership, for starts an iteration, every starts a quantified expression, and at introduces an index.

Examples

WITH ND-Root COMPUTE every number:$n in BT-13-Number satisfies $n > 0

The statement keywords WITH and COMPUTE in upper case, and the keywords of the expression in lower case.

--- STAGE 1a ---
WITH ND-Root
  ASSERT BT-00-Code in ['a', 'b'] AS ERROR R-AB1-C2D FOR BT-00-Code IN 1-5;

In a rule, in tests membership inside the expression, and IN introduces the notice subtypes.

EFX-1 had no statement keywords. Its other keywords are written as in EFX-2.

Keywords

A keyword is a word with a fixed meaning in the language, such as WITH, and or count. The names of the built-in functions are keywords too. Because their meaning is fixed, you cannot use keywords as names.

There are two exceptions. First, a name after a prefix is always read as a name, even when it is spelled like a keyword: so $date, ?count and [...indicator] are valid. The prefixes are $ for variables, parameters and dictionaries, ? for functions, @ for attributes, # for flags, and ... for codelists. Second, a statement keyword in lower case is not a keyword (see Case sensitivity).

The words of label blocks in templates, such as field, code and name, are keywords only inside a label block (see Label block).

string is another name for the conversion function text. It is kept from EFX-1, where it was the name of that function.

Examples

WITH ND-Root COMPUTE every date:$date in BT-13-Date satisfies $date > 2020-01-01Z

The iterator variable is called $date, although date is a keyword.

WITH ND-Root COMPUTE BT-00-Code in [...indicator]

A reference to the codelist called indicator.

EFX-2 adds many keywords, for example WITH, COMPUTE, LET, DISPLAY, ASSERT, has, duplicates, distinct, at and the names of the new built-in functions. It removes notice and the XPath axes, such as preceding and ancestor. The type measure is now called duration.

Identifiers

An identifier is the name of something in the language: a field, a node, a variable, a function, a codelist, a template, a rule, a validation stage or a flag.

Most identifiers are made of a name: a word that starts with a letter or an underscore and continues with letters, digits and underscores. You can divide a name into parts with single hyphens, as in text-values, but a name cannot start or end with a hyphen. A prefix shows what the name stands for: $total is a variable, ?has-values a function. Names that start with two underscores, such as $__index, are reserved for the translator, which uses them for the variables that it creates itself. You cannot declare them in EFX.

The identifiers of the SDK have fixed forms:

Identifier Form Examples

Field

a business term identifier, optionally a qualifier in parentheses, and one or more parts, each after a hyphen and starting with a letter or an underscore

BT-00-Text, BT-00(a)-Text, BT-195(BT-00)-Text-In-Repeatable-Node

Node

ND- followed by letters and digits

ND-Root, ND-RepeatableNode

Business term

BT-, OPP-, OPT- or OPA- followed by digits

BT-00, OPT-301

Rule

R-, three letters or digits, a hyphen, three letters or digits

R-AB1-C2D

Validation stage

letters, digits, underscores and hyphens, starting with a letter or a digit

1a, 4m

The parts of a field identifier start with a letter. This is why BT-00-Number-1 is one name, and not BT-00-Number minus 1. You use business term identifiers on their own in the label blocks of templates (see Label block).

Examples

WITH ND-RepeatableNode COMPUTE BT-195(BT-00)-Text-In-Repeatable-Node is present

A field identifier with a qualifier.

LET text*:$text-values = BT-13-Text;
LET indicator:?has_values(text*:$values) = count($values) > 0;
DISPLAY ${?has_values($text-values)};

A template file with a variable, a function and a parameter whose names contain a hyphen or an underscore.

--- STAGE 4m ---
WITH ND-Root
  ASSERT BT-00-Number > 0
    AS WARNING R-2A1-9ZZ
    FOR BT-00-Number
    IN 1-3, E1
    SCOPE @PRE #lawfulness;

A stage identifier, a rule identifier and a flag.

In EFX-1, a variable name could not contain hyphens, and the parts of a codelist name had to start with a letter. Function, template, rule, stage and flag identifiers, and the reserved names, are new in EFX-2.

Punctuation and operators (overview)

Several symbols of EFX have more than one use. This table lists each symbol with its uses, and the entries that describe them.

Symbol Uses

( )

grouping (Parentheses and precedence); the arguments of a function call; parameter lists

[ ]

predicates (Predicate); indexes, [at n] (Index); sequences (Sequence construction); codelist references [...name]; dictionary lookups

{ }

after $, # or @ in templates: an expression block ${…}, a label block #{…} or a hyperlink @{…}

,

separates the items of a list: arguments, parameters, sequence items, variables, notice subtypes

:

separates a type from a name (text:$total); introduces a field property (BT-00-Text:rawValue); in a template, separates the caption from the content (Caption)

::

context override (Context override)

;

ends a template line, a declaration and a rule; introduces the pluraliser in a label block

=

gives a value in a declaration (LET number:$total = 0;); it is not a comparison, which is written ==

== != < <= > >=

comparison (Comparison operators)

+ - * / %

arithmetic (Arithmetic operators); - also starts a negative number or duration and forms ranges of notice subtypes; * also marks a sequence type (text*), stands for all notice subtypes (IN *) and starts a bulleted line; / also starts an absolute reference and comes before an attribute name (/@)

.

decimal separator in numbers

...

codelist reference [...name]

$

prefix of variables, parameters and dictionaries; $value and ${ in templates

?

prefix of user-defined and dynamic functions; in templates, an outline marker

#

prefix of flags; #include; in templates, #{, #value and the outline markers # and #tag

@

comes before an attribute name (/@name); @PRE and @POST; @{ in templates

&

character references in templates

|

separator inside label blocks; introduces the format options of an expression block in templates, as in ${BT-00-Number|2}

\

escape character in text literals and in templates; line joining in templates

' "

delimiters of text literals

//

comment (Comments)

---

section headers in template files and stage headers in rules files