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

Tutorial on Name Analysis

Previous Chapter Next Chapter Table of Contents


Insertion of Scopes into the Environment Hierarchy

We now demonstrate how scopes obtained from object properties are inserted into the environment hierarchy given by the syntactically nested ranges. For this purpose we extend our module example.

We introduce a with statement that allows the components of a module to be used without qualification in the WithBody. (This construct is similar to the with statement in Pascal, where record variables are used instead of the module identifiers discussed here. It directly corresponds to the use construct in Ada.)

ScopeInsert.con[25]==

Statement:      'with' WithClause 'do' WithBody.
WithClause:     ModUseIdent.
WithBody:       Statement.
This macro is attached to a product file.

The WithBody is a special kind of range: The scope rules for our with statement require that the scope of the module stated by the ModUseIdent is inserted in the environment hierarchy between the scope of the WithBody and the environment formed by the range nest that encloses the with statement. I.e. a definition in a range enclosing the with statement may be hidden by a definition of the module; those definitions may be hidden within the WithBody. (In the case of our language the WithBody may not directly contain declarations, although deeper nested Blocks may contain such declarations.)

We use another library module (see Inheritance of Scopes of Specification Module Library: Name Analysis) to support such an embedding of environments:

ScopeInsert.specs[26]==

$/Name/AlgInh.gnrc:inst
This macro is attached to a product file.

The facility of inserting an environment obtained from a scope property of an object is provided by the module role InhRange, which specializes RangeScope. The ModUseIdent establishes the inheritance using the module role InheritScope. The inserted outer scope is obtained from ModUseIdent.Key, the inner scope is specified by the attribute WithBody.Env. The computation of WithBody.GotInh is required to state that the inheritance is established.

ScopeInsert.lido[27]==

SYMBOL WithBody INHERITS InhRange END;

RULE: Statement ::= 'with' WithClause 'do' WithBody COMPUTE
  WithClause.InnerScope = WithBody.Env;
  WithBody.GotInh = WithClause.InheritOk;
END;

SYMBOL WithClause INHERITS InheritScope, ChkInherit END;

RULE: WithClause ::= ModUseIdent COMPUTE
  WithClause.ScopeKey = ModUseIdent.Key;
END;
This macro is attached to a product file.


Previous Chapter Next Chapter Table of Contents