Association of properties to definitions
Objects in an input text are often classified to belong to one
of several kinds, e.g. variables, procedures or labels in programming
languages. They may occur in different contexts which determine their kind,
require that they belong to a certain kind, or select different computations
depending on their kind.
Such a classification is often the part of the type analysis task.
This module can be used for any unique classification of objects
which is encoded by integral values.
If Objects may belong to more than one kind, or occurrences allow
for objects of several kinds the module KindSet
(see Associate Sets of Kinds to Objects) should be used instead of this one.
The module is instantiated by
$/Prop/Kind.gnrc+instance=NAME +referto=KEY :inst
This module associates a property named NAMEKind of type int
to objects. Two computational roles NAMESetKind and NAMEGetKind
are provided.
In a context NAMESetKind the NAMEKind
property of the object is set to the value of the attribute
NAMESetKind.NAMEKind , which has to be provided by a user's computation.
In case that different Kind values are stated for one object
in some NAMESetKind contexts the property value 0 named
IntMultiple is associated.
In a context NAMEGetKind the property is accessed and supplied by
the attribute NAMEGetKind.HasNAMEKind .
It can be used to check if it is the required kind, or
if the kind is ambigously set (IntMultiple ), or
if the kind is not set at all (value -1 named (IntNone ).
The roles NAMESetKind and NAMEGetKind may be associated
to the same grammar symbol. That is necessary if kinds are determined
by applications of objects rather than by definitions, or if a
language does not distinguish between defining and applied occurrences.
NAMERangeKind is automatically associated to the
grammar root (see Common Aspects of Property Modules).
If the NAMEKind property is accessed in other user's computations,
those have to state NAMERangeKind.GotNAMEKind as precondition.
IntMultiple and IntNone are defined in a file
KindBad.h . If their encoding is inconvenient for a particular
implementation, that file may be overridden by a user supplied file
having the name KindBad.h .
|