An overview of the OPTRAN system
OPTRAN is a batch-oriented system for the generation of compilers that support program transformations. Programs are represented by attributed abstract syntax trees (AAST). The transformation of AAST's is a powerful method to describe problems in compiler writing such as machine-independent optimizations, language-based editors, and source-to-source translations.
The specification language OPTRAN allows for a static and declarative description of tree transformations. An OPTRAN transformation unit consists of a tree grammar specifying the underlying language of abstract syntax trees, an attribute grammar defining the decoration of these trees with semantic attributes, a set of transformation rules to be exhaustively applied to the attributed trees, and a strategy for the application of these rules.
Given such a specification, the system will automatically generate the transformation system, mainly consisting of efficient attribute evaluators and reevaluators, as well as a tree pattern matcher and transformer. The attribute grammar class accepted by the evaluator generator is the class of strongly noncircular AG's. Ordered partitions and evaluation plans are generated based upon an analysis of global dependencies, cf. [LMW89]. A linear time pattern matcher, a bottom up tree automaton, is generated from the set of input patterns of the transformation rules, cf. [MWW86]. Very effective table compression methods have been developped in order to arrive at acceptable table sizes, cf. [BMW91].
The main goal of the system design is the usage of precomputation methods wherever possible. The technique of Grammar Flow Analysis has been developped for that purpose, cf. [Mön91]. The static view of transformations makes it possible to generate highly efficient transformers.
The system is written in Pascal and generates Pascal programs. Pascal also serves as host language, i.e. semantic rules are specified as Pascal procedures. This complicates the error diagnosis of the runtime system as the semantics of these procedures is not obvious to the generator system. Furthermore it inhibits the recognition of certain properties of the specification like invariance of attribute assignments under non-trivial transformations. In that respect, OPTRAN could profit from a functional specification language. On the other hand, disciplined users can very effectively use the additional freedom they enjoy in an imperative language. Meanwhile, the execution time system has been translated to C with some gain in run time efficiency.
The system has been used for machine independent code optimization, semantic analysis, standardization of intermediate representation, and overload resolution in an Ada front end, code generation, and source-to-source translation.
- [BMW91]J. Börstler, U. Möncke, R. Wilhelm, “Table Compression for Tree Automata”, to appear in ACM Transaction on Programming Languages and Systems, 1991Google Scholar
- [LMW89]P. Lipps, U. Möncke, R. Wilhelm, “OPTRAN — A Language/System for the Specification of Program Transformations: System Overview and Experiences”, LNCS 371, pp. 52–65, Springer-Verlag, 1989Google Scholar
- [MWW86]U. Möncke, B. Weisgerber, R. Wilhelm, “Generative Support for Transformational Programming”, ESPRIT '85: Status Report of Continuing Work, The Commission of the European Communities (eds.), pp. 511–527, Elsevier Science Publishers B. V. (North-Holland), 1986Google Scholar
- [Mön91]U. Möncke, “Grammar Flow Analysis”, this volumeGoogle Scholar