Go up. Go to department page.

Incremental Semantic Analysis

LUTEDX/(TECS-1003)/1-276/(1992)

G. Hedin

Ph.D. thesis, Lund University, Lund, Sweden, 1992.

Abstract

Semantic analysis is a central part of the compilation process. The main subproblems include name analysis, type checking, and detection of static-semantic errors. In an interactive programming environment it is useful to perform the semantic analysis incrementally, keeping the static-semantic information up to date while the program is edited. This allows advanced browsing and editing facilities to be implemented, based on the semantic information. Furthermore, incremental semantic analysis is a prerequisite for making also the rest of the compilation process incremental in order to reduce the turnaround time between editing and execution.

This work is directed towards incremental semantic analysis for object-oriented programming languages. These languages have comparatively complex static-semantics which could not be adequately handled with earlier techniques such as attribute grammars.

The main contribution of this work is a new technique for developing incremental semantic analyzers: Door Attribute Grammars. This technique extends standard attribute grammars by allowing objects and references to be specified as part of the attribution of a syntax tree. Special "door"-objects act as an interface between the syntax tree and its object attribution. This extension results in space-efficient attributions for which incremental updates can be performed efficiently. In particular, the complex naming semantics of object-oriented languages can be handled in a straight forward way by attributing the tree with explicit visibility graphs built using objects and references.

The price for using objects and references in an attribution is that non-local attribute dependencies are introduced which prevent incremental attribute evaluators to be generated completely automatically from the grammar. We solve this problem by splitting the grammar in two parts: one part (the main grammar) which can be treated by automatic methods, and another part (the door package) for which a manual, but systematic, implementation technique is developed. A door package can implement general aspects of a family of programming languages. To specify a new language in the supported family it suffices to write a main grammar, using the door package as a tool box.

The techniques have been developed and tested in practice. A complete incrementally compiling environment has been built: Mjolner/Orm, which currently supports the major part of Simula.