[NEXT] [PREV]    HANDBOOK / LANGUAGE REFERENCE MANUAL /

Introduction

Gentle
Applications
Concepts
Examples
Handbook
Support
Download

Gentle is a high-level programming language for compiler writers. It covers the whole spectrum of compiler construction, ranging from analysis over transformation to synthesis. Gentle provides a uniform notation for all tasks.

Language Overview

The language is based on recursive definition and structural induction, the underlying paradigm of virtually all translation tasks.

Gentle allows the user to define mutally recursive types by enumerating alternative structures


   Expr = plus(Expr,Expr), minus(Expr,Expr), const(INT)
Programs in Gentle are expressed by rules of the form

   G : A B C
These rules may be interpreted as grammar rules ( G is constructed from A, B, and C), as logical statements ( G is true if A, B, and C are true), or in a procedural manner (to solve task G, solve subtasks A, B, and C).

Members of a rule may have parameters (an arrow separating input from output parameters). This results in attributed grammars


   AddingExpression(-> plus(X1, X2)):
      AddingExpression(-> X1) "+" Primary(-> X2)
or in transformation schemes that inductively follow the structure of terms

   Eval(plus (X1, X2)->N1+N2): Eval(X1->N1) Eval(X2->N2).
   Eval(minus(X1, X2)->N1-N2): Eval(X1->N1) Eval(X2->N2).
   Eval(const(N)     ->N).
Unparsing may be expressed in a similar way

   Code(plus(X1, X2) -> Reg2) :
      Code(X1 -> Reg1)
      Code(X2 -> Reg2)
      Emit("add", Reg1, Reg2).
Such rules can be augmented by cost values. Then, rules are selected in such a way that the sum of the costs of all selected rules is optimal. This allows a nondeterministic specification that handles idioms of the target machine by rules with corresponding patterns.

Gentle is a strongly typed language that allows a tool to statically check the consistency of the specification. Traditional errors such as uninitialized variables can be detected at the earliest point.

Gentle has a declarative flavor. It also provides mutable global variables and tables to represent deferred information and cyclic structures. Gentle supports procedures written in other languages.

Related Languages

Gentle descends from CDL [7] and Prolog [15]. An early version was described in [10].





[NEXT] [PREV]