User Defined Syntax
Doktorsavhandling, 1992

This thesis describes two examples of user defined syntax. The first, and most thoroughly investigated, is a new datatype construction, the conctype, the elements of which have a very flexible syntax. An embedded language can easily be introduced into a programming language using conctypes and computations are easily expressed using the concrete syntax and a special pattern matching form. The second example is user defined distfix operators which give a user possibility to extend the syntax for expressions in a programming language. We describe both a user's view and the implementation of these two examples. In both cases, context-free grammars serve as a basis for the definition of the new syntax. A problem that is investigated is how to disambiguate grammars with precedences. To see how this should be done we investigate which language a grammar together with precedence rules defines. For a sub-class of context-free grammars we give a predicate that defines the precedence correct syntax trees according to some precedence rules. We also give an algorithm that transforms such a grammar to an ordinary unambiguous context-free grammar and prove the correctness of the algorithm. We use the algorithm in our implementation of distfix operators. For more general grammars, we isolate one kind of ambiguity which is suitable to resolve with precedence rules. We define the generated language for such a grammar by an attribute grammar. This approach of resolving ambiguity is used in the implementation of conctypes.

distfix operators

user's view




datatype construction



Annika Aasa

Institutionen för datavetenskap


Data- och informationsvetenskap



Doktorsavhandlingar vid Chalmers tekniska högskola. Ny serie: 890

Mer information