General Information

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

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

Reference Manuals

 o User Interface
 o Eli products and parameters
 o LIDO Reference Manual

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

 Questions, Comments, ....

Tutorial on Type Analysis

Previous Chapter Next Chapter Table of Contents


Type Definitions

We now introduce type definitions to our language. A name can be defined for any TypeDenoter. That name can be used to denote the type it stands for.

The following concrete productions are added:

TypeDef.con[40]==


Declaration:    'type' TypeDenoter TypeDefIdent ';'.
TypeDefIdent:   Ident.

This macro is attached to a product file.

Here is an example program with type definitions. It makes use of the facility that identifiers may be defined after their uses: TypedefExamp[41]==

begin
  var   tt rv;
  type  t tt;
  type  record int i, bool b, real r end t;
  var   int j, bool c, real s;
  var   t rt;
  j = rv.i;
  c = rv.b;
  s = rv.r;
  rt = rv;
end

This macro is attached to a product file.

A type definition introduces a new name for a type given by the TypeDenoter. In our language we specify that a type definition does not introduce a new type, rather it introduces another name for a type. Hence, there may be many different names for the same type. This view is supported by the roles of the Typing module: They just establish a Defer relation from the key of the TypeDefIdent to the type of the TypeDenoter.

Hence, in the following specification we only have to characterize a defining occurrence of a type identifier by the corresponding roles of the name analysis module and those for a defining occurrence of a type identifier (TypeDefDefId, ChkTypeDefDefId). In the Declaration context the Type attribute is just passed from the TypeDenoter to the TypeDefIdent.

TypeDef.lido[42]==


SYMBOL TypeDefIdent INHERITS 
        ChkUnique, IdDefScope, IdentOcc,
        TypeDefDefId, ChkTypeDefDefId
END;

RULE: Declaration ::= 'type' TypeDenoter TypeDefIdent ';' COMPUTE
  TypeDefIdent.Type = TypeDenoter.Type;
END;

This macro is attached to a product file.

If we wanted to deviate from the above rules for name equality in case of certain types, we would use the same specification, and would augment the function that checks for equality of type by suitable comparisons, e. g. compare the structure of two record types.


Previous Chapter Next Chapter Table of Contents