Eli   Documents Get Eli: Translator Construction Made Easy at SourceForge.net.
    Fast, secure and Free Open Source software downloads

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 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


Set a Property at the First Object Occurrence

This module associates values of type TYPE as property NAME to objects identified by keys. The property is set at most once at the first occurrence of the object which has the NAMESetFirst role. The module may for example be used to associate source coordinates of defining identifier occurrences to objects.

The module instantiation differs from the usual pattern for this library:

   $/Prop/SetFirst.gnrc+instance=NAME +referto=TYPE :inst

Note: This module is not applicable to symbol occurrences that do not have an attribute named Key, e.g. due to the use of the referto parameter for a consistent renaming module.

Values are associated in the first NAMESetFirst context with respect to left-to-right depth-first tree order. The property value to be set has to be provided by a user's computation for the attribute NAMESetFirst.NAME (in any, not only the first NAMESetFirst context).

The role NAMERangeSetFirst is automatically associated to the root of the grammar (see Common Aspects of Property Modules). The attribute NAMERangeSetFirst.GotNAME has to be used as a precondition for computations which access the NAME property to guarantee that the property is set.

If we want to associate the source coordinates of defining identifier occurrences to object keys in our running example we instantiate this module using the coordinate type CoordPtr exported by the error module, and the property name DefPt

   $/Prop/SetFirst.gnrc+instance=DefPt +referto=CoordPtr :inst

Then the roles of this module are associated to our grammar symbols:

   SYMBOL DefPoint      INHERITS DefPtSetFirst COMPUTE
      SYNT.DefPt = COORDREF;
   END;

   SYMBOL DefIdent      INHERITS DefPoint END;
   SYMBOL ClassDefIdent INHERITS DefPoint END;
   SYMBOL ModDefIdent   INHERITS DefPoint END;

The property computed this way may for example be used to check whether an identifier occurs in an applied context before its definition, as required e.g. in Pascal. For that purpose a function CoordLess is used to compare coordinates. (It is provided by the PropLib module, which is automatically instantiated when this module is used.)

   SYMBOL ChkBeforeDef COMPUTE 
      IF (CoordLess (COORDREF, GetDefPt (THIS.Key, COORDREF)),
      message (ERROR, 
               CatStrInd ("identifier occurs before its definition: ", 
                          THIS.Sym),
               0, COORDREF))
      DEPENDS_ON INCLUDING DefPtRangeSetFirst.GotDefPt;
   END;

The role ChkBeforeDef is then associated to all grammar symbols that represent applied identifer occurreces which shall be checked.


Previous Chapter Next Chapter Table of Contents