@@ -236,22 +236,22 @@ not administrative ones.
236236In addition to the basic grammar shown above,
237237definitions of syntax variants can also be split into multiple _ fragments_ :
238238```
239- def ::=
240- "syntax" varid subid* "=" deftyp-frag syntax fragment definition
239+ deftyp ::= ...
240+ deftyp-frag syntax fragment definition
241241
242242deftyp-frag ::=
243243 "..."
244244 ("..." "|")? casetyp*"|" ("|" "...")? variant fragment
245245```
246246A variant with dots "..." at the end can be extended further by later variant definitions of the same name.
247- This definition must start with dots, accordingly.
247+ These definitions must start with dots, accordingly.
248248A variant is completed by a fragment without trailing dots.
249249Each fragment must be named uniquely by amending the type name with a (possibly empty) list of hierarchical sub-identifiers of the form ` x/y ` ,
250250which can be used to refer to a fragment from splices.
251251Currently, variant types defined in fragments cannot have parameters.
252252
253253** Example:**
254- The instruction syntax above could be defined in two fragments:
254+ The instruction syntax above could be defined in multiple fragments:
255255```
256256syntax instr/stack = DROP | ...
257257syntax instr/arith = ... | CONST numtyp const | ...
@@ -297,6 +297,32 @@ syntax person = {NAME text, AGE nat, ADDRESS text}
297297SpecTec provides special syntax for accessing values of record type,
298298in particular, dot notation for field access.
299299
300+ In addition to the basic grammar shown above,
301+ like [ variant types] ( #variant-types ) ,
302+ definitions of record syntax can also be split into multiple _ fragments_ :
303+ ```
304+ deftyp-frag ::=
305+ "{" "..." "}"
306+ "{" ("..." ",")? fieldtyp*"," (...")? "}" record fragment
307+ ```
308+ A record with dots "..." at the end can be extended further by later record definitions of the same name.
309+ These definitions must start with dots, accordingly.
310+ A record is completed by a fragment without trailing dots.
311+ Each fragment must be named uniquely by amending the type name with a (possibly empty) list of hierarchical sub-identifiers of the form ` x/y ` ,
312+ which can be used to refer to a fragment from splices.
313+ Currently, record types defined in fragments cannot have parameters.
314+
315+ ** Example:**
316+ The person record above could be defined in multiple fragments:
317+ ```
318+ syntax person/name = { NAME text, ... }
319+ syntax person/age = { ..., AGE nat, ... }
320+ syntax person/address = { ..., ADDRESS text }
321+ ```
322+
323+ Semantically, a record definition split into fragments is equivalent to a combined one.
324+ Splitting a definition only has organisational purpose.
325+
300326
301327##### Premises
302328
0 commit comments