Skip to content

6. Values

Contents of ATD 0.1

6.1 The value rule

Every value position follows one rule (FR-006):

Written Is
a bare word (center, remove-when-empty), a number (24, -8, 1.5), a length (12px, 50%) or a string ("Mind map") a literal
( <CEL> ) a CEL expression
@path the value of an attribute of the current element; two-way where the position is editable, as DISL's {attribute}
$name a theme token (DISL §6.2)
#name a parameter of the enclosing shape, marker or template
{ key: value … } a settings map (section 6.4)
[ value, … ] a list

The marks @, $ and # are unused by CEL, and parentheses are CEL's own grouping, so no CEL text is ambiguous with them.

6.2 Positions that take only an expression

A position that only ever takes an expression takes CEL without parentheses: a constraint's when and rule, an operation's enabled, a hook's when, a variant's when, a binding rule's when, a script's conditions and right-hand sides, and the arguments of actions. Such an expression ends where the next construct starts; it is never directly followed by { that is not its own, which is why CEL's message construction is not part of ATD (section 6.3).

6.3 CEL in ATD

Expressions are CEL (FR-007), and the grammar contains CEL's expression syntax (grammar/cel.lark), so that an expression is parsed, coloured and type-checked as part of the description:

  • the conditional ?:, ||, &&, the relations < <= >= > == != in, + -, * / %, ! and unary -, member selection, indexing, calls, lists and maps, with CEL's precedence;
  • every literal: int, uint, double, string and bytes in all their forms, true, false, null;
  • CEL's optional syntax: a.?b, a[?i], [?x] and {?k: v};
  • the macros (has, all, exists, exists_one, map, filter, cel.bind) as calls.

CEL's message construction (Name{field: value}) is not part of ATD: no ADP CEL environment declares a message type (DISL §12.2, DESL §9.2), and leaving it out lets a bare expression be followed by a block (if cond { … }). The abstract tree holds an expression with CEL's abstract syntax ($defs/CelNode): an operator as a call of its CEL function name (_+_, _&&_, !_, -_, _?_:_, _[_], @in), a macro as a call marked macro.

6.4 Settings

The open vocabulary of DISL, DESL and FBL (strokes, fonts, layout options, persistence details, extension x- keys and the many properties ATD gives no keyword of its own) is written as settings: key: value pairs, among a construct's members or in a settings map { … }, whose values follow the value rule, so that they nest (FR-011).

stroke: { color: $color.border, width: 1.5 }
padding: [6, 10]
size: { width: (math.round(textWidth(self.text, 14.0) + 20.0)), resizable: false }
  • A key is a KEY token (section 3.4), or, in a settings map, a string followed by : for a key that is not a name.
  • A comma between two settings is optional.
  • The grammar knows only the form. Which keys a construct admits, and what their values may be, is checked against the JSON Schema of the construct (section 14.6), so that a stroke has one schema, DISL's, whether it is written in JSON or in ATD.
  • An x- key is admitted everywhere and not checked.

6.5 DISL's four embeddings

DISL embeds CEL four ways (DISL §2.5); in ATD each is the value rule:

DISL ATD
(a) Expression: a string that is CEL, or {"cel": …} in a position of section 6.2, bare CEL; in a setting, ( CEL )
(b) Bindable: a literal, {"cel"}, {"attribute"}, {"token"} or {"param"} a literal, ( CEL ), @path, $name or #name
(c) GeomExpr: a number, a percentage string or a string of CEL a number, a length (50%), or ( CEL )
(d) the action expression, in which a literal string is written "'Untitled'" statements (section 12), whose arguments are CEL: "Untitled"

None of the four survives as a form of its own.

6.6 The JSON value of a value

A value has a JSON value, which is what its setting is checked against and what the runtime hands DISL's, DESL's and FBL's engines (section 14.6):

  • a bare word is a JSON string, except true, false and null, which are JSON's literals; a number is a JSON number; a length and a string are JSON strings;
  • ( e ) is, in a property the schema types as an Expression, the string e; in any other property, {"cel": "e"};
  • @p, $n and #n are {"attribute": "p"}, {"token": "n"} and {"param": "n"};
  • a settings map is a JSON object with its keys in written order, and a list a JSON array.

A literal in a property the schema types as an Expression is refused (ATD5003): an expression is written as one.

Referenced from