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


Basic Scope Rules

In many cases of name analysis the language distinguishes between defining occurrences of identifiers in declaration and applied occurrences in expressions (an example with only one kind of identifier occurrence is shown below). Hence, we extend our kernel grammar by DefIdent for defining occurrences of identifiers and UseIdent for applied occurrences, and by Declarations that introduce names for values. An Expression can be an applied identifier occurrence.

Furthermore we introduce nested Blocks by deriving them from Expressions, and hence also from Statements.

CoreScope.con[5]==

Declaration:    'val' ValDecls ';'.
ValDecls:       ValDecl // ','.
ValDecl:        DefIdent '=' Expression.
Expression:     Block.
Operand:        UseIdent.

DefIdent:       Ident.
UseIdent:       Ident.
This macro is attached to a product file.

The basic task of name analysis is consistent renaming. For each identifier occurrence a Key attribute is computed such that identifier occurrences that refer to the same object in the program have the same Key attribute value. Hence Keys identify program objects uniquely. Keys are used to associate properties with program objects and to retrieve those properties in different contexts.

The scope rules of a language determine how identifier occurrences are bound to program objects.

The basic Algol-like scope rule reads:

A definition of an identifier a is valid in the whole smallest range that encloses that definition, except inner ranges that contain another definition of a.

Hence, a definition in an outer range is hidden by a definition of the same identifier in an inner range for the whole inner range. Identifiers may be applied before they are defined.

We instantiate a library module that provides computations according to this scope rule:

CoreScope.specs[6]==

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

The computational roles RangeScope, IdDefScope, and IdUseEnv are associated with the corresponding symbols of our grammar.

CoreScope.lido[7]==

SYMBOL Block    INHERITS RangeScope END;
SYMBOL DefIdent INHERITS IdDefScope, IdentOcc END;
SYMBOL UseIdent INHERITS IdUseEnv, IdentOcc END;
This macro is attached to a product file.

As a result attributes DefIdent.Key and UseIdent.Key are computed according to the scope rules.


Previous Chapter Next Chapter Table of Contents