diff --git a/src/de/dhbwstuttgart/parser/RunParser.java b/src/de/dhbwstuttgart/parser/RunParser.java index 9489ca6c..62464e58 100644 --- a/src/de/dhbwstuttgart/parser/RunParser.java +++ b/src/de/dhbwstuttgart/parser/RunParser.java @@ -21,9 +21,10 @@ public class RunParser{ Java8Lexer lexer = new Java8Lexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); Java8Parser parser = new Java8Parser(tokens); - ParserRuleContext tree = parser.compilationUnit(); - SyntaxTreeGenerator generator = new SyntaxTreeGenerator(null); - generator.convert((Java8Parser.CompilationUnitContext) tree); + Java8Parser.CompilationUnitContext tree = parser.compilationUnit(); + SyntaxTreeGenerator generator = new SyntaxTreeGenerator(); + // generator.convert((Java8Parser.CompilationUnitContext) tree); + generator.getNames(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 index 866734f6..ff604263 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java @@ -2,13 +2,27 @@ package de.dhbwstuttgart.parser; import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; -import de.dhbwstuttgart.typecheck.JavaClassRegistry; +import de.dhbwstuttgart.typecheck.*; import java.util.ArrayList; import java.util.List; +import org.antlr.v4.runtime.tree.TerminalNode; public class SyntaxTreeGenerator{ JavaClassRegistry reg = new JavaClassRegistry(); + + public void getNames(Java8Parser.CompilationUnitContext ctx){ + List names = new ArrayList(); + String packageDecl = ""; + List decls = ctx.packageDeclaration().Identifier(); + if(decls != null){ + for(TerminalNode t : decls){ + packageDecl = packageDecl + "." + t.toString(); + } + packageDecl = packageDecl.substring(1); + System.out.println(packageDecl); + } + } public SourceFile convert(Java8Parser.CompilationUnitContext ctx){