Oder Documentation and Delete unnecessary
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled

This commit is contained in:
Lucas 2024-07-08 13:20:41 +02:00
parent 9760e39a29
commit 30bd5a0b5c
14 changed files with 817 additions and 204 deletions

2
.gitignore vendored
View File

@ -78,7 +78,7 @@ fabric.properties
/target /target
src/main/resources/logs/miniCompilerLog.log src/main/resources/logs/miniCompilerLog.log
src/main/resources/output/CompilerInput.class src/test/java/main/CompilerInput.class
src/test/resources/output/javac/CompilerInput$Test.class src/test/resources/output/javac/CompilerInput$Test.class
src/test/resources/output/javac/CompilerInput.class src/test/resources/output/javac/CompilerInput.class
src/test/resources/output/miniCompiler/CompilerInput.class src/test/resources/output/miniCompiler/CompilerInput.class

View File

@ -1,58 +0,0 @@
# Kurzdokumentation
## Aufgabenverteilung
### Maximilian Stahl und Jannik Rombach:
- **Scanner**
- **Parser**
- **AST**
- **AstBuilder**
- **Modul: ast**
- Alle
- **Modul: parser**
- Alle
- **Modul: visitor**
- Alle
- **Testmodul: parser**
- AstBuildertest.java
- Helper.java
- **Testfiles: singleFeatureTests**
- Alle
### Johannes Ehlert:
- **Semantische Analyse**
- **Modul: semantic**
- **Modul: typecheck**
- **Testmodul: parser**
- AstBuildertest.java
- **Testfiles: typedAstFeatureTests**
- Großteil
- **Testfiles: typedAstExceptionsTests**
- Großteil
### David Große:
- **Bytecodegenerator**
- **Modul: bytecode**
- Alle
### Lucas Janker:
- **Tests**
- **Modul: main**
- Alle
- **Testmodul: main**
- Alle
- **Testmodul: parser**
- ScannerTest.java
- ParserTest.java
- **Testmodul: semantic**
- **Testfiles: combinedFeatureTests**
- Alle
- **Testfiles: failureTests**
- Alle
- **Testfiles: Alle**
- Refactoring
- **Ordnerstrukturen**
- Großteil
- **Build**
- **Makefile**
- **Dokumentation**

Binary file not shown.

Binary file not shown.

View File

@ -55,7 +55,10 @@ test/
## Distribution of the realisation ## Distribution of the realisation
### i22030 & i22035 ### i22030 & i22035
Ausführliche Beschreibung der Parser Umsetzung: ![Parserumsetzung](Parser_Dokumentation.pdf) Ausführliche Beschreibung der Parser Umsetzung:
![Parserumsetzung](Parser_Dokumentation.pdf)
Parser: Parser:
- Grammar -> (src/main/java/parser/grammar) - Grammar -> (src/main/java/parser/grammar)
- Scanner - Scanner
@ -110,7 +113,7 @@ cd .\src\test\ ; make clean compile-miniCompiler
``` ```
### 2. Start miniCompiler using jar: ### 2. Start miniCompiler using jar:
If you do not have the .jar, download it [here](https://gitea.hb.dhbw-stuttgart.de/i22005/NichtHaskell2.0/src/branch/Endabgabe/src) or compile it using mvn package or make first If you do not have the .jar, download it [here](https://gitea.hb.dhbw-stuttgart.de/i22005/NichtHaskell2.0/src/branch/main/JavaCompiler-1.0-jar-with-dependencies.jar) or compile it using mvn package or make first
``` ```
java.exe -DgenJar=bool -DgenClass=bool -jar path_to_jar\jarName.jar 'path_to_input_file.java' 'path_to_output_directory' java.exe -DgenJar=bool -DgenClass=bool -jar path_to_jar\jarName.jar 'path_to_input_file.java' 'path_to_output_directory'
``` ```

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View File

@ -5,23 +5,12 @@
all: compile-javac compile-miniCompiler all: compile-javac compile-miniCompiler
compile-javac: compile-javac:
javac -d .\resources\output\javac .\resources\input\CompilerInput.java javac -d .\resources\output\javac ..\main\resources\input\CompilerInput.java
compile-miniCompiler: compile-miniCompiler:
cd ../.. ; mvn -DskipTests install cd ../.. ; mvn -DskipTests install
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 .\resources\output\miniCompiler
test: compile-miniCompiler test-miniCompiler
test-miniCompiler:
# move the compiled class to the test/main folder
mv ../main/resources/output/Compiler.class .java/
# compile the test class
javac .java/main.EndToEndTester.java
# run the test class
java .java/main.EndToEndTester
clean: clean:
# clean main output folders # clean main output folders

View File

@ -107,12 +107,6 @@ public class E2EReflectionsTest {
runTest("MultipleClasses"); runTest("MultipleClasses");
} }
@Test
@Disabled
public void SelfReferenceTest() {
runTest("SelfReference");
}
@Test @Test
public void ThisDotTest() { public void ThisDotTest() {
runTest("ThisDot"); runTest("ThisDot");

View File

@ -1,43 +0,0 @@
package main;
/**
* This class is used to test the output of the compiler.
*
* <p>Im gleichen Ordner wie diese Datei (EndToEndTester.java) muss die selbst kompilierte CompilerInput.class Datei sein.
* <br><strong>Hinweis:</strong> Diese muss man also vom Ordner <code> main/resources/output </code> in diesen Ordner hier (test/java/main) rein kopieren. (bis es eine bessere Lösung gibt -> bin grad in der Make dran das alles hier automatisch zu machen)</p>
*
* <p>Die selbst kompilierte .class Datei wird dann hier drin geladen und eine Instanz von ihr erstellt, es können auch Methoden aufgerufen werden.
* <p>Diese EndToEndTester.java Datei wird dann in <code> \src\test\java> </code> mit <code>javac .\main.EndToEndTester.java</code> kompiliert und mit <code>java main.EndToEndTester</code> ausgeführt.
* Wenn unser Compiler funktioniert, sollten keine Errors kommen (sondern nur die Ausgaben, die wir in der CompilerInput.java Datei gemacht haben,
* oder Methoden, die wir hier aufrufen).</p>
*
*/
public class EndToEndTester {
public static void main(String[] args) {
try {
// Try to load the class named "CompilerInput"
Class<?> cls = Class.forName("Compiler");
// Print a success message if the class is loaded successfully
System.out.println("Class loaded successfully: " + cls.getName());
// Try to create an instance of the loaded class
Object instance = cls.getDeclaredConstructor().newInstance();
// Print a success message if the instance is created successfully
System.out.println("Instance created: " + instance);
// If the class has a main method, you can invoke it
// cls.getMethod("main", String[].class).invoke(null, (Object) new String[]{});
// If the class has other methods, you can invoke them as well
// Example: cls.getMethod("someMethod").invoke(instance);
} catch (ClassNotFoundException e) {
// Print an error message if the class is not found
System.err.println("Class not found: " + e.getMessage());
} catch (Exception e) {
// Print an error message if any other exception occurs during class loading or instance creation
System.err.println("Error during class loading or execution: " + e.getMessage());
}
}
}

View File

@ -1,6 +1,5 @@
package main; package main;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import javax.tools.JavaCompiler; import javax.tools.JavaCompiler;
@ -78,55 +77,6 @@ public class InputFilesTest {
} }
} }
@Test
@Disabled
public void areEndabgabeTestsActuallyValid() throws IOException {
// Get the system Java compiler
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
// Assert that the compiler is available
assertNotNull(javac, "Java Compiler is not available");
File endabgabeTests = new File("src/test/resources/input/endabgabeTests");
List<File> files = getJavaFilesFromDirectory(endabgabeTests);
if (!files.isEmpty()) {
for (File file : files) {
// Try to compile the file and get the result
int result = javac.run(null, null, null, file.getPath());
// Assert that the compilation succeeded (i.e., the result is zero)
assertEquals(0, result, "Expected compilation success for " + file.getName());
}
} else {
System.out.println("No files found in the directories.");
}
}
@Test
@Disabled
public void areSingleFeatureSemanticTestsActuallyValid() throws IOException {
// Get the system Java compiler
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
// Assert that the compiler is available
assertNotNull(javac, "Java Compiler is not available");
File singleFeatureSemanticTests = new File("src/test/resources/input/singleFeatureSemanticTests");
List<File> files = getJavaFilesFromDirectory(singleFeatureSemanticTests);
if (!files.isEmpty()) {
for (File file : files) {
// Try to compile the file and get the result
int result = javac.run(null, null, null, file.getPath());
// Assert that the compilation succeeded (i.e., the result is zero)
assertEquals(0, result, "Expected compilation success for " + file.getName());
}
} else {
System.out.println("No files found in the directories.");
}
}
@Test @Test
@ -154,34 +104,6 @@ public class InputFilesTest {
} }
@Test
@Disabled
public void areTypedAstFeatureTestsActuallyValid() throws IOException {
// Get the system Java compiler
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
// Assert that the compiler is available
assertNotNull(javac, "Java Compiler is not available");
File typedAstFeatureTests = new File("src/test/resources/input/typedAstFeatureTests");
List<File> files = getJavaFilesFromDirectory(typedAstFeatureTests);
if (!files.isEmpty()) {
for (File file : files) {
// Try to compile the file and get the result
int result = javac.run(null, null, null, file.getPath());
// Assert that the compilation succeeded (i.e., the result is zero)
assertEquals(0, result, "Expected compilation success for " + file.getName());
}
} else {
System.out.println("No files found in the directories.");
}
}
/** /**
* This test method checks if invalid Java files fail to compile as expected. * This test method checks if invalid Java files fail to compile as expected.
* It uses the JavaCompiler from the ToolProvider to compile the files. * It uses the JavaCompiler from the ToolProvider to compile the files.

View File

@ -12,9 +12,6 @@ import semantic.SemanticTest;
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)
@Suite.SuiteClasses({ @Suite.SuiteClasses({
InputFilesTest.class,
SemanticTest.class,
EndToTypedAstTest.class
}) })
public class MainTest { public class MainTest {
// This class remains empty, it is used only as a holder for the above annotations // This class remains empty, it is used only as a holder for the above annotations