diff --git a/.idea/misc.xml b/.idea/misc.xml index 2d71b1f..7cf0be7 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -40,7 +40,7 @@ - + \ No newline at end of file diff --git a/Tester.java b/Tester.java new file mode 100644 index 0000000..4c79d57 --- /dev/null +++ b/Tester.java @@ -0,0 +1,5 @@ +public class Tester { + public static void main(String[] args) { + new Test(); + } +} diff --git a/src/main/java/parser/Main.java b/src/main/java/parser/Main.java index 64a1c8b..1f98fb1 100644 --- a/src/main/java/parser/Main.java +++ b/src/main/java/parser/Main.java @@ -1,5 +1,6 @@ package parser; +import bytecode.ByteCodeGenerator; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; @@ -10,7 +11,7 @@ import parser.generated.SimpleJavaParser; public class Main { public static void main(String[] args) throws Exception { // Assuming args[0] contains the path to the input file - CharStream codeCharStream = CharStreams.fromString("class Test { }"); + CharStream codeCharStream = CharStreams.fromString("class Example { }"); SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); CommonTokenStream tokens = new CommonTokenStream(lexer); SimpleJavaParser parser = new SimpleJavaParser(tokens); @@ -22,9 +23,9 @@ public class Main { // Optionally print or process the AST System.out.println("Parsed " + ast.classes.size() + " classes."); - System.out.println(ast.classes.get(0).identifier); + System.out.println(ast.classes.getFirst().identifier); - //ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(); - //byteCodeGenerator.generateByteCode(ast); + ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(); + byteCodeGenerator.generateByteCode(ast); } } \ No newline at end of file diff --git a/src/main/test/java/TestSpecs.md b/src/main/test/java/TestSpecs.md index 3626c74..5a0eb55 100644 --- a/src/main/test/java/TestSpecs.md +++ b/src/main/test/java/TestSpecs.md @@ -2,7 +2,7 @@ ## Scanner Input ### Beispiel 1: Empty Class - String empty class = "class name {}"; + String empty class = "public class Name {}"; ### Beispiel 2: Filled Class @@ -17,7 +17,7 @@ ## Scanner Output ### Beispiel 1: Empty Class - [TokClass,TokIdentifier "name",TokLeftBrace,TokRightBrace] + [TokPublic,TokClass,TokIdentifier "Name",TokLeftBrace,TokRightBrace] ### Beispiel 2: Filled Class @@ -29,9 +29,10 @@ [TokRightBrace] # Parser -## Parser Input (Scanner Output) +## Parser Input +(Scanner Output) -## Parser Output -> AST +## Parser Output (AST) ### Beispiel 1: Empty Class @@ -41,7 +42,8 @@ # Semantische Analyse / Typcheck -## Typcheck Input (Parser Output) +## Typcheck Input +(Parser Output = AST) ## Typcheck Output @@ -53,5 +55,18 @@ # Bytecodegenerierung +## Bytecodegenerierung Input +(Typcheck Output = vom Typcheck eventuell manipulierter AST) +## Bytecodegenerierung Output + +### Beispiel 1: Empty Class +Compiled Classfile + + public class Example { + } + + + +### Beispiel 2: Filled Class \ No newline at end of file