Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
c76916e
remove old DeSer skeletons
jra-se Jul 14, 2025
de940a8
add class2mc and testFixture dependencies
jra-se Jul 14, 2025
faae84e
add TypeCheck3 initialization
jra-se Jul 18, 2025
acf065f
set artifact name
jra-se Jul 21, 2025
b4a92da
add default import for java.lang
jra-se Jul 21, 2025
e979fb7
TypeDeclaration symbol cleanup
jra-se Jul 21, 2025
835018d
make EnumConstantDeclaration a Field
jra-se Jul 21, 2025
fe52d03
add more scopes
jra-se Jul 22, 2025
09926f8
fix overridden printWithoutTypeArguments
jra-se Jul 22, 2025
bf7e62f
add class2mc, pretty print and extended symbol table export options t…
jra-se Jul 22, 2025
30e84c9
add typevisitors for overridden productions
jra-se Jul 22, 2025
802b8ed
Merge branch 'refs/heads/dev' into symbol-table
jra-se Jul 22, 2025
17241c0
fixed scope definitions
jra-se Jul 25, 2025
4bdec3c
add more type visitors
jra-se Jul 25, 2025
19584ef
add imports to the artifact scope
jra-se Jul 25, 2025
9934475
add JavaDSLSymbolTableCompleter
jra-se Jul 25, 2025
a8f5ec9
add JavaDSLSymbolTableUtil
jra-se Jul 25, 2025
46df2f3
add JavaDSLSymbolTableTest
jra-se Jul 25, 2025
15da6e2
JavaDSLTool path option now required multiple usages instead of pathS…
jra-se Aug 4, 2025
a3bc112
fix JavaDSLToolTest
jra-se Aug 4, 2025
110577f
add unnamed default package if needed
jra-se Aug 6, 2025
a7f79dd
set EnumConstant in the FieldSymbol of EnumConstantDeclarations
jra-se Aug 12, 2025
36768fb
add gradle task for tool compilation
jra-se Aug 20, 2025
c71cb69
fix pretty printing option in the JavaDSLTool
jra-se Aug 20, 2025
0e493fc
allow EmptyStatement usage in the class body
jra-se Aug 20, 2025
291527d
remove transitive keyword as it is a contextual keyword
jra-se Aug 20, 2025
c74c4ae
create symbol table only when needed
jra-se Aug 20, 2025
d9dc7e3
print feedback about parsed and unparsable files
jra-se Aug 20, 2025
33633b3
add missing ASTConstructorDeclaration type
jra-se Aug 21, 2025
8aeeffa
fix symbol table building in the JavaDSLTool
jra-se Aug 21, 2025
15e3aa1
add nokeyword for record, as it is a contextual keyword
jra-se Aug 25, 2025
0a83a1e
temporary rollback of nokeyword record
jra-se Aug 25, 2025
fb6e008
fix anonymous class creators
jra-se Aug 25, 2025
3a42589
use OOClass2MCResolver
jra-se Aug 25, 2025
335c5e5
Merge branch 'dev' into symbol-table
jra-se Aug 26, 2025
3a2f15a
fix error codes
jra-se Aug 26, 2025
f45d28f
add adapted symtab completer for LocalVariableDeclaration with var su…
jra-se Aug 26, 2025
82f9da7
more unique error codes
jra-se Aug 26, 2025
08310bc
set constructor type within EnumDeclaration
jra-se Aug 28, 2025
63e042c
add cocos for LocalVariableDeclarations using var
jra-se Aug 28, 2025
1e6b440
override calculation of qualified names in IJavaDSLArtifactScope to s…
jra-se Sep 2, 2025
f630203
override endVisit for inherited LocalVariableDeclarations to prevent …
jra-se Sep 2, 2025
dd84d04
add overridden MCBasicTypesTypeVisitor to resolve non-static (inner) …
jra-se Sep 3, 2025
3b8ced4
remove custom java productions in favour of imported library productions
jra-se Sep 9, 2025
e1d7b0c
reintroduce missing InnerCreatorExpression
jra-se Sep 9, 2025
dd515e4
set basic type symbol properties in the genitor instead of symtab com…
jra-se Sep 9, 2025
d275d81
rework SymTab completion for `var` types and add a third genitor phase
jra-se Sep 9, 2025
e1be1b4
moved SymTabCompletion to ScopesGenitorP2
jra-se Sep 9, 2025
c6144d8
Merge branch 'refs/heads/dev' into symbol-table
jra-se Nov 10, 2025
6c971df
Merge branch 'refs/heads/dev' into symbol-table
jra-se Dec 1, 2025
40ed38b
log SymbolTable phases
jra-se Dec 1, 2025
f0e1610
reintroduce record nokeyword
jra-se Dec 1, 2025
4eb6866
allow additional colons after TypeDeclaration blocks
jra-se Dec 1, 2025
5ea4067
log SymbolTableConstruction timings
jra-se Dec 1, 2025
2495c71
log instead of System.out.printf
jra-se Dec 1, 2025
4dae5b4
add support for additional colons after TypeDeclarations with correct…
jra-se Dec 1, 2025
72fd228
add support for try-with-resources with external resources
jra-se Dec 1, 2025
78a139e
fix prettyprinter
jra-se Dec 1, 2025
a15243c
fix prettyprinter
jra-se Dec 1, 2025
df92231
temporary removal of record-nokeyword
jra-se Dec 2, 2025
5118e21
added MCStructuralTypes to support intersection types
jra-se Dec 4, 2025
f96a165
increase java thread stack
jra-se Dec 4, 2025
09c9824
added JavaDSLOOWithinTypeBasicSymbolsResolver
jra-se Dec 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id "de.monticore.generator" version "$mc_version" apply false
id "com.github.johnrengelman.shadow" version "$shadow_plugin_version" apply false
}

allprojects {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ useLocalRepo=false

org.gradle.caching=true
org.gradle.welcome=never
org.gradle.jvmargs=-Xms3072m -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xms3072m -Xss16m -Dfile.encoding=UTF-8

version=7.9.0-SNAPSHOT

Expand Down
19 changes: 19 additions & 0 deletions javaDSL/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

apply plugin:"com.github.johnrengelman.shadow"

description = "MontiCore: Java DSL"

def grammarsDir = "src/main/grammars"
Expand Down Expand Up @@ -47,11 +51,26 @@ tasks.withType(Test).configureEach {
dependsOn(extractCorpus)
}

tasks.register('buildJavaDSLTool', ShadowJar) {
minimize()
group = 'mc'
archiveFileName = 'MCJavaDSL.jar'
archiveClassifier = 'javadsl-mc-tool'
manifest {
attributes('Main-Class':'de.monticore.java.JavaDSLTool')
}
from sourceSets.main.output
configurations = [project.configurations.runtimeClasspath]
}
jar.dependsOn(buildJavaDSLTool)

dependencies {
implementation "de.monticore.lang:cd4analysis:$mc_version"
implementation "de.monticore:class2mc:$mc_version"

grammar "de.monticore:monticore-grammar:$mc_version"

testImplementation testFixtures("de.monticore:monticore-grammar:$mc_version")
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
Expand Down
144 changes: 81 additions & 63 deletions javaDSL/src/main/grammars/de/monticore/java/JavaDSL.mc4
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ package de.monticore.java;
* |-> de.monticore.types.MCBasicTypes (*)
* |-> de.monticore.types.MCFullGenericTypes (*)
* |-> de.monticore.types.TypeParameters (*)
* |-> de.monticore.types.MCStructuralTypes
*
* (*) Repeated Dependencies are omitted.
*/
Expand All @@ -83,7 +84,8 @@ grammar JavaDSL extends
de.monticore.statements.MCFullJavaStatements,
de.monticore.types.MCArrayTypes,
de.monticore.types.MCFullGenericTypes,
de.monticore.types.TypeParameters {
de.monticore.types.TypeParameters,
de.monticore.types.MCStructuralTypes {

start CompilationUnit;

Expand Down Expand Up @@ -122,10 +124,11 @@ RequiresDirective implements ModuleDirective
= "requires" RequiresModifier? MCQualifiedName ";"
;

enum RequiresModifier
= "static"
| "transitive"
;

interface RequiresModifier;

StaticModifier implements RequiresModifier = ["static"];
TransitiveModifier implements RequiresModifier = ["transitive"];

ExportsDirective implements ModuleDirective
= "exports" MCQualifiedName ("to" toModules:(MCQualifiedName || ",")+)? ";"
Expand All @@ -152,25 +155,25 @@ nokeyword "uses";
nokeyword "provides";
nokeyword "with";
nokeyword "to";
nokeyword "transitive";

// Type declarations
abstract symbol scope TypeDeclaration implements ClassMemberDeclaration, InterfaceMemberDeclaration, AnnotationTypeElementDeclaration, MCBlockStatement, OOType = Name ;
// TODO: Remove Java-specific Interfaces, reuse component grammars and use CoCos for validation?
abstract symbol scope(shadowing) TypeDeclaration implements ClassMemberDeclaration, InterfaceMemberDeclaration, AnnotationTypeElementDeclaration, MCBlockStatement, OOType = Name ;

symbolrule TypeDeclaration =
isAnnotation: boolean ;
isAnnotation: boolean
isRecord: boolean;

symbol scope ClassDeclaration extends TypeDeclaration
// TODO: Remove scope duplicate when monticore#4726 is fixed
scope(shadowing) ClassDeclaration extends TypeDeclaration
= JavaModifier* "class" Name TypeParameters?
("extends" superClass:MCType)?
("implements" implementedInterface:(MCType || ",")+)?
ClassBody
ClassBody ";"*
;

symbolrule ClassDeclaration =
superInterface:MCType*
constructor: de.monticore.javalight._symboltable.JavaMethodSymbol*
methods: de.monticore.javalight._symboltable.JavaMethodSymbol* ;

// TODO Replace with MCJavaBlock? -> with CoCos?
ClassBody
= "{" ClassBodyDeclaration* "}"
;
Expand All @@ -181,12 +184,17 @@ ClassBody
* https://docs.oracle.com/javase/specs/jls/se19/html/jls-8.html#jls-8.10
*/

symbol scope RecordDeclaration extends TypeDeclaration
// TODO: Remove scope duplicate when monticore#4726 is fixed
scope(shadowing) RecordDeclaration extends TypeDeclaration
= JavaModifier* "record" Name TypeParameters? RecordHeader
("implements" implementedInterface:(MCType || ",")+)?
RecordBody
RecordBody ";"*
;

// TODO: "record" is a contextual keyword, but setting it to nokeyword creates conflicts with MethodDeclaration
// -> might need to be fixed in MontiCore itself
//nokeyword "record";

RecordHeader
= "(" (RecordComponent || ",")* ")"
;
Expand All @@ -200,6 +208,7 @@ astrule RecordComponent =
return this.isPresentVariableArity();
};

// TODO Replace with MCJavaBlock? -> with CoCos?
RecordBody
= "{" (ClassBodyDeclaration | CompactConstructorDeclaration)* "}"
;
Expand All @@ -208,27 +217,27 @@ CompactConstructorDeclaration
= JavaModifier* Name body:MCJavaBlock
;

symbol scope InterfaceDeclaration extends TypeDeclaration
// TODO: Remove scope duplicate when monticore#4726 is fixed
scope(shadowing) InterfaceDeclaration extends TypeDeclaration
= JavaModifier* "interface" Name TypeParameters?
("extends" extendedInterface:(MCType || ",")+)?
InterfaceBody
InterfaceBody ";"*
;

// TODO Replace with MCJavaBlock? -> with CoCos?
InterfaceBody
= "{" InterfaceBodyDeclaration* "}"
;

symbol scope EnumDeclaration extends TypeDeclaration
// TODO: Remove scope duplicate when monticore#4726 is fixed
scope(shadowing) EnumDeclaration extends TypeDeclaration
= JavaModifier* "enum" Name
("implements" implementedInterface:(MCType || ",")+)?
"{" (EnumConstantDeclaration || ",")* ","? EnumBody? "}"
"{" (EnumConstantDeclaration || ",")* ","? EnumBody? "}" ";"*
;

symbolrule EnumDeclaration =
constructor: de.monticore.javalight._symboltable.JavaMethodSymbol*
methods: de.monticore.javalight._symboltable.JavaMethodSymbol*;

symbol EnumConstantDeclaration
// TODO: Remove scope duplicate when monticore#4726 is fixed
scope(shadowing) symbol EnumConstantDeclaration implements Field
= Annotation* Name Arguments? ClassBody?
;

Expand All @@ -237,9 +246,12 @@ EnumBody
;

ClassBlock implements ClassBodyDeclaration
= (["static"])? JavaBlock
= (["static"])? MCJavaBlock
;

@Override
EmptyStatement implements ClassBodyDeclaration;

interface ClassMemberDeclaration extends ClassBodyDeclaration ;

interface MethodBody ;
Expand All @@ -266,21 +278,25 @@ ArrayInitializer implements VariableInitializer
;

// ANNOTATIONS

symbol scope AnnotationTypeDeclaration extends TypeDeclaration
// TODO: Remove scope duplicate when monticore#4726 is fixed
scope(shadowing) AnnotationTypeDeclaration extends TypeDeclaration
= JavaModifier* "@" "interface" Name AnnotationTypeBody
;

// TODO Replace with MCJavaBlock? -> with CoCos? | Replace with { InterfaceBodyDeclaration }
AnnotationTypeBody
= "{" (AnnotationTypeElementDeclaration)* "}"
;

interface AnnotationTypeElementDeclaration ;

symbol scope AnnotationMethod implements AnnotationTypeElementDeclaration
// TODO Replace with MethodDeclaration?
// TODO: Remove scope duplicate when monticore#4726 is fixed
scope(shadowing non_exporting ordered) AnnotationMethod implements AnnotationTypeElementDeclaration, JavaMethod
= JavaModifier* MCType Name "(" ")" DefaultValue? ";"
;

// TODO Replace with ConstDeclaration?
AnnotationConstant implements AnnotationTypeElementDeclaration
= JavaModifier* MCType (VariableDeclarator || ",")+ ";"
;
Expand Down Expand Up @@ -309,40 +325,25 @@ MCBasicGenericType implements MCGenericType <20>
= (AnnotatedName || ".")+ "<" (MCTypeArgument || ",")* ">"
;

astrule MCBasicGenericType =
method public String printWithoutTypeArguments() {
java.util.List<String> names = new ArrayList<>();
for(ASTAnnotatedName annotatedName : getAnnotatedNameList()) {
names.add(annotatedName.getName());
}
return String.join(".", names);
};

@Override
MCQualifiedType implements MCObjectType
= (AnnotatedName || ".")+
;

// STATEMENTS / BLOCKS

interface Statement extends MCBlockStatement ;

scope JavaBlock implements Statement, MethodBody, ConstructorBody, FinallyBlock
= "{" MCBlockStatement* "}"
;

scope TryStatement implements Statement
= "try" JavaBlock ExceptionHandler
;

interface ExceptionHandler ;

CatchExceptionsHandler implements ExceptionHandler
= CatchClause+ ("finally" FinallyBlock)?
;

FinallyBlockOnlyHandler implements ExceptionHandler
= ("finally" FinallyBlock)
;

TryStatementWithResources implements Statement
= "try" "(" (Resource || ";")+ ";"? ")" JavaBlock CatchClause* ("finally" FinallyBlock)?
;

Resource
= JavaModifier* MCType DeclaratorId "=" Expression
;
// TODO: Remove scope duplicate when monticore#4726 is fixed
@Override
scope(shadowing) MCJavaBlock implements MethodBody, ConstructorBody;

IdentifierAndTypeArgument
= Name TypeArguments?
Expand All @@ -352,17 +353,16 @@ TypeArguments
= "<" (MCTypeArgument || ",")* ">"
;

interface FinallyBlock ;

LabeledStatement implements Statement
= label:Name ":" Statement
;

CreatedName
= (IdentifierAndTypeArgument || ".")+
| MCPrimitiveType
;

// TODO: might need some attention...can we do that better?
InnerCreatorExpression implements Expression <275>
= Expression "." "new" InnerCreator
;

InnerCreator
= firstTypeArguments:TypeArguments? Name secondTypeArguments:TypeArguments? ClassCreatorRest
;
Expand All @@ -379,6 +379,24 @@ LocalVariableDeclaration
@Override
LambdaParameter implements Variable = (["var"] | MCType)? Name;

@Override
TryLocalVariableDeclaration
= JavaModifier* (["var"] | MCType) DeclaratorId "=" Expression ;

// Add support for try-with-resources with external resources
TryStatement4 implements MCStatement
= "try" "(" resource:Field ")"
core:MCJavaBlock
CatchClause*
("finally" finally:MCJavaBlock)? ;

@Override
EnhancedForControl implements ForControl
= EnhancedForControlFormalParameter ":" Expression;

EnhancedForControlFormalParameter
= JavaModifier* (["var"] | MCType) Declarator;

nokeyword "var";

/*
Expand All @@ -395,7 +413,7 @@ JavaAnnotation extends JavaModifier implements ElementValue
( "(" AnnotationArguments? ")" )?
;

AnonymousClass implements Creator
scope(shadowing) AnonymousClass extends ClassCreator implements Creator
= MCType Arguments ClassBody?
;

Expand Down
Loading