Skip to content

14. Static semantics

Contents of ATD 0.1

What the grammar cannot state and a checker MUST check (FR-010).

14.1 A description

A description is its root and the parts its imports reach (section 5). Every file is parsed; a file that does not parse is reported (ATD1001). A description whose files do not all parse is checked no further than its syntax: what the parser skipped would otherwise be reported again as names that resolve to nothing. Its names are still collected, so that a language server's hover, definition and completion answer in the parts that parse (FR-053).

14.2 Namespaces and names

Each of the following is a namespace, as in DISL §2.2: types (element and relation types share one), enums and data types (sharing one with types), coordinate systems, axes, snapping profiles, styles, shapes, markers, icons, forms, tools, templates, constraints, operations, hooks, reasons, functions, layouts and their algorithms, viewpoints, bindings, and each binding's rules. Two declarations of one name in a namespace are a finding (ATD2006); names differing only in case are one name. A reference resolves in its namespace across every file of the description; a name a library import brings is prefixed with its alias. A reference that resolves to nothing is a finding at the reference (ATD2001 an attribute, ATD2002 a type, ATD2004 a binding rule, ATD2005 a function, ATD2010 a capability, ATD2011 any other name), with the closest names (section 15.5). An element type, attribute, parameter, function or local whose name is a CEL reserved word cannot be used in CEL and is a finding at its declaration (ATD4003).

14.3 Imports and parts

Section 5.2 and 5.3: a part names its root's origin (ATD2007), is imported by one root (ATD2008), and its file exists in the description's folder (ATD2009); a cycle is reported once (ATD2003).

14.4 Kinds

A description admits only the constructs its kind allows (FR-005). This table is normative, and a checker reads it from one place:

Construct family Diagram Designer Editor
Element types, attributes, enums, data types, ids, containment yes yes yes
Relation types, ports, derived relations yes no (ATD3001 at the construct) no (ATD3001)
coordinates, notation, toolbox, layout, viewpoint, and a move's to <x>, <y> yes no (ATD3002) no (ATD3002)
form yes yes no (ATD3002)
surface table, surface hierarchy no (ATD3002) yes no (ATD3002)
surface text no (ATD3002) no (ATD3002) yes
Constraints, operations, actions, reasons, messages, labels, documentation, origin, settings yes yes yes
Hooks yes no (ATD3001) yes
Bindings of every family, registration yes yes yes
Functions, capabilities yes yes yes

A designer MUST have one form surface and an editor one text surface (ATD3003).

14.5 Expressions

Every expression is type-checked in the CEL environment of its position (DISL §2.5, §12.3; DESL §9.3; FBL §2.4): the variables in scope, the functions of DISL's library and the description's own, and the result type the position expects. The environments:

Position Variables Result
a constraint's when and rule, of for <Types> self, diagram or document, and DISL §12.3's constraint context bool
an operation's enabled, a context tool's visible and enabled self, diagram or document, selection bool
an operation's or hook's statements self, diagram or document, selection, p (the parameters), event and old in a hook, the locals (statements)
a variant's when, a notation's ( CEL ) self, diagram, view bool, or the property's type
a binding rule's when, a slot's value (…) entry, text, style, file (FBL §2.4) bool, the attribute's type
a function's statements its parameters and locals its result type
a setting's ( CEL ) the context of the property, as DISL, DESL or FBL names it the property's type

An expression whose type does not fit the position is a finding (ATD4001); an unknown variable (ATD4004) and a CEL reserved word used as an identifier (ATD4003) are findings too.

A variable that holds an element is read as the type a test <variable>.isA('<Type>') names where that test holds: on the right of && when the test is one of its left operand's && conjuncts, and in the first branch of ?: when it is one of the condition's. An attribute of that type is then no ATD2001 (timeline.atd's self.isA('Period') && readableTime(self.end)).

14.6 Settings

Each construct's settings are checked against the $defs entry of DISL, DESL or FBL that Appendix C names for the construct (FR-011): the setting's JSON value (section 6.6) is put where the construct's JSON form would have it, and validated. A key the schema does not admit (ATD5001), a value it does not admit (ATD5002), and a literal where the schema wants an expression (ATD5003) are findings at the setting. An x- key is admitted and not checked.

14.7 Model, surface and binding as one unit

The model, the surface and the bindings are checked together, so that one cause gives one finding, where it is:

  • a binding rule's type MUST be a type of the model or a key of persistence's typeMap (DISL §11.2, DESL §5.2), as DESL §10.1 says (ATD2002 otherwise). A key mapped as: document reads and writes the attributes of document { … }; one mapped to a type, that type's; each through the entry's attributes, which rename the binding's attributes to the model's. A key mapped as: header or as: unreadable keeps its entries out of the model, and its rules bind no attribute; an unreadable entry is reported by std.unreadableEntry;
  • every attribute a binding rule reads or writes MUST be one of those its type gives it (ATD6001 at the binding, once, not again where the attribute is used);
  • a notation, form, surface or outline names the model's types and attributes (ATD2002, ATD2001);
  • a rule a binding names (parent, within, cascade, references) is one of its rules (ATD2004), as FBL §14.1 requires.
  • a hierarchy surface fits its types, as DESL §10.1 requires of one (ATD6002, at the member of surface hierarchy that does not fit): the levels' type contains itself and the entries' type; each labels attribute is an attribute of every type of its on; the collapsed attribute is one of the levels' type and of the entries' type; the widths type's level is a string attribute and its width an int attribute. A type or an attribute a member names that does not exist is ATD2002 or ATD2001, not ATD6002;
  • a counter id rule's mark (DESL §5.3.5) is a string attribute of document { … } (ATD6003, at the setting mark);
  • each key of persistence's settings (DESL §5.5) is a block that every binding of the description declares in its registration's blocks (ATD6004, at the key); the types and attributes a setting names are the model's (ATD2002, ATD2001).

14.8 The script

Section 12's rules: a function call resolves (ATD2005) and is in the library or the description (ATD7001); purity through the call graph (ATD7002); every path returns or fails (ATD7003); recursion at most 64 (ATD7004); a loop's limit a non-negative integer; an action only where a model may change.

Referenced from