6 Commits

Author SHA1 Message Date
Lucas
729f4f23d6 Update Makefile
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
2024-07-04 15:02:01 +02:00
Lucas
a1a9cce511 CompilerInput.java now valid
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
2024-07-04 14:59:27 +02:00
Lucas
f7a4e65093 E2E Running
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Other tests and make refactored
2024-07-04 14:35:02 +02:00
Lucas
2934872457 SemanticTest recovered
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
InputFiles from Test excluded
MainTest working properly
Make and POM updated
2024-07-04 10:37:56 +02:00
Lucas
1c327705d8 Merge branch 'Endabgabe' into Tests
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
2024-07-04 09:40:05 +02:00
Lucas
49195c754c small changes
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
2024-07-03 17:43:09 +02:00
8 changed files with 37 additions and 56 deletions

View File

@@ -43,10 +43,21 @@ src/
└── resources/ └── resources/
test/ test/
└── java/ └── java/
│ ├── main/ -> MainTest, E2ETests, UtilityTests │ ├── main/
│ ├── parser/ -> Performs tests on the parser │ ├── parser/ -> Performs tests on the parser
│ └── semantic/ -> Performs tests on the semantic check │ └── semantic/
└── resources/ -> Ressources for running the Tests └── resources/ -> Ressources for running the Tests
├──input
│ ├── combinedFeatureTests
│ ├── endabgabeTests
│ ├── failureTests
│ ├── singleFeatureSemanticTests
│ ├── singleFeatureTests
│ ├── typedAstExceptionsTests
│ └── typedAstFeatureTests
└──output
├── javac
└── raupenpiler
``` ```
## Class-Diagramm AST ## Class-Diagramm AST
@@ -62,7 +73,5 @@ test/
## How to run the compiler ## How to run the compiler
## Download ## Download
```bash ```bash

View File

@@ -253,7 +253,6 @@ public class SemanticAnalyzer implements SemanticVisitor {
if (toCheck.memberAccess != null) { if (toCheck.memberAccess != null) {
var result = toCheck.memberAccess.accept(this); var result = toCheck.memberAccess.accept(this);
toCheck.identifier = toCheck.memberAccess.identifiers.getLast();
toCheck.setTypeNode(result.getType()); toCheck.setTypeNode(result.getType());
return result; return result;
} else { } else {
@@ -317,13 +316,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
@Override @Override
public TypeCheckResult analyze(IfElseNode toCheck) { public TypeCheckResult analyze(IfElseNode toCheck) {
var resultIf = toCheck.ifStatement.accept(this); var resultIf = toCheck.ifStatement.accept(this);
if(toCheck.elseStatement != null){ var resultElse = toCheck.elseStatement.accept(this);
var resultElse = toCheck.elseStatement.accept(this);
return new TypeCheckResult(resultIf.isValid() && resultElse.isValid(), new BaseType(TypeEnum.VOID));
}
return new TypeCheckResult(resultIf.isValid() && resultElse.isValid(), new BaseType(TypeEnum.VOID));
return new TypeCheckResult(resultIf.isValid(), new BaseType(TypeEnum.VOID));
} }
@Override @Override
@@ -609,15 +604,11 @@ public class SemanticAnalyzer implements SemanticVisitor {
ITypeNode currentType = null; ITypeNode currentType = null;
int start = 0; int start = 0;
if(!memberAccessNode.identifiers.isEmpty()){ if(!memberAccessNode.identifiers.isEmpty()){
if(currentFields.get(memberAccessNode.identifiers.getFirst()) != null){ if(currentFields.get(memberAccessNode.identifiers.get(0)) != null){
memberAccessNode.identifiers.addFirst(currentClass.identifier); memberAccessNode.identifiers.add(0, currentClass.identifier);
start++; start = 1;
} }
} }
if(context.getClasses().get(memberAccessNode.identifiers.getFirst()) == null){
memberAccessNode.identifiers.addFirst(currentClass.identifier);
start++;
}
for (int i = start; i < memberAccessNode.identifiers.size(); i++) { for (int i = start; i < memberAccessNode.identifiers.size(); i++) {
String s = memberAccessNode.identifiers.get(i); String s = memberAccessNode.identifiers.get(i);
@@ -635,8 +626,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
} else { } else {
if (currentType instanceof ReferenceType reference) { if (currentType instanceof ReferenceType reference) {
var currentTypeClass = context.getClass(reference.getIdentifier()); var currentTypeClass = context.getClass(reference.getIdentifier());
memberAccessNode.identifiers.add(i, reference.getIdentifier());
i++;
var currentField = currentTypeClass.getField(s); var currentField = currentTypeClass.getField(s);
if (currentField.getAccessModifier().accessType == EnumAccessModifierNode.PUBLIC) { if (currentField.getAccessModifier().accessType == EnumAccessModifierNode.PUBLIC) {
currentType = currentField.getType(); currentType = currentField.getType();

View File

@@ -12,6 +12,12 @@ compile-raupenpiler:
cd ../.. ; mvn exec:java -DgenJar=true -DgenClass=true -Dexec.mainClass="main.Main" -Dexec.args="'src/main/resources/input/CompilerInput.java' 'src/main/resources/output'" cd ../.. ; mvn exec:java -DgenJar=true -DgenClass=true -Dexec.mainClass="main.Main" -Dexec.args="'src/main/resources/input/CompilerInput.java' 'src/main/resources/output'"
# cp ../main/resources/output/CompilerInput.class .java/resources/output/raupenpiler # cp ../main/resources/output/CompilerInput.class .java/resources/output/raupenpiler
test: compile-javac compile-raupenpiler test-javac test-raupenpiler
test-javac:
# gleich wie bei raupenpiler, kann ich ohne funktionierenden Compiler nicht testen
test-raupenpiler: test-raupenpiler:
# move the compiled class to the test/main folder # move the compiled class to the test/main folder
mv ../main/resources/output/CompilerInput.class .java/main/ mv ../main/resources/output/CompilerInput.class .java/main/

View File

@@ -88,7 +88,7 @@ public class E2EReflectionsTest {
for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) {
if (field.getName().equals(raupenpilerField.getName())) { if (field.getName().equals(raupenpilerField.getName())) {
assertEquals(field.getType(), raupenpilerField.getType()); assertEquals(field.getType(), raupenpilerField.getType());
// assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); // assertEquals(field.getModifiers(), raupenpilerField.getModifiers());
} }
} }
} }

View File

@@ -338,17 +338,6 @@ public class EndToTypedAstTest {
} }
@Test
public void Expression(){
ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/Expression.java");
SemanticAnalyzer.generateTast(tast);
assertTrue(SemanticAnalyzer.errors.isEmpty());
}
// ------------------ Helpers ------------------ // ------------------ Helpers ------------------
/** /**

View File

@@ -1,10 +0,0 @@
class VariableCompare{
void trueMethod(boolean a, int c) {
if(a && c == 10){
}
}
}

View File

@@ -1,16 +1,13 @@
public class Compiler { public class Klasse1 {
Node node; public int test;
public int add(int i, int j) {
node = new Node();
node.x = 1;
return i+j;
}
}
public class Node { public int test1() {
public int x; test = 5;
public void main() { return 1;
Compiler compiler = new Compiler(); }
int i = compiler.add(5, 8);
public void test2() {
int testInt;
testInt = this.test1();
} }
} }