Tutorial on Type Analysis
This tutorial is an introduction to the solution of the type analysis
required for programming language implementation.
It demonstrates many aspects of
that task which can occur in programming languages or special purpose
languages. The solution proceeds from basic aspects, such as declarations,
typed objects, and overloaded operators, up to more complex
aspects, such as type definitions and function types.
This tutorial may be used for a practical introduction to the
specification techniques for type analysis, or as a source of
examples that show how to solve certain problems, or it may give
hints for language design.
This file is an executable specification. An analyzer for an
artificial language can be generated from it. The language is
kept small by restricting it to those constructs necessary to
demonstrate the type analysis task, not regarding its usability
for programming.
The generated analyzer produces output that reports the result of
type analysis, i. e. the type property of program objects.
The explanations in this tutorial assume that the reader is familiar
with the use of the Eli system, with the use of its module library,
and knows the general description of the type analysis task
in the documentation of the module library.
Furthermore, the reader should be familiar with basic concepts of
the name analysis task. Its solution is a precondition for
type analysis. It is described only briefly in this text.
There is a separate tutorial for name analysis, see
Overview of Tutorial on Name Analysis.
Sections 1 to 4 specify a small language kernel and solve the
name analysis task. The focus of the following sections is on
type analysis only. The topics are arranged in an order such that
no forward references are needed. Readers may stop reading at
any section after section 7. They then have a complete description
of the name analysis task for a language that has the constructs
and concepts introduced so far. (It should even be possible to
drop the rest of the specification an generate an analyzer
for the language specified so far. This feature has not yet been
tried.)
For that purpose the example language is presented such that
from section 5 on each section augments the language by some
new constructs and concepts that demonstrate the aspect of
concern. Readers are asked for some patience until they see
what the whole language is.
|