class_declaration ::= ( [ 'external' ] | [ 'abstract' ]\ [ 'value' ] )
'class' parametrized_class 'is' class_body 'end' .
parametrized_class ::= class_identifier
[ '[' class_bounds ']' ] [ '('class_parameters ')' ] .
class_identifier ::= identifier .
class_bounds ::= identifiers | '$*$' ( ',' '$*$' )\stern .
identifiers ::= identifier ( ',' identifier )\stern .
class_parameters ::= class_parameter ( ';' class_parameter )\stern .
class_parameter ::= identifier [ '$<$' type_bound ] .
type_bound ::= type_specifier .
type_specifier ::= class_specifier | 'SAME' | bound_method_type | stream_type |
polymorphic_type .
polymorphic_type ::= '\dollar' class_specifier | '\dollar' SAME .
class_specifier ::= identifier [ '[' bounds ']' ] [ '(' class_arguments ')' ] .
bounds ::= bound ( ',' bound )\stern .
bound ::= '$*$' | expression .
class_arguments ::= class_argument ( ',' class_argument )\stern .
class_argument ::= class_specifier .
class_body ::= [ inheritances ] [ feature_declarations ] .
inheritances ::= inheritance ( ';' inheritance )\stern ';' .
inheritance ::= subtype_inheritance | include_inheritance .
subtype_inheritance ::= 'subtype' 'of' class_specifier [ ':' modifications ] .
include_inheritance ::= [ 'private' ] 'include' class_specifier [(
':' | '::') modifications ] .
modifications ::= modification ( ',' modification )\stern .
modification ::= feature_specification [ '$\ttarrow$' [ identifier ] ] .
feature_specification ::= identifier [ method_specification ].
method_specification ::= [ '(' parameter_types ')' ] [ ':' result_type ] .
parameter_types ::= parameter_type ( ',' parameter_type )\stern .
parameter_type ::= parameter_kind type_specifier .
parameter_kind ::= [ '!' | '\&' | '\&\&' ] .
result_type ::= type_specifier .
bound_method_type ::= ( 'procedure' | 'stream' ) method_specification .
stream_type ::= 'stream' '!' method_specification .
For feature declarations see 5.
Examples:
abstract class STACK(T) is - the interface of stack implementations ... end; value class COMPLEX is re,im: FLTD; ... end; external class TCL_INTERFACE is ... end; class ORDERED_SET(T<ORDERED) is ... end; class TRIANGULAR_MATRIX[n](T) is ...end;
Class specifiers:
INT TCL_INTERFACE \
TRIANGULAR_MATRIX[n+1](FLTD)
SET(INT) T($ SET(CHAR))
Type specifiers:
$SET(INT) SAME procedure(INT, :INT)
stream(!INT):INT
A class declaration without class parameters and without inheritance clauses immediately defines a class. Other class declarations are transformed into classes as explained in 4.2. The prefixes external, abstract and value respectively determine the kind of the class. A class without the prefix external or abstract defines a concrete class. A class without the prefix external or value defines a reference class.
Class bounds are used for array classes, cf. 8.2.1. They determine
the number and length of the dimensions of the array. Stars indicate that
the names of the bounds are inherited from a superclass which then must
also be an array class.