summaryrefslogtreecommitdiffstats
blob: 650c3299aa4946cf0c6e488032f218e4ec914367 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
-- @name		Program
-- @version		0.1
-- @domains		programming
-- @authors		Frédéric Jouault
-- @date		2007/03/07
-- @description	This metamodel describes programs. A Program inherits both from Structure and ProcContainerElement. A Progam can contain VariableDeclarations (as a Structure), Procedures (as a ProcContainerElement), and Monitors. A Monitor is also a Structure and a ProcContainerElement, and can therefore contain VariableDeclarations and Procedures. Besides Statements and Parameters, a Procedure, as a Structure, can also contain VariableDeclarations. Each VariableDeclaration is associated with a one and only Type. It may also contain an initial value that is represented by an Expression (see below). Parameters inherit from VariableDeclaration. They are characterized by a "direction" attribute ("in" or "out"). A Procedure contains a sequence of Statements. An AssignmentStat contains a "target" VariableExp and a "value" Expression. A WhileStat contains a "condition" Expression and several "doStats" Statements. A ConditionalStat contains a "condition" Expression, several "thenStats" Statements and, optionally, "elseStats" Statements. Finally, an ExpressionStat simply contains an Expression. Expression is an abstract entity from which the following elements inherit: IntegerExp and BooleanExp (which inherit from the abstract LiteralExp entity), VariableExp which is associated with a VariableDeclaration, PropertyCallExp (abstract) which is characterized by its "source" element (of type Expression). There exist three types of PropertyCallExp: the AttributeCallExp, the OperatorCallExp and the ProcedureCallExp. An OperatorCallExp contains a right element (of type Expression). A ProcedureCallExp can contain "argument" Expressions.
package Program {

	abstract class LocatedElement {
		attribute location[0-1] : String;
		attribute commentsBefore[*] ordered : String;
		attribute commentsAfter[*] ordered : String;
	}
    
	abstract class NamedElement extends LocatedElement {
		attribute name : String;
	}
	
	abstract class Structure extends NamedElement {
		reference variables[*] ordered container : VariableDeclaration oppositeOf structure;    
	}
	
	abstract class ProcContainerElement extends Structure {
		reference procedures[*] ordered container : Procedure oppositeOf "container";
	}
	
	class Program extends ProcContainerElement {
		reference monitors[*] ordered container : Monitor oppositeOf program;
	}
	
	class Monitor extends ProcContainerElement {
		reference program : Program oppositeOf monitors;
	}
	
	-- Procedures
	class Procedure extends Structure {
		reference "container" : ProcContainerElement oppositeOf procedures;
		reference parameters[*] ordered container : Parameter oppositeOf procedure;
		reference statements[*] ordered container : Statement;
	}
	
	class VariableDeclaration extends NamedElement {
		reference type : Type;
		reference initialValue[0-1] container : Expression;
		reference structure : Structure oppositeOf variables;
	}

	class Parameter extends VariableDeclaration {
		attribute direction : Direction;
		reference procedure : Procedure oppositeOf parameters;
	}

	enumeration Direction {
		literal in;
		literal out;
	}
	-- End Procedures

	-- Types
	class Type extends NamedElement {
	}
	-- End Types

	-- Expressions
	abstract class Expression extends LocatedElement {
	}
    
	class VariableExp extends Expression {
		reference declaration : VariableDeclaration;
	}
    
	-- PropertyCalls
	abstract class PropertyCallExp extends Expression {
		reference source container : Expression;
		attribute name : String;
	}

	class OperatorCallExp extends PropertyCallExp {
		reference right container : Expression;
	}

	class AttributeCallExp extends PropertyCallExp {
	}

	class ProcedureCallExp extends PropertyCallExp {
		reference arguments[*] ordered container : Expression;
	}
	-- End PropertyCalls

	-- Literals    
	abstract class LiteralExp extends Expression {
	}

	class BooleanExp extends LiteralExp {
		attribute symbol : Boolean;
	}

	class IntegerExp extends LiteralExp {
		attribute symbol : Integer;
	}
	-- End Literals    
	-- End Expressions

	-- Statements
	abstract class Statement extends LocatedElement {
	}

	class AssignmentStat extends Statement {
		reference target container : VariableExp;
		reference value container : Expression;
	}
    
	class ConditionalStat extends Statement {
		reference condition container : Expression;
		reference thenStats[1-*] container : Statement;
		reference elseStats[*] container : Statement;
	}
    
	class WhileStat extends Statement {
		reference condition container : Expression;
		reference doStats[1-*] container : Statement;
	}

	class ExpressionStat extends Statement {
		reference expression container : Expression;
	}
	-- End Statements
}

package PrimitiveTypes {
	datatype Boolean;
	datatype Integer;
	datatype String;
}