Next: Defining a domain
Up: The ALLCOT syntax
Previous: The ALLCOT syntax
A category definition looks like
Identifier : Identifier FunctionDeclarationSequence |
|
or like
Identifier : FunctionDeclarationSequence |
|
where in each case
- the first
Identifier must be a new identifier,
- the second
Identifier must refer to an existing category,
-
FunctionDeclarationSequence is a sequence (possibly empty) of
function declarations, each declaration ending with a ;.
The specifications of the so-defined category
consists of the function declarations on the right
of the with key-word, plus
the specifications of the existing category, if present.
A function declaration looks like
Identifier : TypeSequence Type |
(1) |
where
-
Identifier must be a new identifier,
-
TypeSequence is a sequence (possibly empty)
of % or type identifiers, separated
by commas,
- Type is % or a type identifier, or () (which means void).
such that
- either % is the first element in
TypeSequence
(and the function is viewed as a method)
- or % is not the first element in
TypeSequence
but Type is % (and the function is viewed as a creator).
The above constraint is not required in ALDOR
and is meant here to ease the type checking in ALLCOT.
We shall return to this later.
Some remarks regarding the non-terminal Type.
There are circumstances where Type cannot be % or () .
For instance, we shall never need to declare of variable of type () .
Moreover, in the definition of the main function, we
shall never need to declare of variable of type %.
These special cases can be treated at the level of the type checking.
Observe that the empty list () can be generated by two
different ways: as an empty list of parameter of a function or as the void type.
Next: Defining a domain
Up: The ALLCOT syntax
Previous: The ALLCOT syntax
Marc Moreno Maza
2004-12-01