Eli   Documents

General Information

 o Eli: Translator Construction Made Easy
 o Global Index
 o Frequently Asked Questions
 o Typical Eli Usage Errors

Tutorials

 o Quick Reference Card
 o Guide For new Eli Users
 o Release Notes of Eli
 o Tutorial on Name Analysis
 o Tutorial on Scope Graphs
 o Tutorial on Type Analysis
 o Typical Eli Usage Errors

Reference Manuals

 o User Interface
 o Eli products and parameters
 o LIDO Reference Manual
 o Typical Eli Usage Errors

Libraries

 o Eli library routines
 o Specification Module Library

Translation Tasks

 o Lexical analysis specification
 o Syntactic Analysis Manual
 o Computation in Trees

Tools

 o LIGA Control Language
 o Debugging Information for LIDO
 o Graphical ORder TOol

 o FunnelWeb User's Manual

 o Pattern-based Text Generator
 o Property Definition Language
 o Operator Identification Language
 o Tree Grammar Specification Language
 o Command Line Processing
 o COLA Options Reference Manual

 o Generating Unparsing Code

 o Monitoring a Processor's Execution

Administration

 o System Administration Guide

Mail Home

Association of properties to definitions

Previous Chapter Next Chapter Table of Contents


Map Objects to Integers

This module computes a mapping of object keys to non-negative numbers A number is associated as property named NAMEObjNo to each object exactly once. In each NAMERangeObjCnt subtree the numbers are chosen separately starting from 0 incrementing by 1 (changeable default). NAMERangeObjCnt is automatically associated to the grammar root.

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 role NAMEObjCnt has to be associated to grammar symbols such that all objects that should be considered have an occurrence in such a context. The attribute NAMEObjCnt.NAMEObjNo is the number the object is mapped to.

NAMERangeObjCnt is automatically associated to the grammar root (see Common Aspects of Property Modules). The attribute NAMERangeObjCnt.NAMETotalObjNo is the total number of objects in that range. The ranges may be nested. The mapping starts anew for each range node. The mappings of inner ranges do not contribute to outer ranges.

The default start value is 0. It can be changed by overriding the computation of NAMERangeObjCnt.NAMEInitObjCnt. The computation of NAMEObjCnt.NAMEIncrementCnt can be overridden to change the default increment value of 1.

If the ObjNo property is accessed by user's computations, they have to state NAMERangeObjCnt.NAMETotalObjNo as a precondition.

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. The ObjCnt is simply attached to the IdentOcc role which represents any identifier occurrence in our example:

   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;


Previous Chapter Next Chapter Table of Contents