Repository navigation
Expand file tree
/
Copy pathJavaLight.mc4
More file actions
106 lines (78 loc) · 3.17 KB
/
Copy pathJavaLight.mc4
File metadata and controls
106 lines (78 loc) · 3.17 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;
/* This is a MontiCore stable grammar.
* Adaptations -- if any -- are conservative. */
import de.monticore.statements.*;
import de.monticore.expressions.*;
import de.monticore.literals.*;
import de.monticore.symbols.*;
import de.monticore.types.*;
/**
* The JavaLight language defines a subset of the Java
* programming language. The language introduces Java
* method declarations, constructor declarations,
* interface method declarations, attributes, and
* annotations. The JavaLight language neither defines
* classes nor interfaces. However, it is easily reusable
* and extensible for the creation of more complex
* languages such as the complete Java programming language.
* For example, the JavaLight language is used in the
* MontiCore grammar language for specifying ast rules and
* symbol rules.
*/
component grammar JavaLight extends AssignmentExpressions,
JavaClassExpressions,
MCCommonLiterals,
MCCommonStatements,
MCArrayStatements,
MCReturnStatements,
TypeParameters {
interface ClassBodyDeclaration;
interface InterfaceBodyDeclaration;
interface scope (shadowing non_exporting ordered)
symbol JavaMethod extends Method = Name;
symbolrule JavaMethod =
exceptions: de.monticore.types.check.SymTypeExpression*
annotations: de.monticore.types.check.SymTypeExpression*
isSynchronized: boolean
isNative:boolean
isStrictfp: boolean
isDefault: boolean;
MethodDeclaration implements JavaMethod, ClassBodyDeclaration, InterfaceBodyDeclaration
= MCModifier* TypeParameters?
MCReturnType Name FormalParameters (dim:"[" "]")*
("throws" Throws)? (MCJavaBlock | ";");
ConstructorDeclaration implements JavaMethod, ClassBodyDeclaration
= MCModifier* TypeParameters? Name FormalParameters
("throws" Throws)? MCJavaBlock;
ConstDeclaration extends LocalVariableDeclarationStatement
implements ClassBodyDeclaration,
InterfaceBodyDeclaration
= LocalVariableDeclaration ";";
Throws
= (MCQualifiedName || ",")+;
LastFormalParameter
= MCModifier* MCType "..." DeclaratorId;
FormalParameterListing
= (FormalParameter || ",")+ ("," LastFormalParameter)?
| LastFormalParameter;
FormalParameters
= "(" FormalParameterListing? ")";
// ANNOTATIONS
Annotation implements MCModifier, ElementValue
= "@" annotationName:MCQualifiedName
( "(" AnnotationArguments? ")" )?;
interface AnnotationArguments ;
AnnotationPairArguments implements AnnotationArguments
= (ElementValuePair || ",")+;
interface ElementValue;
ElementValueOrExpr implements AnnotationArguments
= ElementValue | Expression;
ElementValuePair
= Name "=" ElementValueOrExpr;
ElementValueArrayInitializer implements ElementValue
= "{" (ElementValueOrExpr || ",")* (",")? "}";
// ARRAY-Creator
ArrayDimensionByInitializer implements ArrayDimensionSpecifier
= (dim:"[" "]")+ ArrayInit;
}