next up previous contents index
Next: 3.2 Expressions Up: 3 Tutorial Previous: 3 Tutorial

3.1 Starting with an Example

external

To   get a global view of AS, let us take a small example that will not look too strange to old Centaur users: the EXP example.

abstract syntax of EXP is

assign : Var # Exp -> Exp;
plus, minus, prod : Exp # Exp -> Exp;
uminus : Exp -> Exp;

#integer : integer -> Int;
variable : string -> Var;

Var < Exp;
Int < Exp;

exp_s : EXP+ -> Exp_s;

Atoms = Var + Int;

end Exp;

This     definition defines tree kinds of objects: one formalism (EXP), five phyla (Exp, Int, Var, Exp_s and Atoms), eight operators (assign, plus, minus, prod, uminus, #integer, variable and exp_s). As integer is a keyword of AS, the name integer has been used for an operator by prefixing it with a sharp symbol.

external Keywords

Only three sorts of statements are used: operators definitions (giving their signatures), types inclusions, and types unions. In signatures, the sharp symbol (#) represents the product of phyla and the notation ``P+'' reads as ``list of P''. Type inclusion is represented by ``<'' and type union by ``+''.

external Definition of Operators, Definition of Phyla Lists

The types integer and string are predefined.

external Predefined Types

external


next up previous contents index
Next: 3.2 Expressions Up: 3 Tutorial Previous: 3 Tutorial

Thierry Despeyroux
Fri May 16 15:24:06 MET DST 1997