Rewritable Reference Attributed Grammars - design, implementation, and applications

Torbjörn Ekman

Research output: ThesisLicentiate Thesis


This thesis presents an object-oriented technique for rewriting abstract syntax trees in order to simplify compilation. The technique, Rewritable Reference Attributed Grammars (ReRAGs), is completely declarative and supports both rewrites and computations by means of attributes. We have implemented ReRAGs in our aspect-oriented compiler compiler tool JastAdd II. We present the ReRAG formalism, its evaluation algorithm, and examples of its use. JastAdd II uses three synergistic mechanisms for supporting separation of concerns: inheritance for model modularization, aspects for cross-cutting concerns, and rewrites that allow computations to be expressed on the most suitable model. This allows compilers to be written in a high-level declarative and modular fashion, supporting language extensibility as well as reuse of modules for different compiler-related tools. Each technique is presented using a series of simplified examples from static semantic analysis for the Java programming language.
A case study is presented where ReRAGs are used extensively to implement a compiler for the Control Module extension to the IEC61131-3 automation languages. That Control Modules concept is further extended, in a modular fashion, with object-oriented features to improve encapsulation, composition mechanisms, code re-use, and type safety.
Original languageEnglish
Awarding Institution
  • Department of Computer Science
  • Hedin, Görel, Supervisor
  • Nilsson, Klas, Supervisor
  • Magnusson, Boris, Supervisor
Publication statusPublished - 2004

Subject classification (UKÄ)

  • Computer Science


Dive into the research topics of 'Rewritable Reference Attributed Grammars - design, implementation, and applications'. Together they form a unique fingerprint.

Cite this