-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathMCBasicTypes.mc4
More file actions
105 lines (83 loc) · 3.42 KB
/
Copy pathMCBasicTypes.mc4
File metadata and controls
105 lines (83 loc) · 3.42 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
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
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.types;
/* This is a MontiCore stable grammar.
* Adaptations -- if any -- are conservative. */
import de.monticore.*;
/**
* This grammar defines basic types.
*
* This eases the reuse of type structures in languages similar to Java,
* that are somewhat simplified, e.g. without generics.
*
* The grammar contains types from Java, e.g., primitives, void,
* classes (also sometimes called "reference types").
*
* 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 MCBasicTypes extends de.monticore.MCBasics {
/*=================================================================*/
/** ASTMCType is the top level interface for all kinds of types
* (except Void).
* It is also an extension point for other forms of types.
*/
interface MCType;
/*=================================================================*/
/** The ASTMCQualifiedName represents a possibly qualified name.
The different parts of a qualified name are separated by '.'; they are
stored in an ASTStringList.
@attribute parts A List of ASTStringList concludes all name parts
*/
MCQualifiedName =
parts:(Name || ".")+;
/*=================================================================*/
/** ASTMCPackageDeclaration represents a package declaration usable
for diagrams
E.g.: package A.b;
*/
MCPackageDeclaration = "package" MCQualifiedName& ";";
/** ASTMCImportStatement represents the import list for diagrams
E.g.: import A.b;
E.g.: import A.*;
*/
MCImportStatement =
"import" MCQualifiedName ("." Star:["*"])? ";" ;
/*=================================================================*/
/*= Primitives ====================================================*/
/** ASTMCPrimitiveType represents every primitive type supported by Java.
The type is not realized by an enumeration, because this form
of definitions can be conservatively extended.
@attribute primitive BOOLEAN, BYTE, CHAR, SHORT, INT, FLOAT, LONG,
or DOUBLE
*/
MCPrimitiveType implements MCType =
primitive: [ "boolean" | "byte" | "short" | "int"
| "long" | "char" |"float" | "double" ];
/*=================================================================*/
/*=========== Types (Classes, Interfaces in OO) ===================*/
/** ASTMCObjectType contains names of freely defined types (which in
* Java are mainly classes, interfaces, enums).
* They may be qualified by package names.
*
* This is also an extension point for generic types.
*/
interface MCObjectType extends MCType;
/** ASTMCQualifiedType represents types like class or interface types
which could have a qualified name like this: a.b.c.D
*/
MCQualifiedType implements MCObjectType = MCQualifiedName;
/*=================================================================*/
/*= ReturnTypes and void ==========================================*/
/* These special types do not implement interface ASTMCType, because
they will not appear in the type calculations etc.
*/
MCReturnType = MCVoidType | MCType;
/** ASTVoidType represents the return type "void".
*/
MCVoidType = "void";
}