Fehler im Parsen von Typen mit Package Namen behoben

This commit is contained in:
JanUlrich 2018-09-07 00:39:31 +02:00
parent 8759a9cc5d
commit 1e037a0019
6 changed files with 2942 additions and 2931 deletions

View File

@ -104,7 +104,17 @@ public class TypeGenerator {
private static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.ClassOrInterfaceTypeContext classOrInterfaceTypeContext, JavaClassRegistry reg, GenericsRegistry generics) {
Java8Parser.ClassType_lfno_classOrInterfaceTypeContext ctx = classOrInterfaceTypeContext.classType_lfno_classOrInterfaceType();
return convertTypeName(ctx.Identifier().toString(), ctx.typeArguments(),classOrInterfaceTypeContext.getStart(), reg, generics);
if(ctx.typeArguments() != null &&
classOrInterfaceTypeContext.classType_lf_classOrInterfaceType().size() > 0)
throw new NotImplementedException();
String typeName = ctx.Identifier().toString();
Java8Parser.ClassType_lf_classOrInterfaceTypeContext nextCtx = null;
for(Java8Parser.ClassType_lf_classOrInterfaceTypeContext forEachCtx : classOrInterfaceTypeContext.classType_lf_classOrInterfaceType()){
nextCtx = forEachCtx;
typeName += "." + forEachCtx.Identifier().toString();
}
Java8Parser.TypeArgumentsContext arguments = nextCtx!=null?nextCtx.typeArguments():ctx.typeArguments();
return convertTypeName(typeName, arguments, classOrInterfaceTypeContext.getStart(), reg, generics);
}
private static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.InterfaceTypeContext interfaceTypeContext) {

View File

@ -109,7 +109,6 @@ classOrInterfaceType
| interfaceType_lfno_classOrInterfaceType
)
( classType_lf_classOrInterfaceType
| interfaceType_lf_classOrInterfaceType
)*
;

File diff suppressed because it is too large Load Diff

View File

@ -5,12 +5,12 @@ class Faculty {
m () {
var fact = (Integer x) -> {
//if (x == 1) {
if (x == 1) {
return x;
//}
//else {
//return x * (fact.apply(x-1));
//}
}
else {
return x * (fact.apply(x-1));
}
};
return fact;
}

View File

@ -0,0 +1,17 @@
import java.lang.Integer;
class Faculty {
m () {
var fact = (Integer x) -> {
if (x == 1) {
return x;
}
else {
return x * (fact.apply(x-1));
}
};
return fact;
}
}

View File

@ -61,6 +61,10 @@ public class JavaTXCompilerTest {
execute(new File(rootDirectory+"Faculty.jav"));
}
@Test
public void facultyIf() throws IOException, ClassNotFoundException {
execute(new File(rootDirectory+"FacultyIf.jav"));
}
@Test
public void facultyTyped() throws IOException, ClassNotFoundException {
execute(new File(rootDirectory+"FacultyTyped.jav"));
}