diff --git a/Tester.class b/Tester.class deleted file mode 100644 index 69949dc..0000000 Binary files a/Tester.class and /dev/null differ diff --git a/src/main/java/Example.java b/src/main/java/CompilerInput.txt similarity index 96% rename from src/main/java/Example.java rename to src/main/java/CompilerInput.txt index 6f34d6e..aaa23f5 100644 --- a/src/main/java/Example.java +++ b/src/main/java/CompilerInput.txt @@ -1,3 +1,2 @@ public class Example { } - diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 87d9828..4045dee 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -14,9 +14,11 @@ import java.nio.file.Paths; public class Main { public static void main(String[] args) throws Exception { + CharStream codeCharStream = null; + try { - codeCharStream = CharStreams.fromPath(Paths.get("./Example.java")); + codeCharStream = CharStreams.fromPath(Paths.get("src/main/java/CompilerInput.txt")); parsefile(codeCharStream); } catch (IOException e) { System.err.println("Error reading the file: " + e.getMessage()); @@ -25,7 +27,7 @@ public class Main { static void parsefile(CharStream codeCharStream){ - // CharStream codeCharStream = CharStreams.fromString("class Example { } class Example2 { }"); + // CharStream codeCharStream = CharStreams.fromString("class javaFileInput.Example { } class Example2 { }"); SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); CommonTokenStream tokens = new CommonTokenStream(lexer); SimpleJavaParser parser = new SimpleJavaParser(tokens); diff --git a/classFileOutput/Example.class b/src/main/java/classFileOutput/Example.class similarity index 100% rename from classFileOutput/Example.class rename to src/main/java/classFileOutput/Example.class diff --git a/src/main/test/java/SimpleJavaFeatureTest.java b/src/main/test/java/AllFeaturesClassExample.java similarity index 90% rename from src/main/test/java/SimpleJavaFeatureTest.java rename to src/main/test/java/AllFeaturesClassExample.java index b71f63b..1a8493d 100644 --- a/src/main/test/java/SimpleJavaFeatureTest.java +++ b/src/main/test/java/AllFeaturesClassExample.java @@ -1,10 +1,10 @@ -public class SimpleJavaFeatureTest { +public class AllFeaturesClassExample { int a; boolean b; char c; // Konstruktor - SimpleJavaFeatureTest(int a, boolean b, char c) { + AllFeaturesClassExample(int a, boolean b, char c) { this.a = a; this.b = b; this.c = c; @@ -62,7 +62,7 @@ public class SimpleJavaFeatureTest { } public static void main(String[] args) { - SimpleJavaFeatureTest obj = new SimpleJavaFeatureTest(12, true, 'a'); + AllFeaturesClassExample obj = new AllFeaturesClassExample(12, true, 'a'); obj.controlStructures(); obj.logicalOperations(); } diff --git a/src/main/test/java/EmptyClassExample.java b/src/main/test/java/EmptyClassExample.java new file mode 100644 index 0000000..290e747 --- /dev/null +++ b/src/main/test/java/EmptyClassExample.java @@ -0,0 +1,4 @@ +public class EmptyClassExample { + private class Inner { + } +} \ No newline at end of file diff --git a/src/main/test/java/MainTest.java b/src/main/test/java/MainTest.java index 46ad4ee..3da386d 100644 --- a/src/main/test/java/MainTest.java +++ b/src/main/test/java/MainTest.java @@ -25,7 +25,7 @@ public class MainTest { void testEmptyClass() { CharStream codeCharStream = null; try { - codeCharStream = CharStreams.fromPath(Paths.get("src/main/java/Example.java")); + codeCharStream = CharStreams.fromPath(Paths.get("src/main/test/java/EmptyClassExample.java")); Main.parsefile(codeCharStream); } catch (IOException e) { System.err.println("Error reading the file: " + e.getMessage()); diff --git a/src/main/test/java/MoreFeaturesClassExample.java b/src/main/test/java/MoreFeaturesClassExample.java new file mode 100644 index 0000000..4f6fbf3 --- /dev/null +++ b/src/main/test/java/MoreFeaturesClassExample.java @@ -0,0 +1,6 @@ +public class MoreFeaturesClassExample { + int hallo; + private class Inner { + int hallo2; + } +} diff --git a/src/main/test/java/TestSpecs.md b/src/main/test/java/TestSpecs.md index 5a0eb55..f459ee6 100644 --- a/src/main/test/java/TestSpecs.md +++ b/src/main/test/java/TestSpecs.md @@ -7,7 +7,7 @@ ### Beispiel 2: Filled Class String filled class = - "class Example {" + + "class javaFileInput.Example {" + "if (x < 5) {" + "for (int i = 0; i < 10; i++) {" + "while (true) {" + @@ -21,7 +21,7 @@ ### Beispiel 2: Filled Class - [TokClass,TokIdentifier "Example",TokLeftBrace] + [TokClass,TokIdentifier "javaFileInput.Example",TokLeftBrace] [TokIf,TokLeftParen,TokIdentifier "x",TokLessThan,TokNumber 5,TokRightParen,TokLeftBrace] [TokFor,TokLeftParen,TokIdentifier "int",TokIdentifier "i",TokAssign,TokNumber 0,TokSemicolon,TokIdentifier "i",TokLessThan,TokNumber 10,TokSemicolon,TokIdentifier "i",TokPlus,TokPlus,TokRightParen,TokLeftBrace] [TokWhile,TokLeftParen,TokIdentifier "true",TokRightParen,TokLeftBrace] @@ -63,7 +63,7 @@ ### Beispiel 1: Empty Class Compiled Classfile - public class Example { + public class javaFileInput.Example { } diff --git a/Tester.java b/src/main/test/java/Tester.java similarity index 69% rename from Tester.java rename to src/main/test/java/Tester.java index 92c20ee..b0e86c8 100644 --- a/Tester.java +++ b/src/main/test/java/Tester.java @@ -1,5 +1,5 @@ public class Tester { public static void main(String[] args) { - new Example(); + new EmptyClassExample(); } }