11. Bindings
Contents of ATD 0.1
A binding (grammar/binding.lark) is an FBL 0.16 binding written as text (FBL §3 to §13): every property of FBL's Binding has its ATD form in Appendix C. Its meaning, reading and writing are FBL's, unchanged.
binding <name> [family <family> | family capability <name>] { … }:
family <family>is the family of a declared file body (FBL §4):yaml,json,xml,lines,blocks,bulletsorgrammar(section 11.9);family capability <name>reads and writes the body through a capability of thereaderextension point, under FBL §11's persistence plugin contract (FBL'sreaderas aPluginReader); its arguments are the binding's settingargs;- a binding without
familyhas a folder body (FBL §10), described bybody { kind: folder … }; labelis FBL'stitle.
A description MAY have several bindings, one per format family, as DESL's persistence.bindings lists them.
claims { … } (FBL's Claims), or claims files "<glob>", … for its names; body { … } (FBL's Body), text { … } (FBL's TextDefaults), header { … } (FBL's Header), and settings of FBL's Binding (comment, unmatched, readOnly).
element <Type> [as <name>] [at "<selector>" | line "<regex>"] { … } is an element rule (FBL §5.1), relation <Type> [as <name>] […] { … } a relation rule (FBL §5.4). The name after as is FBL's rule name, written as FBL writes it, hyphens and dots included (as unreadable-requirement, section 3.6); without it the rule's name is its type's. The same holds for every name a binding declares or names: the binding's own, a block's, a section's, and those parent, within, files and references name. Members:
id from <slot> [{ … }]orid { … }(FBL §5.3);attribute <name> [from <slot>] [{ … }]: an attribute binding (FBL §5.2), its options as settings (empty,absent,default,number,time,style,map,override,content,create,readOnly,read,quoted,fallback, (FBL 0.10)secondaryandrefusals, (FBL 0.11)escapeandgather, (FBL 0.12)itemsandseparator, (FBL 0.13)split, (FBL 0.15)or,expand,ordinalandname), andreferences <rules> by <name>for FBL'sreference(by idfor a reference by stored id, FBL §5.7);parent <rules> [slot <name>](FBL §5.5),within <names>,when <CEL>,files <names>;insert { … }andremove { … }(section 11.5);- in a relation rule,
source from <slot>andtarget from <slot>; - settings of FBL's
ElementRule(caseInsensitive,opens,undo,readOnly, (FBL 0.10)origins, a list of the origins the rule is read for, FBL §5.1, (FBL 0.11)selectedView, §11.9), which a relation rule takes as well.
A slot is <kind> [<argument>]: key "<key>", attribute "<name>", text, group "<name>", continuation, parent "<attribute>", capture "<name>" or value (<CEL>), with the slot's other properties (child, word, flag) in the block that follows it.
block <name> [line "<regex>"] { … } is a block rule of the blocks family (FBL §4.7), (FBL 0.11) and block <name> { … } with at one of the grammar family (section 11.9), section <name> "<heading>" { … } a section of the bullets family (FBL §4.8).
insert { … } and remove { … } are FBL's Insert and Remove (FBL §6.2), as settings: place, container, emit, keys, create, skeleton, constant, (FBL 0.10) refusals (when, container, (FBL 0.14) key, duplicate), cascade. (FBL 0.14) In the yaml and json families, the insert of a rule whose at ends in a capture adds a member to a mapping under the key the add gives the attribute bound to that capture (FBL §6.2); ATD writes it with no setting of its own. (FBL 0.16) In the grammar family, insert takes continues: { at: "<selector>", same: { <attribute>: <slot> }, separator: "<text>", emit: "<text>" } and remove takes parts: [{ item: "<selector>", separator: "<text>" }, …] and whole: "<selector>" (FBL §6.2, §6.3).
registration { … } is FBL's RegistrationSettings (FBL §8: blocks, createOnFirstPlacement, headers, resource, its settings map holding capture or (FBL 0.10) byOrigin, a capture per reading's origin, legacyLayout, legacyIdentities, (FBL 0.12) read as the JSON array of {id, kind, key} the Wardley map's tool writes, FBL §8.7), with the blocks layout, identities and those a binding declares. (FBL 0.12) A rule's id { sidecar: { key: "<cel>", kind: <name>, ordinal: "<text>" } } keeps its ids in the identities by kind and natural key, ordinal, holding {n} once, keying each later holder of one key (FBL §5.3, §8.6). template <value> is the bytes of a new body (FBL §13): a string, or a settings map of FBL's Template (byOrigin).
A binding whose family is a capability has no rules: what it reads is what the capability's reader returns (FBL §11.2), and every edit is a splice the capability plans. The capability is required with requires capability (section 13.2).
FBL's guarantees hold for every binding in ATD (FBL §1.4, §6, §7): reading never fails on content, unmapped text is kept byte for byte, every edit is a minimal splice with an exact undo.
family grammar is FBL 0.9's grammar family, with what FBL 0.11 and 0.12 add to it (FBL §4.9): the binding carries an LALR(1) grammar in ATD grammar notation (section 4) and maps the nodes of the tree it reads to elements and relations.
grammar { … }carries the grammar inline: everything between the braces is the grammar's text, read undergrammar/notation.lark(the rulegrammar_text), and is FBL'sbody.grammaras a string.grammar from "<file>.lark"names a file beside the description that holds it, FBL'sbody.grammaras{file}. A binding of the family has exactly one of the two, and a binding of another family has neither.- The grammar is in the subset of section 4.1, its terminals in the subset of section 3.5; its
%imports name the binding's own files beside the description, never the modules of ATD's grammar. It is built as section 4.4 says, from the start rule that the settingstartofbodynames (FBL'sbody.start, defaultstart), with the lexing rule of section 3.6. body { … }takes the family's settings:start, andrecover: { unit: <rule>, sync: [<terminals>] }, which reads a body that does not parse in part (FBL §4.9); (FBL 0.15) andprefixes,ordinalsandorder, settings maps as FBL states them (FBL §3.2, §4.9).- (FBL 0.11)
recoveralso takesnested: { open: <terminal>, close: <terminal> }, the tokens that open and close a block, so that a body is read in part inside blocks too, andunclosed: { <terminal>: "<text>" }, the ignored terminals whose token must end with that text and may run to the end of the body (FBL §4.9, Reading in part):recover: { unit: unit, sync: [_NL], nested: { open: "{", close: "}" }, unclosed: { BLOCK_COMMENT: "*/" } }. - (FBL 0.11) A slot's setting
escape: { with: "\\", quote: "\"" }, written in the slot's block or in its attribute's, reads and writes a quoted value's escapes (FBL §4.9, Escapes, §5.2). - (FBL 0.11) An attribute binding's
createtakes, in this family,{ emit: "<text>", after: [<attributes>], pad: true }: the text of an absent part, the attributes whose parts precede it, nearest first, and whether the parts before it are written empty (FBL §4.9, Writing); andgather: [<slots>], further slots of a read-onlymanyattribute whose items follow the first slot's (FBL §5.2). - (FBL 0.11) A rule's
opensis, in this family, a settings map,opens: { open: " {", close: "}" }, the text of a block written around a first child (FBL §4.9); andselectedView: truereads the rule for the selected view only (FBL §4.9, Views, §9.3). - (FBL 0.12) An attribute binding's slot takes, in this family,
items: { <attribute>: <slot>, … }, a slot per item attribute relative to each node the slot reaches, andseparator: "<text>", so that amanyattribute is a list of structured values (FBL §5.2, §6.3):attribute positions from node "positions/position" { items: { visibility: { node: "visibility" }, maturity: { node: "maturity" } }, separator: "," }. - (FBL 0.15) A slot's selector may reach up and across with
..and+; an attribute binding takesor: [<slots>], further slots of which the first present is the value; and a slot takesexpand: trueorexpand: { keywords: { … } },ordinal: <numbering>andname: true, and itsescapetakessequences,unicode,writesandrequote(FBL §4.9, §5.2, §6.3). A value is read in Turtle's terms with them, asw3c-turtle.larkshows. - (FBL 0.16) An
insert'scontinueswrites a new entry into the last statement of the same subject, replacing its last token (replace-separator), and aremove'spartsandwholetake a part of a list with its separator and the whole statement when it is the last (FBL §4.9, §6.2, §6.3, section 11.5):insert { place: end-of-document, emit: "\n{s} {p} {o} .", continues: { at: "/triples_statement", same: { s: { node: "triples/subject/iri", expand: true } }, separator: ";", emit: "{p} {o} ." } }andremove { parts: [{ item: ".", separator: "," }, { item: "../..", separator: ";" }], whole: "../../../../.." }. - (FBL 0.13) An attribute binding's slot takes, in this family,
split: "<text>", the text at which the value of each node it reaches is cut into the items of amanyattribute, each without the white space around it, and a set of them is written into the node by splices (FBL §4.9, §5.2, §6.3):attribute tags from node "tags" { split: ",", readOnly: true }reads"Extra, More"as the two tagsExtraandMore. - (FBL 0.11) A block rule of this family is
block <name> { … }with the settingsat, the selector of the view's node,view, its key from a slot,origins, the readings that show it, andinsert, how a view block is added (FBL §5.1, §4.9, Views); it has noline. - A rule's
at "<selector>"selects nodes of the tree by their names (at "/triples_statement"), and a slotnode "<selector>"reads the text of the node or token its relative selector reaches, with the settingmatchwhen only part of the text is the value (attribute name from node "PNAME_NS" { match: r"(?<value>[^:]*):" }); FBL §4.9 and §5.2 define both. - The checker builds the grammar with the desktop host's table builder, on
etalii-lark(research R9): a grammar that is not LALR(1), or in which two terminals a state accepts match the same text, is refused withATD8001, placed at the head of the definition of the rule whose reduction is in conflict (of two such rules, the one defined first), and naming the kind of conflict, the terminal and the rules. A grammar the checker cannot read as notation isATD1001at the place it stops, as for any syntax error; a file named bygrammar fromthat is not there isATD2009. atd-grammar.py --tableswrites the normalized tables (section 4.7) of every grammar a binding example carries, inline or from a file, togrammar/tables/<example>.<binding>.tables.json, and those of every grammar an FBL example names togrammar/tables/<fbl example>.<binding>.tables.json, so that the desktop host's builder is cross-checked against Lark's for binding grammars too.
FBL §4.9 says what the family reads, how it writes, and how it reads a body in part; its guarantees are FBL's (section 11.8). In phase 1 no host but the desktop host is required to read the family (FR-081): the family's round-trip fixtures, specifications/fbl/fixtures/w3c-turtle-grammar*/, grammar-*/, (FBL 0.11) structurizr-*/ and (FBL 0.12) wardley-*/, carry the guarantee to every host that implements it later.
The example binding-grammar.atd carries Turtle's grammar inline.