Skip to content

Expression engine grammar

The exact definition of what you can write in an expression. It accepts two ways of writing the same thing: C# style and Python style. If you are looking for examples and not the definition, start with the quick guide or the manual.

Principles

Tokens

TokenFormExample
Numberdigits with optional . decimal (no thousands separator)123, 0.5, 1234.56
String"..." or '...'; escapes \\ \" \' \n \t"IVA", '21%'
Date#yyyy-MM-dd#, #yyyy-MM-dd HH:mm#, #... HH:mm:ss##2026-06-10#
Booleantrue, false
Nullnull or None (alias)
Field[Field Name] (allows spaces and accents)[Total Línea]
Identifierletter or _ + letters/digits/_PageNumber, tipoIva
AggregateAGG(identifier) — special form, reports compatibilityAGG(totalVentas)

Grammar (EBNF) — Level 1

expresion      := condicional
condicional    := coalesce ( '?' expresion ':' expresion
                           | 'if' coalesce 'else' condicional )?   // Python form
coalesce       := logicaOr ('??' logicaOr)*
logicaOr       := logicaAnd (('||' | 'or') logicaAnd)*
logicaAnd      := igualdad (('&&' | 'and') igualdad)*
igualdad       := relacional (('==' | '!=' | '<>') relacional)*
relacional     := aditiva (('<' | '<=' | '>' | '>=') aditiva)*
aditiva        := multiplicativa (('+' | '-') multiplicativa)*
multiplicativa := unaria (('*' | '/' | '%') unaria)*
unaria         := ('-' | '!' | 'not') unaria | postfija
postfija       := primaria ('.' identificador argumentos?)*      // allowed members only
primaria       := numero | cadena | fecha | 'true' | 'false' | 'null'
                | '[' nombreCampo ']'
                | 'AGG' '(' identificador ')'
                | identificador argumentos?                       // allowed symbol or function
                | '(' expresion ')'
argumentos     := '(' (expresion? (',' expresion?)*)? ')'   // a gap between commas is null

Types and conversions

Language types: Null, Boolean, Decimal, String, DateTime.

Null semantics (three-valued logic, compatible with MS SQL / PostgreSQL)

OperationResult
null + 5, null * x, -nullnull (all arithmetic propagates)
"a" + nullnull (like +/`\\ in SQL; Concat` ignores null)
a == b with a null at runtimenull (unknown)
x == null / x != null (literal)true/false — acts as IS [NOT] NULL
true or nulltrue
false or nullnull
true and nullnull
false and nullfalse
not nullnull
Condition of ?: (or if) = nullthe false branch is taken (as in SQL WHERE)
null ?? xx (equivalent to Coalesce(null, x))

Allowed functions

English names in SQL/C# style (the ones SQL users already know); case-insensitive.

Adding a function = an entry in the function registry (name, arity, types, purity). Level 1 functions are pure (no side effects); Now/Today are pure thanks to the fixed clock.

Errors

Four categories, all with position (index and excerpt) and a message in Spanish:

  1. Parse (ExpressionParseException): unexpected/expected token. Includes the = case → ‘use ==’.
  2. Binding (ExpressionBindException): unknown symbol or function; suggestion by edit distance (‘¿Quiso decir [TotalLinea]?’, ‘Did you mean [TotalLinea]?’).
  3. Permissions (ExpressionPermissionException): symbol from an area the user can’t access.
  4. Runtime (ExpressionRuntimeException): division by zero, failed conversion, incompatible type, step budget exhausted (scripts).

Level 2 — Script

It reuses the expression grammar in full. It only adds statements:

script      := sentencia+
sentencia   := declaracion | asignacion | si | mientras | porCada | devolver
             | bloque | expresion ';'
declaracion := 'var' identificador '=' expresion ';'
asignacion  := identificador '=' expresion ';'
si          := 'if' '(' expresion ')' sentencia ('else' sentencia)?
mientras    := 'while' '(' expresion ')' sentencia
porCada     := 'foreach' '(' 'var' identificador 'in' expresion ')' sentencia
devolver    := 'return' expresion? ';'
bloque      := '{' sentencia* '}'    // opens a child scope

Rules: