Structure

This commit is contained in:
i22011 2024-05-08 11:42:34 +02:00
parent 7e4c0d97f6
commit c48a3671fb
4 changed files with 12 additions and 4 deletions

View File

@ -0,0 +1,3 @@
public class Example {
}

View File

@ -1,10 +1,11 @@
package parser;
import bytecode.ByteCodeGenerator; import bytecode.ByteCodeGenerator;
import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.ParseTree;
import parser.ASTBuilder;
import parser.ClassDeclarationNode;
import parser.ProgramNode;
import parser.generated.SimpleJavaLexer; import parser.generated.SimpleJavaLexer;
import parser.generated.SimpleJavaParser; import parser.generated.SimpleJavaParser;
@ -15,7 +16,7 @@ public class Main {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
CharStream codeCharStream = null; CharStream codeCharStream = null;
try { try {
codeCharStream = CharStreams.fromPath(Paths.get("path/to/your/file.txt")); codeCharStream = CharStreams.fromPath(Paths.get("src/main/java/Example.java"));
parsefile(codeCharStream); parsefile(codeCharStream);
} catch (IOException e) { } catch (IOException e) {
System.err.println("Error reading the file: " + e.getMessage()); System.err.println("Error reading the file: " + e.getMessage());

View File

@ -1 +0,0 @@
class Test { }

View File

@ -9,6 +9,11 @@ public class SimpleJavaFeatureTest {
this.b = b; this.b = b;
this.c = c; this.c = c;
} }
private class InnerClass {
void innerMethod() {
System.out.println("Inner class method");
}
}
// Methode zur Demonstration von Kontrollstrukturen // Methode zur Demonstration von Kontrollstrukturen
void controlStructures() { void controlStructures() {