-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathMCFullGenericTypes.mc4
More file actions
57 lines (46 loc) · 1.88 KB
/
Copy pathMCFullGenericTypes.mc4
File metadata and controls
57 lines (46 loc) · 1.88 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
/* (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 completes the type definitions to
* support the full Java type system including wildcards Blubb<? extends A>
*
* A general advice: When you are not sure that you need this kind of
* types, then use a simpler version.
* Type checking ist tricky.
*
* 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 MCFullGenericTypes
extends MCSimpleGenericTypes {
/*=================================================================*/
/** ASTWildcardTypeArgument represents a wildcard type in a type argument
* (generics). It also contains either an upper- or a lower bound.
*
* @attribute upperBound Supertye of the type argument
* @attribute lowerBound Subtype of the type argument
*/
MCWildcardTypeArgument implements MCTypeArgument =
"?" ( ("extends" upperBound:MCType)
| ("super" lowerBound:MCType) )?;
/*=================================================================*/
/** ASTMCMultipleGenericType
* is only used for parsing, if referenced Type is
* generic AND has generic inner classes e.g.
* monticore.Generic1<TypeParam1>.GenericInnerClass<TypeParam2>
*/
MCMultipleGenericType implements MCGenericType, MCType =
MCBasicGenericType // complex Outer Type qualification
"." (MCInnerType || ".")+ ;
// At this point it is not unique whether a type name is used or defined:
// this left open to the embedding nonterminal
MCInnerType = Name ("<" (MCTypeArgument || ",")+ ">")?;
}