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

View File

@@ -253,7 +253,6 @@ public class SemanticAnalyzer implements SemanticVisitor {
if (toCheck.memberAccess != null) {
var result = toCheck.memberAccess.accept(this);
toCheck.identifier = toCheck.memberAccess.identifiers.getLast();
toCheck.setTypeNode(result.getType());
return result;
} else {
@@ -317,15 +316,11 @@ public class SemanticAnalyzer implements SemanticVisitor {
@Override
public TypeCheckResult analyze(IfElseNode toCheck) {
var resultIf = toCheck.ifStatement.accept(this);
if(toCheck.elseStatement != null){
var resultElse = toCheck.elseStatement.accept(this);
return new TypeCheckResult(resultIf.isValid() && resultElse.isValid(), new BaseType(TypeEnum.VOID));
}
return new TypeCheckResult(resultIf.isValid(), new BaseType(TypeEnum.VOID));
}
@Override
public TypeCheckResult analyze(MethodCallNode toCheck) {
@@ -609,15 +604,11 @@ public class SemanticAnalyzer implements SemanticVisitor {
ITypeNode currentType = null;
int start = 0;
if(!memberAccessNode.identifiers.isEmpty()){
if(currentFields.get(memberAccessNode.identifiers.getFirst()) != null){
memberAccessNode.identifiers.addFirst(currentClass.identifier);
start++;
if(currentFields.get(memberAccessNode.identifiers.get(0)) != null){
memberAccessNode.identifiers.add(0, currentClass.identifier);
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++) {
String s = memberAccessNode.identifiers.get(i);
@@ -635,8 +626,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
} else {
if (currentType instanceof ReferenceType reference) {
var currentTypeClass = context.getClass(reference.getIdentifier());
memberAccessNode.identifiers.add(i, reference.getIdentifier());
i++;
var currentField = currentTypeClass.getField(s);
if (currentField.getAccessModifier().accessType == EnumAccessModifierNode.PUBLIC) {
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'"
# 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:
# move the compiled class to the test/main folder
mv ../main/resources/output/CompilerInput.class .java/main/

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 ------------------
/**

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 {
Node node;
public int add(int i, int j) {
node = new Node();
node.x = 1;
return i+j;
}
}
public class Klasse1 {
public int test;
public class Node {
public int x;
public void main() {
Compiler compiler = new Compiler();
int i = compiler.add(5, 8);
public int test1() {
test = 5;
return 1;
}
public void test2() {
int testInt;
testInt = this.test1();
}
}