summaryrefslogtreecommitdiffstats
blob: 33ceeef0c526f6f0548084477f167d8c25c2a68a (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
-- @name		ANTLR
-- @version		1.0
-- @domains		MDE, Grammarware
-- @authors		Frédéric Jouault
-- @date		2007/09/19
-- @description	This ANTLR metamodel is used for both ANTLRv2 and ANTLRv3. Two distinct TCS models (ANTLRv2.tcs, and ANTLRv3.tcs) are used. Only few changes where required to make this metamodel compatible with ANTLRv3: 1) separating labelDeclarations and declarations, 2) ProductionRule.needReturnDeclaration : Boolean.
-- @see			http://www.antlr.org
package Core {

	abstract class LocatedElement {
		attribute location : String;
		attribute id : String;
	}

	abstract class NamedElement extends LocatedElement {
		attribute name : String;
	}
}

package ANTLR {

	class Grammar extends NamedElement {
		attribute "package" ordered : String;
		reference actions[*] ordered container : SemanticAction;
		reference rules[*] ordered container : ProductionRule oppositeOf grammar;
		attribute options ordered : String;
		attribute lexer ordered : String;
		reference lexerRules[*] ordered container : ProductionRule oppositeOf grammarAsLexer;
	}

	class ProductionRule extends NamedElement {
		reference grammar[0-1] : Grammar oppositeOf rules;
		reference grammarAsLexer[0-1] : Grammar oppositeOf lexerRules;

		reference actions[*] ordered container : SemanticAction;
		reference returns[0-1] container : VariableDeclaration;
		reference declarations[*] ordered container : VariableDeclaration;

		-- necessary for ANTLRv3 because we do not need an Object ret = null; definition
		-- thanks to the automatic label declaration
		attribute needReturnDeclaration : Boolean;

		-- only necessary for ANTLR v2, because there are automatically created with ANTLR v3
		reference labelDeclarations[*] ordered container : VariableDeclaration;
		reference parameters[*] ordered container : Parameter;
		reference expression container : Expression oppositeOf rule;
		attribute options[*] ordered : String;
	}


-- @begin Expressions
	abstract class Expression extends LocatedElement {
		reference sequence[0-1] : Sequence_ oppositeOf expression;
		reference rule[0-1] : ProductionRule oppositeOf expression;
		reference prevAction[0-1] container : SemanticAction;
		reference action[0-1] container : SemanticAction oppositeOf expression;
		reference storeTo[0-1] container : Variable;
		reference concatenation[0-1] : Concatenation oppositeOf expressions;
		reference alternative[0-1] : Alternative oppositeOf expressions;
		attribute syntacticPredicate[0-1] : String;
		attribute options[*] ordered : String;
	}

    -- @begin Complex Expressions
	class Sequence_ extends Expression {
		reference expression container : Expression oppositeOf sequence;
		attribute lower : Integer;
		attribute upper : Integer;
	}

	class Concatenation extends Expression {
		reference expressions[1-*] ordered container : Expression oppositeOf concatenation;
	}

	class Alternative extends Expression {
		reference expressions[1-*] ordered container : Expression oppositeOf alternative;
	}
    -- @end Complex Expressions

    -- @begin Calls
	class RuleCall extends Expression {
		reference calledRule : ProductionRule;
		reference arguments[*] container : ActionExpression;
	}

	class TokenCall extends Expression {
		attribute name ordered : String;
		attribute storeASTTo[0-1] ordered : String;
	}
    -- @end Calls

	-- @begin Keywords
	class Terminal extends Expression {
		attribute value : String;
	}

-- @begin ForLexer
	class CharTerminal extends Expression {
		attribute value : String;
	}

	class Negation extends Expression {
		reference expression container : Expression;
	}

	class Drop extends Expression {
		reference expression container : Expression;
	}

	class Interval extends Expression {
		reference start container : CharTerminal;
		reference end container : CharTerminal;
	}
-- @end ForLexer

	-- unused
	class LiteralExpression extends Expression {
		attribute value : String;
	}
-- @end Expressions
}

package Actions {

	class Type extends NamedElement {
	}


-- @begin Variables
	class VariableDeclaration extends NamedElement {
		reference variable[*] : Variable oppositeOf declaration;
		attribute type : String;
		attribute initialValue : String;
	}

	class Parameter extends VariableDeclaration {
	}

	class Variable extends ActionExpression {
		reference declaration : VariableDeclaration oppositeOf variable;
	}
-- @end Variables


-- @begin SemanticActions
	abstract class SemanticAction extends LocatedElement {
		reference block[0-1] : SemanticActionBlock oppositeOf actions;
		reference expression : Expression oppositeOf action;
	}

	class SimpleSemanticAction extends SemanticAction {
		attribute value : String;
	}

	class SemanticActionBlock extends SemanticAction {
		reference actions[*] container : SemanticAction oppositeOf block;
	}
-- @end SemanticActions


-- @begin Expressions
	abstract class ActionExpression extends LocatedElement {
		attribute type : String;
	}

	class TextualExpression extends ActionExpression {
		attribute value : String;
	}
-- @end Expressions
}

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