Generating Software from Specifications WS 2013/14 - File SignaturesSol.fw
@=~
~p maximum_input_line_length = infinity
This file contains the specification of a language
for sequences of declarations with polymorphic types.
A declaration consists of a name and a polymorphic type.
(You may insert a separator or a terminator.)
A type is a function type, denoted by the binary type operator ->,
a tupel type, denoted by the binary type operator *,
a list type denoted by the unary postfix type operator list,
a polymorphic type parameter,
parentheses to override precedences.
The precedence of type operators decreases in the following order:
list, *, ->.
* associates to the left, -> associates to the right.
The following file contains correct input for the processor.
Add further examples to check every language construct:
~O~<Signature.ok~>~{
ggt: int*int -> int;
pair: 'a * 'b;
lg: 'a list -> int;
map: ('a -> 'b * 'a list) -> 'b list;
cmap: ('a -> 'b) -> 'a list -> 'b list;
~}
The following file specifies the concrete syntax:
~O~<Signature.con~>~{
Program: Signatures.
Signatures: Signatures Signature / Signature.
Signature: Ident ':' AType ';'.
AType: BType '->' AType / BType.
BType: BType '*' CType / CType.
CType: CType 'list' /
'int' / 'bool' /
TypeParam /
'(' AType ')'.
~}
The following file specifies the non-literal tokens:
~O~<Signature.gla~>~{
Ident: C_IDENTIFIER
TypeParam: $'[a-z] [mkidn]
~}
Redundant chain productions are eliminated:
~O~<Signature.map~>~{
MAPSYM
Type ::= AType BType CType.
~}
Generiert mit Camelot | Probleme mit Camelot? | Geändert am: 13.11.2013


