diff --git a/src/de/dhbwstuttgart/parser/RunParser.java b/src/de/dhbwstuttgart/parser/RunParser.java index 9b1c8653..9489ca6c 100644 --- a/src/de/dhbwstuttgart/parser/RunParser.java +++ b/src/de/dhbwstuttgart/parser/RunParser.java @@ -22,9 +22,8 @@ public class RunParser{ CommonTokenStream tokens = new CommonTokenStream(lexer); Java8Parser parser = new Java8Parser(tokens); ParserRuleContext tree = parser.compilationUnit(); - ParseTreeWalker walker = new ParseTreeWalker(); - CompilationUnitEvaluator eval = new CompilationUnitEvaluator(); - walker.walk(eval, tree); + SyntaxTreeGenerator generator = new SyntaxTreeGenerator(null); + generator.convert((Java8Parser.CompilationUnitContext) tree); } catch(Exception e){ System.out.println("An exception occured which is unknown and on our TODO list."); diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java new file mode 100644 index 00000000..78694e38 --- /dev/null +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java @@ -0,0 +1,29 @@ +package de.dhbwstuttgart.parser; + +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.Class; +import de.dhbwstuttgart.typecheck.JavaClassRegistry; + +import java.util.ArrayList; +import java.util.List; + +public class SyntaxTreeGenerator { + + public SyntaxTreeGenerator(JavaClassRegistry nameReg){ + //TODO: Implement + } + + public SourceFile convert(Java8Parser.CompilationUnitContext ctx){ + List classes = new ArrayList<>(); + for(Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){ + Class newClass = convert(typeDecl.classDeclaration()); + classes.add(newClass); + } + return new SourceFile(classes); + } + + private Class convert(Java8Parser.ClassDeclarationContext ctx) { + //TODO: Implement + return null; + } +}