Compare commits
2 Commits
f673612f54
...
4c4c06f728
Author | SHA1 | Date | |
---|---|---|---|
|
4c4c06f728 | ||
|
30bd5a0b5c |
2
.gitignore
vendored
2
.gitignore
vendored
@ -78,7 +78,7 @@ fabric.properties
|
||||
|
||||
/target
|
||||
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.class
|
||||
src/test/resources/output/miniCompiler/CompilerInput.class
|
||||
|
@ -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**
|
BIN
JavaCompiler-1.0-jar-with-dependencies.jar
Normal file
BIN
JavaCompiler-1.0-jar-with-dependencies.jar
Normal file
Binary file not shown.
Binary file not shown.
@ -55,7 +55,10 @@ test/
|
||||
## Distribution of the realisation
|
||||
|
||||
### i22030 & i22035
|
||||
Ausführliche Beschreibung der Parser Umsetzung: ![Parserumsetzung](Parser_Dokumentation.pdf)
|
||||
Ausführliche Beschreibung der Parser Umsetzung:
|
||||
|
||||
![Parserumsetzung](Parser_Dokumentation.pdf)
|
||||
|
||||
Parser:
|
||||
- Grammar -> (src/main/java/parser/grammar)
|
||||
- Scanner
|
||||
@ -110,7 +113,7 @@ cd .\src\test\ ; make clean compile-miniCompiler
|
||||
```
|
||||
|
||||
### 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'
|
||||
```
|
||||
|
809
src/main/resources/logs/miniCompiler.log
Normal file
809
src/main/resources/logs/miniCompiler.log
Normal file
File diff suppressed because one or more lines are too long
BIN
src/main/resources/output/CompilerInput.class
Normal file
BIN
src/main/resources/output/CompilerInput.class
Normal file
Binary file not shown.
BIN
src/main/resources/output/output.jar
Normal file
BIN
src/main/resources/output/output.jar
Normal file
Binary file not shown.
@ -5,23 +5,12 @@
|
||||
all: compile-javac compile-miniCompiler
|
||||
|
||||
compile-javac:
|
||||
javac -d .\resources\output\javac .\resources\input\CompilerInput.java
|
||||
javac -d .\resources\output\javac ..\main\resources\input\CompilerInput.java
|
||||
|
||||
compile-miniCompiler:
|
||||
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'"
|
||||
|
||||
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
|
||||
|
||||
|
||||
cp ..\main\resources\output\CompilerInput.class .\resources\output\miniCompiler
|
||||
|
||||
clean:
|
||||
# clean main output folders
|
||||
|
@ -107,12 +107,6 @@ public class E2EReflectionsTest {
|
||||
runTest("MultipleClasses");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void SelfReferenceTest() {
|
||||
runTest("SelfReference");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ThisDotTest() {
|
||||
runTest("ThisDot");
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package main;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
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
|
||||
@ -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.
|
||||
* It uses the JavaCompiler from the ToolProvider to compile the files.
|
||||
|
@ -12,9 +12,6 @@ import semantic.SemanticTest;
|
||||
*/
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
InputFilesTest.class,
|
||||
SemanticTest.class,
|
||||
EndToTypedAstTest.class
|
||||
})
|
||||
public class MainTest {
|
||||
// This class remains empty, it is used only as a holder for the above annotations
|
||||
|
Loading…
Reference in New Issue
Block a user