* "Normal" class and interface names can now be resolved.

* TODO: line comments
This commit is contained in:
Jakob Herrmann 2017-01-10 22:20:44 +01:00
parent fb10220da9
commit 3c6ffcf4d8
3 changed files with 22 additions and 4 deletions

View File

@ -29,6 +29,7 @@ public class RunParser{
for(JavaClassName name : generator.reg.existingClasses){
System.out.println(name.toString());
}
System.out.println(generator.reg.existingClasses.size());
}
catch(Exception e){
System.out.println("An exception occured which is unknown and on our TODO list.");

View File

@ -13,17 +13,33 @@ public class SyntaxTreeGenerator{
public void getNames(Java8Parser.CompilationUnitContext ctx){
String packageDecl = "";
List<TerminalNode> decls = ctx.packageDeclaration().Identifier();
if(decls != null){
for(TerminalNode t : decls){
if(ctx.packageDeclaration() != null){
for(TerminalNode t : ctx.packageDeclaration().Identifier()){
packageDecl = packageDecl + "." + t.toString();
}
packageDecl = packageDecl.substring(1);
}
String nameString = "";
for (Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
if(typeDecl.interfaceDeclaration() != null){
if(typeDecl.interfaceDeclaration().normalInterfaceDeclaration() != null){
String nameString = packageDecl + "." + typeDecl.interfaceDeclaration().normalInterfaceDeclaration().Identifier().toString();
if(packageDecl != ""){
nameString = packageDecl + "." + typeDecl.interfaceDeclaration().normalInterfaceDeclaration().Identifier().toString();
}
else{
nameString = typeDecl.interfaceDeclaration().normalInterfaceDeclaration().Identifier().toString();
}
this.reg.existingClasses.add(new JavaClassName(nameString));
}
}
else{
if(typeDecl.classDeclaration().normalClassDeclaration() != null){
if(packageDecl != ""){
nameString = packageDecl + "." + typeDecl.classDeclaration().normalClassDeclaration().Identifier().toString();
}
else{
nameString = typeDecl.classDeclaration().normalClassDeclaration().Identifier().toString();
}
this.reg.existingClasses.add(new JavaClassName(nameString));
}
}

View File

@ -2,3 +2,4 @@
* Core-Problem: Typinferenz vs. Konstruktoren
* möglicherweise Problem: falsche Return-Expressions
* Problem: Line-Comments werden nicht erkannt bzw. führen dazu dass das gesamte File nicht geparsed wird (Java8.g4).