Repository navigation
Expand file tree
/
Copy pathMCCollectionTypes.mc4
More file actions
80 lines (60 loc) · 2.37 KB
/
Copy pathMCCollectionTypes.mc4
File metadata and controls
80 lines (60 loc) · 2.37 KB
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
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.types;
/* This is a MontiCore stable grammar.
* Adaptations -- if any -- are conservative. */
import de.monticore.types.*;
/**
* This grammar defines four generics: List<>, Map<,>, Set<>
* and Optional<> on top of basic types.
*
* These four generics correspond to a typical predefined set of generic
* types for example used in connection with UML class diagrams or the
* OCL.
* UML associations typically have those association multiplicities and
* therefore these types are of interest.
*
* This eases the reuse of type structures in languages similar to Java,
* that are somewhat simplified, e.g. without general generics.
*
* This grammar is part of a hierarchy of types, namely
* * types.MCBasicTypes.mc4
* * types/MCArrayTypes.mc4
* * types/MCCollectionTypes.mc4
* * types/MCSimpleGenericTypes.mc4
* * types/MCFullGenericTypes.mc4
*
*/
component grammar MCCollectionTypes
extends MCBasicTypes {
/*=================================================================*/
/**
* MCGenericType covers the following four forms of generics.
* E.g. in visitors it can also be used to restrict to these
* forms of generics even if further generics would be available.
*/
interface MCGenericType extends MCObjectType;
/*=================================================================*/
/* The following definitions use the next-Command and thus
* avoid "List" etc. to become keywords
*/
MCListType implements MCGenericType <200> =
key("List") "<" MCTypeArgument ">";
MCOptionalType implements MCGenericType <200> =
key("Optional") "<" MCTypeArgument ">";
MCMapType implements MCGenericType <200> =
key("Map") "<" key:MCTypeArgument "," value:MCTypeArgument ">";
MCSetType implements MCGenericType <200> =
key("Set") "<" MCTypeArgument ">";
/*=================================================================*/
/**
* ASTMCTypeArgument interface describes arguments of generic types.
* Eg. such as qualified or primitive types.
*
* This is also an extension point for more general type arguments.
*/
interface MCTypeArgument;
MCBasicTypeArgument implements MCTypeArgument <200> =
MCQualifiedType;
MCPrimitiveTypeArgument implements MCTypeArgument <190> =
MCPrimitiveType;
}