Go backward to 1 CASL concrete syntax related to data type declaration
Go up to Top
Go forward to 3 SORT-GEN-ITEM : Some Examples
2 SORT-ITEM : Some Examples for
DATATYPE-DECL
2
With this construct, CASL provides the facility to specify concisely
various ways for building data of a given sort.
- spec
- LIST[sort Elem] =
- sort
-
- List[Elem] ::=
-
empty |
sort Elem |
__ __:Elem×List[Elem]
- ...
-
- end
-
An equivalent (and more verbose) specification for
LIST[sort Elem] is the following:
- spec
- LIST[sort Elem] =
- sort
- List[Elem];
Elem<List[Elem]
- ops
- empty: -> List[Elem];
__ __:Elem×List[Elem] -> List[Elem]
- ...
-
- end
-
It is often quite practical to provide selectors
(as the_name_of and the_content_of in the FILE example)
to easily recover the various parts from which a data is build.
- spec
- FILE =
- sort
-
- File ::= <__.__>:
-
(the_name_of__:Name) ×
(the_content_of__:Content)
- end
-
An equivalent (and quite more verbose) specification for FILE
is the following:
- spec
- FILE =
- sort
- File
- ops
- <__.__>: Name ×Content -> File;
the_name_of__: File -> Name;
the_content_of__:File -> Content
- axioms
-
- forall n:Name, c:Content
-
- .
- the_name_of <n.c> = n
- .
- the_content_of <n.c> = c
- end
-
CoFI
Note: M-2 ---- 5 January 1998.
Comments to Christine.Choppy@irin.univ-nantes.fr