summaryrefslogtreecommitdiffstats
blob: 7c33853140d48ed980342cc427b532983815bed2 (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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
-- @name		TCS
-- @version		1.0
-- @domains		MDE, Grammarware
-- @authors		Frédéric Jouault
-- @date		2007/07/30
-- @description	TCS (Textual Concrete Syntax) is a textual syntax specification language for metamodels.

package TCS {

	abstract class LocatedElement {
		attribute location[0-1] : String;
		attribute commentsBefore[*] ordered : String;
		attribute commentsAfter[*] ordered : String;
	}

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

	class ConcreteSyntax extends NamedElement {
		-- name must be the metamodel's
		attribute k[0-1] : Integer;
		reference templates[*] ordered container : Template oppositeOf concreteSyntax;
		reference keywords[*] ordered container : Keyword;
		reference symbols[*] ordered container : Symbol;
		reference operatorLists[*] ordered container : OperatorList;
		reference tokens[*] ordered container : Token;
		attribute lexer : String;
	}

-- @begin Templates
	abstract class Template extends NamedElement {
		reference concreteSyntax : ConcreteSyntax oppositeOf templates;
		attribute disambiguate[0-1] : String;
		attribute disambiguateV3[0-1] : String;
	}

	class FunctionTemplate extends Template {
		attribute className : String;
		reference functionSequence container : Sequence oppositeOf functionContainer;
	}

	class ClassTemplate extends Template {
		-- name must be the class's
		reference templateSequence[0-1] container : Sequence oppositeOf templateContainer;
		attribute modifiers[*] : TemplateModifiers;

		-- until Enumeration is supported
		attribute isAbstract : Boolean;
		attribute isDeep : Boolean;
		reference prefixSequence container : Sequence oppositeOf prefixContainer;
		attribute isOperatored : Boolean;
		reference operatorList[0-1] : OperatorList;
		reference parentheses[0-1] container : Parentheses;
		attribute isMain : Boolean;
		attribute isMulti : Boolean;	-- can be used in combination with main
		attribute isContext : Boolean;
		attribute isAddToContext : Boolean;
		attribute isNonPrimary : Boolean;
		attribute mode[0-1] : String;
	}
	
	class Parentheses extends LocatedElement {
		attribute isOff : Boolean;
		reference left[0-1] container : Sequence;
		reference right[0-1] container : Sequence;
	}

	enumeration TemplateModifiers {
		literal "abstract";
		literal operatored;
		literal main;
		literal context;
		literal addToContext;
	}

	class PrimitiveTemplate extends Template {
		attribute typeName : String;
		attribute isDefault : Boolean;
		attribute tokenName : String;
		attribute value : String;
		attribute serializer : String;
		attribute orKeyword : Boolean;
	}

	class OperatorTemplate extends Template {
		reference operators[*] : Operator oppositeOf templates;
		attribute source : String;
		attribute storeOpTo[0-1] : String;
		attribute storeRightTo[0-1] : String;
		reference otSequence[0-1] container : Sequence oppositeOf otContainer;
		attribute isContext : Boolean;
	}

	class EnumerationTemplate extends Template {
		-- name must be the enumeration's
		attribute automatic : Boolean;
		reference mappings[*] ordered container : EnumLiteralMapping;
	}

	class EnumLiteralMapping extends LocatedElement {
		reference "literal" container : EnumLiteralVal;
		reference element container : SequenceElement;
	}
-- @end Templates

-- @begin Literals
	abstract class Literal extends NamedElement {
		reference operators[*] : Operator oppositeOf "literal";
		reference literalRefs[*] : LiteralRef oppositeOf "referredLiteral";
		attribute value : String;
	}

	class Symbol extends Literal {
		attribute spaces[*] : SpaceKind;
	}

	enumeration SpaceKind {
		literal leftSpace;
		literal leftNone;
		literal rightSpace;
		literal rightNone;
	}

	class Keyword extends Literal {
	}
-- @end Literals

-- @begin Operators
	class OperatorList extends LocatedElement {
		attribute name[0-1] : String;
		reference priorities[*] ordered container : Priority oppositeOf list;
	}

	class Priority extends LocatedElement {
		reference list : OperatorList oppositeOf priorities;
		attribute value : Integer;
		attribute associativity : Associativity;
		reference operators[*] container : Operator oppositeOf priority;
	}

	class Operator extends NamedElement {
		attribute isPostfix : Boolean;
		attribute arity : Integer;
		reference "literal"[0-1] : Literal oppositeOf operators;
		reference priority : Priority oppositeOf operators;
		reference templates[*] : OperatorTemplate oppositeOf operators;
	}

	enumeration Associativity {
		literal left;
		literal right;
	}
-- @end Operators

	class Sequence extends LocatedElement {
		reference elements[*] ordered container : SequenceElement oppositeOf elementSequence;
		reference templateContainer[0-1] : ClassTemplate oppositeOf templateSequence;
		reference prefixContainer[0-1] : ClassTemplate oppositeOf prefixSequence;
		reference functionContainer[0-1] : FunctionTemplate oppositeOf functionSequence;
		reference blockContainer[0-1] : Block oppositeOf blockSequence;
		reference thenContainer[0-1] : ConditionalElement oppositeOf thenSequence;
		reference elseContainer[0-1] : ConditionalElement oppositeOf elseSequence;
		reference separatorContainer[0-1] : SeparatorPArg oppositeOf separatorSequence;
		reference otContainer[0-1] : OperatorTemplate oppositeOf otSequence;
--		reference keyContainer : Key oppositeOf keySequence;
		reference alternativeContainer[0-1] : Alternative oppositeOf sequences;
	}

-- @begin Sequence Elements
	abstract class SequenceElement extends LocatedElement {
		reference elementSequence : Sequence oppositeOf elements;
	}

	class LiteralRef extends SequenceElement {
		reference referredLiteral : Literal oppositeOf literalRefs;
	}

	class Property extends SequenceElement {
		attribute name : String;
		reference propertyArgs[*] ordered container : PropertyArg oppositeOf property;
	}

	class CustomSeparator extends SequenceElement {
		attribute name : String;
	}

	class Block extends SequenceElement {
		reference blockSequence container : Sequence oppositeOf blockContainer;
		reference blockArgs[*] ordered container : BlockArg oppositeOf block;
	}

	class ConditionalElement extends SequenceElement {
		-- condition must be boolean
		reference condition container : Expression oppositeOf conditionalElement;
		reference thenSequence container : Sequence oppositeOf thenContainer;
		reference elseSequence container : Sequence oppositeOf elseContainer;
	}

	class PropertyInit extends SequenceElement {
		attribute name : String;
		reference value container : Value;
	}

	class Alternative extends SequenceElement {
		reference sequences[2-*] ordered container : Sequence oppositeOf alternativeContainer;
		attribute isMulti : Boolean;
	}

	class FunctionCall extends SequenceElement {
		reference calledFunction : FunctionTemplate;
	}
-- @end Sequence Elements

-- @begin Property Arguments
	abstract class PropertyArg extends LocatedElement {
		reference property : Property oppositeOf propertyArgs;
	}

	class RefersToPArg extends PropertyArg {
		attribute propertyName : String;
	}

	class LookInPArg extends PropertyArg {
		attribute propertyName[1-*] ordered : String;
	}

	class CreateInPArg extends PropertyArg {
		attribute propertyName[1-*] ordered : String;
	}

	class RefersToKeyPArg extends PropertyArg {
		attribute value : Boolean;
	}

	class SeparatorPArg extends PropertyArg {
		reference separatorSequence container : Sequence oppositeOf separatorContainer;
	}

	class AutoCreatePArg extends PropertyArg {
		attribute value : AutoCreateKind;
	}

	class ImportContextPArg extends PropertyArg {

	}

	class ForcedLowerPArg extends PropertyArg {
		attribute value : Integer;
	}

	enumeration AutoCreateKind {
		literal always;
		literal ifmissing;
		literal never;
	}

	class CreateAsPArg extends PropertyArg {
		attribute name : String;
	}

	class AsPArg extends PropertyArg {
		attribute value : String;
	}

	class ModePArg extends PropertyArg {
		attribute mode : String;
	}
-- @end Property Arguments


-- @begin Block Arguments
	abstract class BlockArg extends LocatedElement {
		reference block : Block oppositeOf blockArgs;
	}

	class NbNLBArg extends BlockArg {
		attribute value : Integer;
	}

	class IndentIncrBArg extends BlockArg {
		attribute value : Integer;
	}

	class StartNLBArg extends BlockArg {
		attribute value : Boolean;
	}

	class StartNbNLBArg extends BlockArg {
		attribute value : Integer;
	}

	class EndNLBArg extends BlockArg {
		attribute value : Boolean;
	}
-- @end Block Arguments


-- @begin Expressions
	abstract class Expression extends LocatedElement {
		reference conditionalElement : ConditionalElement oppositeOf condition;
	}

	class AndExp extends Expression {
		reference expressions[*] ordered container : AtomExp oppositeOf andExp;
	}

	abstract class AtomExp extends LocatedElement {
		reference andExp : AndExp oppositeOf expressions;
		attribute propertyName : String;
	}

	class EqualsExp extends AtomExp {
		reference value container : Value;	-- Was an Attribute but Ecore forbids non-EDataType attributes
	}

	class BooleanPropertyExp extends AtomExp {
	}

	class IsDefinedExp extends AtomExp {
	}

	class OneExp extends AtomExp {
	}
-- @end Expressions


-- @begin Values
	abstract class Value extends LocatedElement {

	}

	class StringVal extends Value {
		attribute symbol : String;
	}

	class IntegerVal extends Value {
		attribute symbol : Integer;
	}

	class NegativeIntegerVal extends Value {
		attribute symbol : Integer;
	}

	class EnumLiteralVal extends Value {
		attribute name : String;
	}

	class PropertyVal extends Value {
		attribute propertyName[1-*] : String;
	}
-- @end Values


-- @begin Tokens
	class Token extends NamedElement {
		reference pattern container : OrPattern;
	}

	class OrPattern extends LocatedElement {
		reference simplePatterns[1-*] ordered container : SimplePattern;
	}

-- @begin SimplePatterns
	abstract class SimplePattern extends NamedElement {
	}

	class RulePattern extends SimplePattern {
		reference rule container : Rule;
--		reference arguments[*] ordered container : RuleArgument;
	}

-- @begin Rules
	abstract class Rule extends LocatedElement {
	}

	class WordRule extends Rule {
		reference start container : OrPattern;
		reference part container : OrPattern;
		reference end[0-1] container : OrPattern;
		reference words[*] container : Word;
	}

	class Word extends NamedElement {
		attribute token : String;
	}

	class EndOfLineRule extends Rule {
		reference start container : StringPattern;
		attribute dropStart : Boolean;
	}

	class MultiLineRule extends Rule {
		reference start container : StringPattern;
		attribute dropStart : Boolean;
		reference end container : StringPattern;
		attribute dropEnd : Boolean;
		reference esc[0-1] container : StringPattern;
		reference escMappings[*] container : Mapping;
	}
	
	abstract class Mapping extends LocatedElement {}
	
	class SimpleMapping extends Mapping {
		attribute key : String;
		attribute value : String;
	}
	
	class WildcardMapping extends Mapping {}
	
	class OctalMapping extends Mapping {}

	class HexadecimalMapping extends Mapping {}
-- @end Rules

--	class RuleArgument extends NamedElement {
--		reference value container : OrPattern;
--	}

	class StringPattern extends SimplePattern {
	}

	class ClassPattern extends SimplePattern {
	}
-- @end SimplePatterns
-- @end Tokens


-- @begin Obsolete Items
--	class Key extends NamedElement {
--		-- name must be the class's
--		reference keySequence container : Sequence oppositeOf keyContainer;
--	}
--	class FunctionCall extends SequenceElement {		-- unused
--		reference function : Function;
--		reference arguments[*] ordered container : Argument;
--	}
-- @end Obsolete Items

}

package PrimitiveTypes {

	datatype Boolean;
	datatype Integer;
	datatype String;

}