Association of properties to definitions
This module computes a mapping of object keys to non-negative numbers
A number is associated as property named
The module can be used to just count the objects that occur in a range, to prepare for generating unique identifier names on output, or to map objects of a range to addresses that are incremented by a certain value.
The module is instantiated by
$/Prop/ObjCnt.gnrc+instance=NAME +referto=KEY :inst
The default start value is 0. It can be changed by
overriding the computation of
We demonstrate an application of this module by mapping the objects
of out running example to unique numbers, in order to print
unique names as they resulted from the consistent renaming task.
For that purpose the grammar root can be chosen for the range role.
SYMBOL Program COMPUTE printf ("the program references %d different objects\n", THIS.TotalObjNo); END; SYMBOL IdentOcc INHERITS ObjCnt COMPUTE printf ("object %s%d referenced in line %d\n", StringTable (THIS.Sym), THIS.ObjNo, LINE); END;