forked from JavaTX/JavaCompilerCore
neuer Versuch mit Parser gespeichert
This commit is contained in:
parent
9eebf294dc
commit
3c165f79e4
30
src/FLJ.g4
Normal file
30
src/FLJ.g4
Normal file
@ -0,0 +1,30 @@
|
||||
grammar FLJ;
|
||||
|
||||
// Inputsyntax für ein Featherweight Java
|
||||
|
||||
l2 : (l)+;
|
||||
|
||||
l : Class ClassName '{' (feld)* method* '}';
|
||||
|
||||
|
||||
feld: ClassName Var ';';
|
||||
|
||||
returnExpression: 'return' expression ';' ;
|
||||
methodCall: Var '(' args? ')';
|
||||
|
||||
|
||||
expression: Var | expression'.'methodCall | expression'.'Var | 'new' ClassName generics? '('expressionArgs?')' expression? ;
|
||||
method: Var '(' expressionArgs? ')' '{' returnExpression? '}' ;
|
||||
args: Var | (Var ',')+ Var ;
|
||||
expressionArgs : expression | (expression ',')+ expression;
|
||||
|
||||
generics: '<''>';
|
||||
|
||||
Class: 'class';
|
||||
ClassName: [A-Z]+[a-z]*;
|
||||
Var: [a-z]+;
|
||||
|
||||
|
||||
|
||||
Linefeed: '\r'? '\n' -> skip; //'\r' für Windows linefeed
|
||||
WS : [ \t]+ -> skip; //Überspringen aller Leerzeichen
|
47
src/FWJ.g4
Normal file
47
src/FWJ.g4
Normal file
@ -0,0 +1,47 @@
|
||||
grammar FWJ;
|
||||
|
||||
// Inputsyntax für ein Federleichtes Java
|
||||
|
||||
sourceFile : (classX)+;
|
||||
|
||||
classX : Class bezeichner '{' (feld)* methodDecl* '}';
|
||||
|
||||
|
||||
feld: bezeichner bezeichner ';';
|
||||
|
||||
//returnExpression: 'return' expression ';' ;
|
||||
//methodCall: Token2 '(' expr? ')';
|
||||
|
||||
|
||||
//expression: exprVar | exprNew | exprMcall ;
|
||||
//method: Var '(' expressionArgs? ')' '{' returnExpression? '}' ;
|
||||
//args: Var | (Var ',')+ Var ;
|
||||
//expressionArgs : expression | (expression ',')+ expression;
|
||||
|
||||
generics: '<' ( (generic ',' )+ generic | generic? ) '>';
|
||||
generic: (bezeichner '=' bezeichner);
|
||||
|
||||
methodDecl: bezeichner '(' methodDeclArgs? ')' '{' returnExpr? '}' ;
|
||||
methodDeclArgs: bezeichner | (bezeichner ',')+ bezeichner ;
|
||||
|
||||
returnExpr: 'return' expr ';' ;
|
||||
|
||||
|
||||
exprMCall : bezeichner '(' exprMCallArgs? ')';
|
||||
exprVar: bezeichner;
|
||||
exprField: '.'bezeichner;
|
||||
exprNew: 'new' bezeichner generics? '('exprMCallArgs?')';
|
||||
|
||||
|
||||
expr: exprVar | expr'.'expr | exprField | exprMCall | exprNew ;
|
||||
exprMCallArgs: expr | ( expr ',')+ expr;
|
||||
|
||||
|
||||
Class: 'class';
|
||||
// Für Klassen und Variablen
|
||||
bezeichner: Token2;
|
||||
Token2: [a-zA-Z0-9_]+;
|
||||
|
||||
|
||||
Linefeed: '\r'? '\n' -> skip; //'\r' für Windows linefeed
|
||||
WS : [ \t]+ -> skip; //Überspringen aller Leerzeichen
|
8
src/control/A.jal
Normal file
8
src/control/A.jal
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
class A {
|
||||
mt(x,y,z) { return x.sub(y).add(z) ; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
8
src/control/A2.jal
Normal file
8
src/control/A2.jal
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
class A {
|
||||
mt(x,y,z) { return x.sub(y.div1() , y.mul2(z.fak())); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
7
src/control/Main.jal
Normal file
7
src/control/Main.jal
Normal file
@ -0,0 +1,7 @@
|
||||
class Main {
|
||||
|
||||
main() { return new A< T1=MyInteger , T7=MyInteger >().mt( new MyInteger(1) , new MyInteger(2) , new MyInteger(3) ); }
|
||||
|
||||
}
|
||||
|
||||
|
71
src/control/Main.java
Normal file
71
src/control/Main.java
Normal file
@ -0,0 +1,71 @@
|
||||
package control;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.parserFWJ.Parser;
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.ClassTyped;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPHwithClass;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println("Hallo Welt");
|
||||
|
||||
// Pfade:
|
||||
String s1 = "source3.javLight";
|
||||
String s2 = "source2.javLight";
|
||||
String s3 = "source.javLight";
|
||||
String ne = "sourceNew.javLight";
|
||||
|
||||
|
||||
// Neue Pfade
|
||||
String myInteger = "MyInteger.jal";
|
||||
String main = "Main.jal";
|
||||
String a = "A.jal";
|
||||
String a2 = "A2.jal";
|
||||
|
||||
|
||||
Start start = new Start(a2, main);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// Lesen von A
|
||||
Parser p = new Parser();
|
||||
Map<String, TPH> ass = new HashMap<>();
|
||||
ClassTyped clta = p.parseCode(ReadIn.read(a),ass);
|
||||
|
||||
TPHwithClass tph = new TPHwithClass();
|
||||
tph.classTyped = clta;
|
||||
ass.put("$A", tph );
|
||||
//ass.put("$Integer",tph);
|
||||
//ass.put("$MyInteger",tph);
|
||||
|
||||
// Lesen von main
|
||||
Parser p3 = new Parser();
|
||||
ClassTyped cltmain = p3.parseCode(ReadIn.read(main),ass);
|
||||
System.out.println(cltmain);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
8
src/control/MyInteger.jal
Normal file
8
src/control/MyInteger.jal
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
class MyInteger {
|
||||
|
||||
Integer i;
|
||||
add(x) { return new MyInteger(x); }
|
||||
sub(x) { return new MyInteger(x); }
|
||||
|
||||
}
|
51
src/control/ReadIn.java
Normal file
51
src/control/ReadIn.java
Normal file
@ -0,0 +1,51 @@
|
||||
package control;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
public class ReadIn {
|
||||
|
||||
public static String read(String sourcePath) {
|
||||
|
||||
|
||||
String result = "";
|
||||
|
||||
try {
|
||||
|
||||
|
||||
InputStream is = Main.class.getResourceAsStream(sourcePath);
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
BufferedReader bf = new BufferedReader(isr);
|
||||
List<String> lines = new ArrayList<>();
|
||||
|
||||
while (true) {
|
||||
String l = bf.readLine();
|
||||
if (l == null) {
|
||||
break;
|
||||
} else {
|
||||
lines.add(l);
|
||||
}
|
||||
}
|
||||
for (String l2 : lines) {
|
||||
result = result.concat(l2 + "\n" );
|
||||
}
|
||||
return result;
|
||||
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
40
src/control/Start.java
Normal file
40
src/control/Start.java
Normal file
@ -0,0 +1,40 @@
|
||||
package control;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.parserFWJ.Parser;
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.ClassTyped;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPHwithClass;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 12.04.17.
|
||||
*/
|
||||
public class Start {
|
||||
|
||||
|
||||
Map<String, TPH> assumptionsGlobal = new HashMap<>();
|
||||
List<ClassTyped> results = new ArrayList<>();
|
||||
|
||||
|
||||
public Start(String... argsPfade ) {
|
||||
|
||||
for (String arg : argsPfade) {
|
||||
parseKlasse(arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void parseKlasse(String pfad) {
|
||||
Parser p = new Parser();
|
||||
ClassTyped classTyped = p.parseCode(ReadIn.read(pfad), assumptionsGlobal);
|
||||
TPHwithClass tph = new TPHwithClass();
|
||||
tph.classTyped = classTyped;
|
||||
assumptionsGlobal.put("$" + classTyped.getaClass().getName() , tph);
|
||||
System.out.println(classTyped.toCodeTyped());
|
||||
results.add(classTyped);
|
||||
}
|
||||
}
|
36
src/control/source.javLight
Normal file
36
src/control/source.javLight
Normal file
@ -0,0 +1,36 @@
|
||||
class A {
|
||||
mt(x,y,z) { return x.sub(y).add(z) ;}
|
||||
}
|
||||
|
||||
|
||||
class B {
|
||||
add(a,b,c) {return a.add(); }
|
||||
}
|
||||
|
||||
class BB {
|
||||
add(a,b,c) {return a.add(a.b); }
|
||||
}
|
||||
|
||||
|
||||
class BBB {
|
||||
add(a,b,c) {return a.add(a..b, a..c); }
|
||||
}
|
||||
|
||||
|
||||
class Main {
|
||||
main() { return new A(); }
|
||||
}
|
||||
|
||||
|
||||
class Myinteger {
|
||||
Myinteger i;
|
||||
add(x) { return new Myinteger(x.i);}
|
||||
sub(x) { return new Myinteger(x.i);}
|
||||
}
|
||||
|
||||
|
||||
class Main {
|
||||
main() { return new A<>().mt(x,y,z); }
|
||||
}
|
||||
|
||||
|
4
src/control/source2.javLight
Normal file
4
src/control/source2.javLight
Normal file
@ -0,0 +1,4 @@
|
||||
class A {
|
||||
mt(x,y,z) { return x.sub(y).add(z.div(x,x)) ;}
|
||||
}
|
||||
|
4
src/control/source3.javLight
Normal file
4
src/control/source3.javLight
Normal file
@ -0,0 +1,4 @@
|
||||
class A {
|
||||
mt(x,y,z) { return x.sub(y).add(z) ;}
|
||||
}
|
||||
|
4
src/control/sourceNew.javLight
Normal file
4
src/control/sourceNew.javLight
Normal file
@ -0,0 +1,4 @@
|
||||
class Main {
|
||||
main() { return new A<>().mt( new MI() ) ;}
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
package de.dhbwstuttgart.strucTypes4.Algo;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 09.04.17.
|
||||
*/
|
||||
public abstract class ConstraintAbstract {
|
||||
|
||||
|
||||
public abstract void replace(TPH old , TPH neu);
|
||||
|
||||
public Set<TPH> getAllTPH() {
|
||||
System.err.println("Nicht vorgesehen");
|
||||
Set<TPH> leereMenge = new HashSet<>();
|
||||
return leereMenge;
|
||||
}
|
||||
|
||||
public Set<TPH> getAllReceiver() {
|
||||
System.err.println("Nicht vorgesehen");
|
||||
Set<TPH> leereMenge = new HashSet<>();
|
||||
return leereMenge;
|
||||
}
|
||||
|
||||
|
||||
}
|
53
src/de/dhbwstuttgart/strucTypes4/Algo/ConstraintField.java
Normal file
53
src/de/dhbwstuttgart/strucTypes4/Algo/ConstraintField.java
Normal file
@ -0,0 +1,53 @@
|
||||
package de.dhbwstuttgart.strucTypes4.Algo;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 09.04.17.
|
||||
*/
|
||||
public class ConstraintField extends ConstraintAbstract {
|
||||
|
||||
TPH receiver;
|
||||
String nameField;
|
||||
TPH caller;
|
||||
|
||||
public ConstraintField(TPH receiver, String nameField, TPH caller) {
|
||||
this.receiver = receiver;
|
||||
this.nameField = nameField;
|
||||
this.caller = caller;
|
||||
}
|
||||
|
||||
public TPH getReceiver() {
|
||||
return receiver;
|
||||
}
|
||||
|
||||
public void setReceiver(TPH receiver) {
|
||||
this.receiver = receiver;
|
||||
}
|
||||
|
||||
public TPH getCaller() {
|
||||
return caller;
|
||||
}
|
||||
|
||||
public void setCaller(TPH caller) {
|
||||
this.caller = caller;
|
||||
}
|
||||
|
||||
public String getNameField() {
|
||||
return nameField;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(" ConstField( %s , %s , %s ) " , receiver , nameField ,caller);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void replace(TPH old, TPH neu) {
|
||||
System.err.println("Nicht Implementiert");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
46
src/de/dhbwstuttgart/strucTypes4/Algo/ConstraintGleich.java
Normal file
46
src/de/dhbwstuttgart/strucTypes4/Algo/ConstraintGleich.java
Normal file
@ -0,0 +1,46 @@
|
||||
package de.dhbwstuttgart.strucTypes4.Algo;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 09.04.17.
|
||||
*/
|
||||
public class ConstraintGleich extends ConstraintAbstract{
|
||||
|
||||
TPH typeA;
|
||||
TPH typeB;
|
||||
|
||||
public ConstraintGleich(TPH typeA, TPH typeB) {
|
||||
this.typeA = typeA;
|
||||
this.typeB = typeB;
|
||||
}
|
||||
|
||||
public TPH getTypeA() {
|
||||
return typeA;
|
||||
}
|
||||
|
||||
public void setTypeA(TPH typeA) {
|
||||
this.typeA = typeA;
|
||||
}
|
||||
|
||||
public TPH getTypeB() {
|
||||
return typeB;
|
||||
}
|
||||
|
||||
public void setTypeB(TPH typeB) {
|
||||
this.typeB = typeB;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format( "ConsGleich: ( %s == %s ) " , typeA, typeB );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void replace(TPH old, TPH neu) {
|
||||
System.err.println("Nicht Implementiert");
|
||||
}
|
||||
|
||||
}
|
90
src/de/dhbwstuttgart/strucTypes4/Algo/ConstraintMethod.java
Normal file
90
src/de/dhbwstuttgart/strucTypes4/Algo/ConstraintMethod.java
Normal file
@ -0,0 +1,90 @@
|
||||
package de.dhbwstuttgart.strucTypes4.Algo;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 09.04.17.
|
||||
*/
|
||||
public class ConstraintMethod extends ConstraintAbstract {
|
||||
|
||||
TPH receiver;
|
||||
String methodName;
|
||||
List<TPH> argsTypes;
|
||||
TPH returnType;
|
||||
List<TPH> argsBetaTypes;
|
||||
|
||||
public ConstraintMethod(TPH receiver, String methodName, List<TPH> argsTypes, TPH returnType, List<TPH> argsBetaTypes) {
|
||||
this.receiver = receiver;
|
||||
this.methodName = methodName;
|
||||
this.argsTypes = argsTypes;
|
||||
this.returnType = returnType;
|
||||
this.argsBetaTypes = argsBetaTypes;
|
||||
}
|
||||
|
||||
|
||||
public TPH getReceiver() {
|
||||
return receiver;
|
||||
}
|
||||
|
||||
public void setReceiver(TPH receiver) {
|
||||
this.receiver = receiver;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return methodName;
|
||||
}
|
||||
|
||||
public void setMethodName(String methodName) {
|
||||
this.methodName = methodName;
|
||||
}
|
||||
|
||||
public List<TPH> getArgsTypes() {
|
||||
return argsTypes;
|
||||
}
|
||||
|
||||
public void setArgsTypes(List<TPH> argsTypes) {
|
||||
this.argsTypes = argsTypes;
|
||||
}
|
||||
|
||||
public TPH getReturnType() {
|
||||
return returnType;
|
||||
}
|
||||
|
||||
public void setReturnType(TPH returnType) {
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
public List<TPH> getArgsBetaTypes() {
|
||||
return argsBetaTypes;
|
||||
}
|
||||
|
||||
public void setArgsBetaTypes(List<TPH> argsBetaTypes) {
|
||||
this.argsBetaTypes = argsBetaTypes;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(" Const Method( %s , %s , %s , ( %s , %s ))" , receiver, methodName , argsTypes , returnType , argsBetaTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(TPH old, TPH neu) {
|
||||
System.err.println("Nicht Implementiert");
|
||||
}
|
||||
|
||||
|
||||
public Set<TPH> getAllReceiver() {
|
||||
Set<TPH> leereMenge = new HashSet<>();
|
||||
leereMenge.add(receiver);
|
||||
return leereMenge;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
69
src/de/dhbwstuttgart/strucTypes4/Algo/ConstraintSubType.java
Normal file
69
src/de/dhbwstuttgart/strucTypes4/Algo/ConstraintSubType.java
Normal file
@ -0,0 +1,69 @@
|
||||
package de.dhbwstuttgart.strucTypes4.Algo;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 09.04.17.
|
||||
*/
|
||||
public class ConstraintSubType extends ConstraintAbstract {
|
||||
|
||||
TPH typeKleiner;
|
||||
TPH typeGroeßer;
|
||||
|
||||
public ConstraintSubType(TPH typeKleiner, TPH typeGroeßer) {
|
||||
this.typeKleiner = typeKleiner;
|
||||
this.typeGroeßer = typeGroeßer;
|
||||
}
|
||||
|
||||
|
||||
public void replace(TPH old, TPH neu) {
|
||||
if (typeKleiner.equals(old)) {
|
||||
typeKleiner = neu;
|
||||
}
|
||||
if (typeGroeßer.equals(old)) {
|
||||
typeGroeßer = neu;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TPH> getAllTPH() {
|
||||
Set<TPH> tphs = new HashSet<>();
|
||||
tphs.add(typeGroeßer);
|
||||
tphs.add(typeKleiner);
|
||||
return tphs;
|
||||
}
|
||||
|
||||
public TPH getTypeKleiner() {
|
||||
return typeKleiner;
|
||||
}
|
||||
|
||||
public void setTypeKleiner(TPH typeKleiner) {
|
||||
this.typeKleiner = typeKleiner;
|
||||
}
|
||||
|
||||
public TPH getTypeGroeßer() {
|
||||
return typeGroeßer;
|
||||
}
|
||||
|
||||
public void setTypeGroeßer(TPH typeGroeßer) {
|
||||
this.typeGroeßer = typeGroeßer;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format( "Const_Sub: ( %s <* %s ) " , typeKleiner , typeGroeßer );
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Set<TPH> getAllReceiver() {
|
||||
Set<TPH> leereMenge = new HashSet<>();
|
||||
leereMenge.add(getTypeKleiner());
|
||||
return leereMenge;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package de.dhbwstuttgart.strucTypes4.Algo;
|
||||
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 11.04.17.
|
||||
*/
|
||||
public class ConstraintSubTypeInterface extends ConstraintAbstract{
|
||||
|
||||
TPH kleiner;
|
||||
List<TPH> größer;
|
||||
String nameInterface;
|
||||
|
||||
public ConstraintSubTypeInterface(TPH kleiner, List<TPH> größer , String nameInterface) {
|
||||
this.kleiner = kleiner;
|
||||
this.größer = größer;
|
||||
this.nameInterface = nameInterface;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<TPH> getAllTPH() {
|
||||
Set<TPH> tphs = new HashSet<>();
|
||||
tphs.add(kleiner);
|
||||
tphs.addAll(größer);
|
||||
return tphs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(TPH old, TPH neu) {
|
||||
if (kleiner.equals(old)) {
|
||||
kleiner = neu;
|
||||
}
|
||||
|
||||
for (int i = 0 ; i < größer.size() ; i++) {
|
||||
if (größer.get(i).equals(old)) {
|
||||
größer.remove(i);
|
||||
größer.add(i,neu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConstraintSubTypeInterface{" + kleiner + "<* " + nameInterface + "<" + größer +">";
|
||||
}
|
||||
|
||||
|
||||
public Set<TPH> getAllReceiver() {
|
||||
Set<TPH> leereMenge = new HashSet<>();
|
||||
leereMenge.add(kleiner);
|
||||
return leereMenge;
|
||||
}
|
||||
|
||||
}
|
||||
|
216
src/de/dhbwstuttgart/strucTypes4/Algo/Construct.java
Normal file
216
src/de/dhbwstuttgart/strucTypes4/Algo/Construct.java
Normal file
@ -0,0 +1,216 @@
|
||||
package de.dhbwstuttgart.strucTypes4.Algo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.*;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPHFactory;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 09.04.17.
|
||||
*/
|
||||
public class Construct {
|
||||
|
||||
List<ConstraintAbstract> resultConstraints = new ArrayList<>();
|
||||
List<Interface> resultInterfaces = new ArrayList<>();
|
||||
|
||||
|
||||
// Mapping der alten Typvariablen zu neuen
|
||||
private Map<TPH,TPH> altZuNeuTPH = new HashMap<>();
|
||||
private String nameInterface = "";
|
||||
|
||||
|
||||
|
||||
|
||||
public Construct(List<ConstraintAbstract> constraints ) {
|
||||
constructInterfacesSortet(constraints);
|
||||
}
|
||||
|
||||
|
||||
private void constructInterfacesSortet(List<ConstraintAbstract> constraints) {
|
||||
|
||||
Map<TPH, List<ConstraintAbstract>> sortetConst = sortiereConstraints(constraints);
|
||||
|
||||
resultInterfaces = new ArrayList<>();
|
||||
|
||||
// Erstelle Interfaces und Neue Subtype Constraints
|
||||
for (TPH key : sortetConst.keySet() ) {
|
||||
ConstructInterfaceForType constructInterfaceForType = new ConstructInterfaceForType(sortetConst.get(key) , altZuNeuTPH);
|
||||
resultInterfaces.addAll(constructInterfaceForType.resultInterfaces);
|
||||
resultConstraints.addAll(constructInterfaceForType.subTypeconstraints);
|
||||
}
|
||||
|
||||
|
||||
// KopiereSubconstraints
|
||||
for (ConstraintAbstract c: constraints ) {
|
||||
if (c.getClass().equals(ConstraintSubType.class)) {
|
||||
resultConstraints.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
// Kopiere ConstraintSubTypeInterface
|
||||
for (ConstraintAbstract c: constraints) {
|
||||
if (c.getClass().equals(ConstraintSubTypeInterface.class)) {
|
||||
resultConstraints.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private Map<TPH,List<ConstraintAbstract>> sortiereConstraints(List<ConstraintAbstract> constraints) {
|
||||
|
||||
Map<TPH,List<ConstraintAbstract>> constraintMap = new ConcurrentHashMap<>();
|
||||
|
||||
for (ConstraintAbstract con : constraints) {
|
||||
|
||||
TPH receiver = null;
|
||||
|
||||
// Suche den Receiver der Metohde oder des Feldes
|
||||
if (con.getClass().equals(ConstraintMethod.class)) {
|
||||
ConstraintMethod cm = (ConstraintMethod) con;
|
||||
receiver = cm.getReceiver();
|
||||
}
|
||||
else if (con.getClass().equals(ConstraintField.class)) {
|
||||
ConstraintField cf = (ConstraintField) con;
|
||||
receiver = cf.getReceiver();
|
||||
}
|
||||
|
||||
|
||||
// wenn Receiver vorhanden -> füge ihn in die Map ein;
|
||||
if (receiver != null ) {
|
||||
if (constraintMap.containsKey(receiver)) {
|
||||
constraintMap.get(receiver).add(con);
|
||||
}
|
||||
else {
|
||||
List<ConstraintAbstract> clist = new ArrayList<>();
|
||||
clist.add(con);
|
||||
constraintMap.put(receiver,clist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return constraintMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public List<ConstraintAbstract> getResultConstraints() {
|
||||
return resultConstraints;
|
||||
}
|
||||
|
||||
public void setResultConstraints(List<ConstraintAbstract> resultConstraints) {
|
||||
this.resultConstraints = resultConstraints;
|
||||
}
|
||||
|
||||
public List<Interface> getResultInterfaces() {
|
||||
return resultInterfaces;
|
||||
}
|
||||
|
||||
public void setResultInterfaces(List<Interface> resultInterfaces) {
|
||||
this.resultInterfaces = resultInterfaces;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class ConstructInterfaceForType {
|
||||
|
||||
List<Interface> resultInterfaces = new ArrayList<>();
|
||||
List<ConstraintAbstract> subTypeconstraints = new ArrayList<>();
|
||||
Map<TPH,TPH> altZuNeuTPH;
|
||||
|
||||
public ConstructInterfaceForType(List<ConstraintAbstract> cons , Map<TPH,TPH> altZuNeu ) {
|
||||
this.altZuNeuTPH = altZuNeu;
|
||||
constructInterfaces(cons);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void constructInterfaces(List<ConstraintAbstract> constraints) {
|
||||
|
||||
List<MethodInterface> mlist = new ArrayList<>();
|
||||
List<FieldInterface> flist = new ArrayList<>();
|
||||
List<TPH> generics = new ArrayList<>();
|
||||
String nameInterface = "";
|
||||
|
||||
|
||||
// generate Interface Fields
|
||||
for (ConstraintAbstract c : constraints) {
|
||||
|
||||
if (c.getClass().equals(ConstraintField.class)) {
|
||||
ConstraintField constraintField = (ConstraintField) c;
|
||||
|
||||
FieldInterface field = new FieldInterface(changeTPH(constraintField.getCaller()),constraintField.nameField);
|
||||
flist.add(field);
|
||||
|
||||
nameInterface = nameInterface.concat(constraintField.nameField);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// generate Interface Methods // Wichtig ist es die Typvariablen in den Methoden auszutauschnen
|
||||
for (ConstraintAbstract c : constraints) {
|
||||
if (c.getClass().equals(ConstraintMethod.class)) {
|
||||
ConstraintMethod constraintMethod = (ConstraintMethod) c;
|
||||
|
||||
// Erstelle generics (erster ist return, alle weitere Arg der Methode
|
||||
//
|
||||
generics.add(changeTPH(constraintMethod.returnType));
|
||||
generics.addAll(changeTPHList(constraintMethod.argsBetaTypes));
|
||||
|
||||
|
||||
MethodInterface methodInterface = new MethodInterface(constraintMethod.methodName , changeTPH(constraintMethod.returnType) , changeTPHList(constraintMethod.argsBetaTypes));
|
||||
mlist.add(methodInterface);
|
||||
|
||||
nameInterface = nameInterface + constraintMethod.getMethodName() ;
|
||||
|
||||
// Ergebnis Subtype Relation
|
||||
List<TPH> genericsFuerConstraint = new ArrayList<>();
|
||||
genericsFuerConstraint.add(constraintMethod.returnType);
|
||||
genericsFuerConstraint.addAll(constraintMethod.argsBetaTypes);
|
||||
subTypeconstraints.add(new ConstraintSubTypeInterface( constraintMethod.getReceiver(), genericsFuerConstraint, "Type"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Ergebnis Interface
|
||||
Interface anInterface = new Interface(nameInterface, flist , mlist, generics);
|
||||
resultInterfaces.add(anInterface);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private TPH changeTPH(TPH alt) {
|
||||
if (altZuNeuTPH.containsKey(alt)) {
|
||||
return altZuNeuTPH.get(alt);
|
||||
}
|
||||
else {
|
||||
altZuNeuTPH.put(alt, TPHFactory.makeTPH());
|
||||
return altZuNeuTPH.get(alt);
|
||||
}
|
||||
}
|
||||
|
||||
private List<TPH> changeTPHList(List<TPH> list) {
|
||||
List<TPH> list1 = new ArrayList<>();
|
||||
list.forEach((x) -> list1.add(changeTPH(x)));
|
||||
return list1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
package de.dhbwstuttgart.strucTypes4.Algo;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.Algo.*;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPHFactory;
|
||||
|
||||
public class FrischeVariablenGenerator {
|
||||
|
||||
public List<ConstraintAbstract> neueConstraints;
|
||||
public Map<TPH,InformationTuple> mapping;
|
||||
|
||||
|
||||
public boolean createWithoutAssumptions(List<ConstraintAbstract> constraints) {
|
||||
Map<String,TPH> assDummy = new HashMap<>();
|
||||
create(constraints,assDummy);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean create(List<ConstraintAbstract> constraints, Map<String,TPH> assumptions) {
|
||||
|
||||
List<InformationTuple> tuples = new ArrayList<>();
|
||||
|
||||
List<List<TPH>> gruppen = this.sucheGleichConstriants(constraints);
|
||||
|
||||
// um anschaulich zu bleiben anders sortieren
|
||||
Collections.reverse(gruppen);
|
||||
|
||||
|
||||
// Löse Gleichconstraints auf
|
||||
for (List<TPH> gruppe : gruppen ) {
|
||||
String varname = "";
|
||||
for (String key : assumptions.keySet() ) {
|
||||
if (gruppe.contains(assumptions.get(key))) {
|
||||
varname = key;
|
||||
}
|
||||
}
|
||||
InformationTuple tuple = new InformationTuple(TPHFactory.makeTPHV(), gruppe , "" ,varname );
|
||||
tuples.add(tuple);
|
||||
}
|
||||
|
||||
// Für Zuordnung der neuen Typvariablen zu den alten -> duppelte Einträge werden entfernt
|
||||
Map<TPH,InformationTuple> mapping = new HashMap<>();
|
||||
for (InformationTuple i : tuples) {
|
||||
for (TPH tph : i.getAlteTypeVar()) {
|
||||
mapping.put(tph,i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Erstelle neue Constriants mit frischen Variablen
|
||||
ArrayList<ConstraintAbstract> neueConstraintAbstracts = new ArrayList<>();
|
||||
|
||||
for (ConstraintAbstract c : constraints) {
|
||||
|
||||
if (c.getClass().equals(ConstraintField.class)) {
|
||||
ConstraintField cf = (ConstraintField) c;
|
||||
ConstraintField newCf = new ConstraintField( addNewTPHV(cf.getCaller(),mapping), cf.getNameField() , addNewTPHV(cf.getReceiver() , mapping ));
|
||||
neueConstraintAbstracts.add(newCf);
|
||||
}
|
||||
else if (c.getClass().equals(ConstraintMethod.class)) {
|
||||
ConstraintMethod cm = (ConstraintMethod) c;
|
||||
ConstraintMethod newCm = new ConstraintMethod(addNewTPHV(cm.getReceiver(),mapping) , cm.getMethodName() , addNewTPHV(cm.getArgsTypes(),mapping) , addNewTPHV(cm.getReturnType(),mapping) , addNewTPHV(cm.getArgsBetaTypes(),mapping));
|
||||
neueConstraintAbstracts.add(newCm);
|
||||
}
|
||||
else if (c.getClass().equals(ConstraintSubType.class)) {
|
||||
ConstraintSubType cs = (ConstraintSubType) c;
|
||||
ConstraintSubType newCs = new ConstraintSubType(addNewTPHV(cs.getTypeKleiner(),mapping), addNewTPHV(cs.getTypeGroeßer(),mapping));
|
||||
neueConstraintAbstracts.add(newCs);
|
||||
}
|
||||
}
|
||||
|
||||
// Setze Result
|
||||
this.mapping = mapping;
|
||||
this.neueConstraints = neueConstraintAbstracts;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Neuer TPHV wird erstellt wenn TPH noch nicht vorhanden ist. Ansonsten wird bereits vergebener Wert zurückgegeben
|
||||
*/
|
||||
public TPH addNewTPHV(TPH old, Map<TPH,InformationTuple> mapping) {
|
||||
if (mapping.containsKey(old)) {
|
||||
return mapping.get(old).getNewTV();
|
||||
}
|
||||
else {
|
||||
List<TPH> oldlist = new ArrayList<>();
|
||||
oldlist.add(old);
|
||||
mapping.put(old, new InformationTuple(TPHFactory.makeTPHV(), oldlist , "" ,""));
|
||||
System.out.println(mapping.size());
|
||||
return mapping.get(old).getNewTV();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<TPH> addNewTPHV(List<TPH> old, Map<TPH,InformationTuple> mapping) {
|
||||
List<TPH> neueTPH = new ArrayList<>();
|
||||
for (TPH o : old) {
|
||||
neueTPH.add(addNewTPHV(o,mapping));
|
||||
}
|
||||
return neueTPH;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public List<List<TPH>> sucheGleichConstriants(List<ConstraintAbstract> constraints) {
|
||||
|
||||
List<List<TPH>> tph = new ArrayList<>();
|
||||
|
||||
List<ConstraintGleich> gleichConstraints = new ArrayList<>();
|
||||
|
||||
// Liste aller Gleichconstriants
|
||||
for (ConstraintAbstract constriant : constraints) {
|
||||
if (constriant.getClass().equals(ConstraintGleich.class)) {
|
||||
ConstraintGleich gc = (ConstraintGleich) constriant;
|
||||
gleichConstraints.add(gc);
|
||||
}
|
||||
}
|
||||
|
||||
// auflösen der Gleichconstraints
|
||||
for (ConstraintGleich gc : gleichConstraints) {
|
||||
List<TPH> a = getGleicheTPH(gc.getTypeB(),gleichConstraints);
|
||||
List<TPH> b = getGleicheTPH(gc.getTypeA(),gleichConstraints);
|
||||
a.addAll(b);
|
||||
tph.add(b);
|
||||
|
||||
}
|
||||
return tph;
|
||||
}
|
||||
|
||||
|
||||
// Gibt eine liste zurück die gleiche TPH enthält
|
||||
public List<TPH> getGleicheTPH(TPH x, List<ConstraintGleich> menge) {
|
||||
|
||||
List<TPH> tphlist = new ArrayList<>();
|
||||
tphlist.add(x);
|
||||
|
||||
for (ConstraintGleich gc : menge) {
|
||||
if (gc.getTypeA().equals(x)) {
|
||||
tphlist.add(gc.getTypeA());
|
||||
|
||||
// Rek. Aufuf
|
||||
List<ConstraintGleich> menge2 = new ArrayList<>();
|
||||
menge2.addAll(menge);
|
||||
menge2.remove(gc);
|
||||
tphlist.addAll(getGleicheTPH(gc.getTypeB() , menge2));
|
||||
}
|
||||
|
||||
if (gc.getTypeB().equals(x)) {
|
||||
tphlist.add(gc.getTypeB());
|
||||
|
||||
// Rek. Aufuf
|
||||
List<ConstraintGleich> menge2 = new ArrayList<>();
|
||||
menge2.addAll(menge);
|
||||
menge2.remove(gc);
|
||||
tphlist.addAll(getGleicheTPH(gc.getTypeA() , menge2));
|
||||
}
|
||||
}
|
||||
return tphlist;
|
||||
}
|
||||
}
|
||||
|
66
src/de/dhbwstuttgart/strucTypes4/Algo/InformationTuple.java
Normal file
66
src/de/dhbwstuttgart/strucTypes4/Algo/InformationTuple.java
Normal file
@ -0,0 +1,66 @@
|
||||
package de.dhbwstuttgart.strucTypes4.Algo;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
public class InformationTuple {
|
||||
|
||||
TPH newTV;
|
||||
List<TPH> alteTypeVar;
|
||||
String bekannterType;
|
||||
String bekannterVarName;
|
||||
|
||||
|
||||
public InformationTuple(TPH newTV, List<TPH> alteTypeVar, String bekannterType, String bekannterVarName) {
|
||||
this.newTV = newTV;
|
||||
this.alteTypeVar = alteTypeVar;
|
||||
this.bekannterType = bekannterType;
|
||||
this.bekannterVarName = bekannterVarName;
|
||||
}
|
||||
|
||||
public TPH getNewTV() {
|
||||
return newTV;
|
||||
}
|
||||
|
||||
public void setNewTV(TPH newTV) {
|
||||
this.newTV = newTV;
|
||||
}
|
||||
|
||||
public List<TPH> getAlteTypeVar() {
|
||||
return alteTypeVar;
|
||||
}
|
||||
|
||||
public void setAlteTypeVar(List<TPH> alteTypeVar) {
|
||||
this.alteTypeVar = alteTypeVar;
|
||||
}
|
||||
|
||||
public String getBekannterType() {
|
||||
return bekannterType;
|
||||
}
|
||||
|
||||
public void setBekannterType(String bekannterType) {
|
||||
this.bekannterType = bekannterType;
|
||||
}
|
||||
|
||||
public String getBekannterVarName() {
|
||||
return bekannterVarName;
|
||||
}
|
||||
|
||||
public void setBekannterVarName(String bekannterVarName) {
|
||||
this.bekannterVarName = bekannterVarName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InformationTuple{" +
|
||||
"newTV=" + newTV +
|
||||
", alteTypeVar=" + alteTypeVar +
|
||||
", bekannterType='" + bekannterType + '\'' +
|
||||
", bekannterVarName='" + bekannterVarName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
7
src/de/dhbwstuttgart/strucTypes4/Algo/MakeAss.java
Normal file
7
src/de/dhbwstuttgart/strucTypes4/Algo/MakeAss.java
Normal file
@ -0,0 +1,7 @@
|
||||
package de.dhbwstuttgart.strucTypes4.Algo;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 08.04.17.
|
||||
*/
|
||||
public class MakeAss {
|
||||
}
|
82
src/de/dhbwstuttgart/strucTypes4/Algo/TypeExpr.java
Normal file
82
src/de/dhbwstuttgart/strucTypes4/Algo/TypeExpr.java
Normal file
@ -0,0 +1,82 @@
|
||||
package de.dhbwstuttgart.strucTypes4.Algo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.*;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPHwithClass;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 09.04.17.
|
||||
*/
|
||||
public class TypeExpr {
|
||||
|
||||
public static List<ConstraintAbstract> typeExpr(ExpressionAbstract exp, Map<String, TPH> ass , TPH rec , TPH returnType) {
|
||||
|
||||
if (exp.getClass().equals(ExprVar.class )) {
|
||||
ExprVar exprVar = (ExprVar) exp;
|
||||
return exprVar.typeExpr(ass);
|
||||
}
|
||||
else if (exp.getClass().equals(ExprMCall.class)) {
|
||||
ExprMCall exprMCall = (ExprMCall) exp;
|
||||
return exprMCall.typeExpr(ass, rec ,returnType);
|
||||
}
|
||||
else if ( exp.getClass().equals(ExprField.class)) {
|
||||
ExprField exprField = (ExprField) exp;
|
||||
List<ConstraintAbstract> constraints = new ArrayList<>();
|
||||
constraints.add(new ConstraintField(rec,exprField.getNameField(), returnType));
|
||||
return constraints;
|
||||
|
||||
}
|
||||
else if (exp.getClass().equals(Expression.class)) {
|
||||
Expression expression = (Expression) exp;
|
||||
List<ConstraintAbstract> constraints = new ArrayList<>();
|
||||
constraints.addAll(typeExpr(expression.getReceiver(), ass, null ,null ));
|
||||
constraints.addAll(typeExpr(expression.getCaller(),ass, expression.getReceiver().typePlaceHolder , expression.typePlaceHolder ));
|
||||
return constraints;
|
||||
}
|
||||
else if (exp.getClass().equals(ExprNew.class) ) {
|
||||
|
||||
ExprNew exprNew = (ExprNew) exp;
|
||||
List<ConstraintAbstract> constriants = new ArrayList<>();
|
||||
|
||||
System.out.println(exprNew.getGenerics().toString());
|
||||
|
||||
String klassenname = exprNew.getClassType();
|
||||
String key = new String("$" + klassenname);
|
||||
TPH tph = ass.get(key);
|
||||
|
||||
|
||||
if (ass.containsKey(key)) {
|
||||
|
||||
|
||||
TPHwithClass tpHwithClass = (TPHwithClass) tph;
|
||||
System.out.println("set Class" + exprNew.typePlaceHolder.toString());
|
||||
exprNew.typePlaceHolder.setType(tpHwithClass.classTyped);
|
||||
constriants.addAll(tpHwithClass.classTyped.getConstraints());
|
||||
|
||||
|
||||
// Ersetzen der Generics
|
||||
Map<String,String> generic = exprNew.getGenerics();
|
||||
for (String gen : generic.keySet()) {
|
||||
constriants.forEach((ConstraintAbstract cs) -> cs.replace(new TPH(gen) , new TPH(generic.get(gen)) ));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
// Rückgabe der Leeren Constraints
|
||||
// ToDo (grenze des programms)
|
||||
exprNew.typePlaceHolder.setType(new ClassTyped(klassenname));
|
||||
|
||||
return constriants;
|
||||
}
|
||||
return constriants;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
29
src/de/dhbwstuttgart/strucTypes4/grammar/FWJ.tokens
Normal file
29
src/de/dhbwstuttgart/strucTypes4/grammar/FWJ.tokens
Normal file
@ -0,0 +1,29 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
T__7=8
|
||||
T__8=9
|
||||
T__9=10
|
||||
T__10=11
|
||||
T__11=12
|
||||
Class=13
|
||||
Token2=14
|
||||
Linefeed=15
|
||||
WS=16
|
||||
'{'=1
|
||||
'}'=2
|
||||
';'=3
|
||||
'<'=4
|
||||
','=5
|
||||
'>'=6
|
||||
'='=7
|
||||
'('=8
|
||||
')'=9
|
||||
'return'=10
|
||||
'.'=11
|
||||
'new'=12
|
||||
'class'=13
|
218
src/de/dhbwstuttgart/strucTypes4/grammar/FWJBaseListener.java
Normal file
218
src/de/dhbwstuttgart/strucTypes4/grammar/FWJBaseListener.java
Normal file
@ -0,0 +1,218 @@
|
||||
package de.dhbwstuttgart.strucTypes4.grammar;// Generated from /home/sebastian/Schreibtisch/FLJava/src/FWJ.g4 by ANTLR 4.6
|
||||
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
import org.antlr.v4.runtime.tree.ErrorNode;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
|
||||
/**
|
||||
* This class provides an empty implementation of {@link FWJListener},
|
||||
* which can be extended to create a listener which only needs to handle a subset
|
||||
* of the available methods.
|
||||
*/
|
||||
public class FWJBaseListener implements FWJListener {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterSourceFile(FWJParser.SourceFileContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitSourceFile(FWJParser.SourceFileContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterClassX(FWJParser.ClassXContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitClassX(FWJParser.ClassXContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFeld(FWJParser.FeldContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFeld(FWJParser.FeldContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterGenerics(FWJParser.GenericsContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitGenerics(FWJParser.GenericsContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterGeneric(FWJParser.GenericContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitGeneric(FWJParser.GenericContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterMethodDecl(FWJParser.MethodDeclContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitMethodDecl(FWJParser.MethodDeclContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterMethodDeclArgs(FWJParser.MethodDeclArgsContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitMethodDeclArgs(FWJParser.MethodDeclArgsContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterReturnExpr(FWJParser.ReturnExprContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitReturnExpr(FWJParser.ReturnExprContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterExprMCall(FWJParser.ExprMCallContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitExprMCall(FWJParser.ExprMCallContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterExprVar(FWJParser.ExprVarContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitExprVar(FWJParser.ExprVarContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterExprField(FWJParser.ExprFieldContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitExprField(FWJParser.ExprFieldContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterExprNew(FWJParser.ExprNewContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitExprNew(FWJParser.ExprNewContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterExpr(FWJParser.ExprContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitExpr(FWJParser.ExprContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterExprMCallArgs(FWJParser.ExprMCallArgsContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitExprMCallArgs(FWJParser.ExprMCallArgsContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterBezeichner(FWJParser.BezeichnerContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitBezeichner(FWJParser.BezeichnerContext ctx) { }
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterEveryRule(ParserRuleContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitEveryRule(ParserRuleContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void visitTerminal(TerminalNode node) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void visitErrorNode(ErrorNode node) { }
|
||||
}
|
118
src/de/dhbwstuttgart/strucTypes4/grammar/FWJBaseVisitor.java
Normal file
118
src/de/dhbwstuttgart/strucTypes4/grammar/FWJBaseVisitor.java
Normal file
@ -0,0 +1,118 @@
|
||||
package de.dhbwstuttgart.strucTypes4.grammar;// Generated from /home/sebastian/Schreibtisch/FLJava/src/FWJ.g4 by ANTLR 4.6
|
||||
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
|
||||
|
||||
/**
|
||||
* This class provides an empty implementation of {@link FWJVisitor},
|
||||
* which can be extended to create a visitor which only needs to handle a subset
|
||||
* of the available methods.
|
||||
*
|
||||
* @param <T> The return type of the visit operation. Use {@link Void} for
|
||||
* operations with no return type.
|
||||
*/
|
||||
public class FWJBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements FWJVisitor<T> {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitSourceFile(FWJParser.SourceFileContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitClassX(FWJParser.ClassXContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitFeld(FWJParser.FeldContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitGenerics(FWJParser.GenericsContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitGeneric(FWJParser.GenericContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitMethodDecl(FWJParser.MethodDeclContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitMethodDeclArgs(FWJParser.MethodDeclArgsContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitReturnExpr(FWJParser.ReturnExprContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitExprMCall(FWJParser.ExprMCallContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitExprVar(FWJParser.ExprVarContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitExprField(FWJParser.ExprFieldContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitExprNew(FWJParser.ExprNewContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitExpr(FWJParser.ExprContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitExprMCallArgs(FWJParser.ExprMCallArgsContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitBezeichner(FWJParser.BezeichnerContext ctx) { return visitChildren(ctx); }
|
||||
}
|
125
src/de/dhbwstuttgart/strucTypes4/grammar/FWJLexer.java
Normal file
125
src/de/dhbwstuttgart/strucTypes4/grammar/FWJLexer.java
Normal file
@ -0,0 +1,125 @@
|
||||
package de.dhbwstuttgart.strucTypes4.grammar;// Generated from /home/sebastian/Schreibtisch/FLJava/src/FWJ.g4 by ANTLR 4.6
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.atn.*;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.*;
|
||||
|
||||
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
|
||||
public class FWJLexer extends Lexer {
|
||||
static { RuntimeMetaData.checkVersion("4.6", RuntimeMetaData.VERSION); }
|
||||
|
||||
protected static final DFA[] _decisionToDFA;
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
new PredictionContextCache();
|
||||
public static final int
|
||||
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
|
||||
T__9=10, T__10=11, T__11=12, Class=13, Token2=14, Linefeed=15, WS=16;
|
||||
public static String[] modeNames = {
|
||||
"DEFAULT_MODE"
|
||||
};
|
||||
|
||||
public static final String[] ruleNames = {
|
||||
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
|
||||
"T__9", "T__10", "T__11", "Class", "Token2", "Linefeed", "WS"
|
||||
};
|
||||
|
||||
private static final String[] _LITERAL_NAMES = {
|
||||
null, "'{'", "'}'", "';'", "'<'", "','", "'>'", "'='", "'('", "')'", "'return'",
|
||||
"'.'", "'new'", "'class'"
|
||||
};
|
||||
private static final String[] _SYMBOLIC_NAMES = {
|
||||
null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, "Class", "Token2", "Linefeed", "WS"
|
||||
};
|
||||
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #VOCABULARY} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String[] tokenNames;
|
||||
static {
|
||||
tokenNames = new String[_SYMBOLIC_NAMES.length];
|
||||
for (int i = 0; i < tokenNames.length; i++) {
|
||||
tokenNames[i] = VOCABULARY.getLiteralName(i);
|
||||
if (tokenNames[i] == null) {
|
||||
tokenNames[i] = VOCABULARY.getSymbolicName(i);
|
||||
}
|
||||
|
||||
if (tokenNames[i] == null) {
|
||||
tokenNames[i] = "<INVALID>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String[] getTokenNames() {
|
||||
return tokenNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Vocabulary getVocabulary() {
|
||||
return VOCABULARY;
|
||||
}
|
||||
|
||||
|
||||
public FWJLexer(CharStream input) {
|
||||
super(input);
|
||||
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGrammarFileName() { return "FWJ.g4"; }
|
||||
|
||||
@Override
|
||||
public String[] getRuleNames() { return ruleNames; }
|
||||
|
||||
@Override
|
||||
public String getSerializedATN() { return _serializedATN; }
|
||||
|
||||
@Override
|
||||
public String[] getModeNames() { return modeNames; }
|
||||
|
||||
@Override
|
||||
public ATN getATN() { return _ATN; }
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2\22[\b\1\4\2\t\2\4"+
|
||||
"\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+
|
||||
"\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\3\2\3\2\3"+
|
||||
"\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\b\3\b\3\t\3\t\3\n\3\n\3\13\3"+
|
||||
"\13\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3"+
|
||||
"\16\3\16\3\16\3\17\6\17J\n\17\r\17\16\17K\3\20\5\20O\n\20\3\20\3\20\3"+
|
||||
"\20\3\20\3\21\6\21V\n\21\r\21\16\21W\3\21\3\21\2\2\22\3\3\5\4\7\5\t\6"+
|
||||
"\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22\3\2\4"+
|
||||
"\6\2\62;C\\aac|\4\2\13\13\"\"]\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t"+
|
||||
"\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2"+
|
||||
"\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2"+
|
||||
"\37\3\2\2\2\2!\3\2\2\2\3#\3\2\2\2\5%\3\2\2\2\7\'\3\2\2\2\t)\3\2\2\2\13"+
|
||||
"+\3\2\2\2\r-\3\2\2\2\17/\3\2\2\2\21\61\3\2\2\2\23\63\3\2\2\2\25\65\3\2"+
|
||||
"\2\2\27<\3\2\2\2\31>\3\2\2\2\33B\3\2\2\2\35I\3\2\2\2\37N\3\2\2\2!U\3\2"+
|
||||
"\2\2#$\7}\2\2$\4\3\2\2\2%&\7\177\2\2&\6\3\2\2\2\'(\7=\2\2(\b\3\2\2\2)"+
|
||||
"*\7>\2\2*\n\3\2\2\2+,\7.\2\2,\f\3\2\2\2-.\7@\2\2.\16\3\2\2\2/\60\7?\2"+
|
||||
"\2\60\20\3\2\2\2\61\62\7*\2\2\62\22\3\2\2\2\63\64\7+\2\2\64\24\3\2\2\2"+
|
||||
"\65\66\7t\2\2\66\67\7g\2\2\678\7v\2\289\7w\2\29:\7t\2\2:;\7p\2\2;\26\3"+
|
||||
"\2\2\2<=\7\60\2\2=\30\3\2\2\2>?\7p\2\2?@\7g\2\2@A\7y\2\2A\32\3\2\2\2B"+
|
||||
"C\7e\2\2CD\7n\2\2DE\7c\2\2EF\7u\2\2FG\7u\2\2G\34\3\2\2\2HJ\t\2\2\2IH\3"+
|
||||
"\2\2\2JK\3\2\2\2KI\3\2\2\2KL\3\2\2\2L\36\3\2\2\2MO\7\17\2\2NM\3\2\2\2"+
|
||||
"NO\3\2\2\2OP\3\2\2\2PQ\7\f\2\2QR\3\2\2\2RS\b\20\2\2S \3\2\2\2TV\t\3\2"+
|
||||
"\2UT\3\2\2\2VW\3\2\2\2WU\3\2\2\2WX\3\2\2\2XY\3\2\2\2YZ\b\21\2\2Z\"\3\2"+
|
||||
"\2\2\6\2KNW\3\b\2\2";
|
||||
public static final ATN _ATN =
|
||||
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
|
||||
static {
|
||||
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
|
||||
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
|
||||
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
|
||||
}
|
||||
}
|
||||
}
|
29
src/de/dhbwstuttgart/strucTypes4/grammar/FWJLexer.tokens
Normal file
29
src/de/dhbwstuttgart/strucTypes4/grammar/FWJLexer.tokens
Normal file
@ -0,0 +1,29 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
T__7=8
|
||||
T__8=9
|
||||
T__9=10
|
||||
T__10=11
|
||||
T__11=12
|
||||
Class=13
|
||||
Token2=14
|
||||
Linefeed=15
|
||||
WS=16
|
||||
'{'=1
|
||||
'}'=2
|
||||
';'=3
|
||||
'<'=4
|
||||
','=5
|
||||
'>'=6
|
||||
'='=7
|
||||
'('=8
|
||||
')'=9
|
||||
'return'=10
|
||||
'.'=11
|
||||
'new'=12
|
||||
'class'=13
|
159
src/de/dhbwstuttgart/strucTypes4/grammar/FWJListener.java
Normal file
159
src/de/dhbwstuttgart/strucTypes4/grammar/FWJListener.java
Normal file
@ -0,0 +1,159 @@
|
||||
package de.dhbwstuttgart.strucTypes4.grammar;// Generated from /home/sebastian/Schreibtisch/FLJava/src/FWJ.g4 by ANTLR 4.6
|
||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||
|
||||
/**
|
||||
* This interface defines a complete listener for a parse tree produced by
|
||||
* {@link FWJParser}.
|
||||
*/
|
||||
public interface FWJListener extends ParseTreeListener {
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#sourceFile}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterSourceFile(FWJParser.SourceFileContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#sourceFile}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitSourceFile(FWJParser.SourceFileContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#classX}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterClassX(FWJParser.ClassXContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#classX}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitClassX(FWJParser.ClassXContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#feld}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFeld(FWJParser.FeldContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#feld}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFeld(FWJParser.FeldContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#generics}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterGenerics(FWJParser.GenericsContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#generics}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitGenerics(FWJParser.GenericsContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#generic}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterGeneric(FWJParser.GenericContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#generic}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitGeneric(FWJParser.GenericContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#methodDecl}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterMethodDecl(FWJParser.MethodDeclContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#methodDecl}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitMethodDecl(FWJParser.MethodDeclContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#methodDeclArgs}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterMethodDeclArgs(FWJParser.MethodDeclArgsContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#methodDeclArgs}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitMethodDeclArgs(FWJParser.MethodDeclArgsContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#returnExpr}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterReturnExpr(FWJParser.ReturnExprContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#returnExpr}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitReturnExpr(FWJParser.ReturnExprContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#exprMCall}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterExprMCall(FWJParser.ExprMCallContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#exprMCall}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitExprMCall(FWJParser.ExprMCallContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#exprVar}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterExprVar(FWJParser.ExprVarContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#exprVar}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitExprVar(FWJParser.ExprVarContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#exprField}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterExprField(FWJParser.ExprFieldContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#exprField}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitExprField(FWJParser.ExprFieldContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#exprNew}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterExprNew(FWJParser.ExprNewContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#exprNew}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitExprNew(FWJParser.ExprNewContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#expr}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterExpr(FWJParser.ExprContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#expr}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitExpr(FWJParser.ExprContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#exprMCallArgs}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterExprMCallArgs(FWJParser.ExprMCallArgsContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#exprMCallArgs}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitExprMCallArgs(FWJParser.ExprMCallArgsContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link FWJParser#bezeichner}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterBezeichner(FWJParser.BezeichnerContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link FWJParser#bezeichner}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitBezeichner(FWJParser.BezeichnerContext ctx);
|
||||
}
|
1196
src/de/dhbwstuttgart/strucTypes4/grammar/FWJParser.java
Normal file
1196
src/de/dhbwstuttgart/strucTypes4/grammar/FWJParser.java
Normal file
File diff suppressed because it is too large
Load Diff
102
src/de/dhbwstuttgart/strucTypes4/grammar/FWJVisitor.java
Normal file
102
src/de/dhbwstuttgart/strucTypes4/grammar/FWJVisitor.java
Normal file
@ -0,0 +1,102 @@
|
||||
package de.dhbwstuttgart.strucTypes4.grammar;// Generated from /home/sebastian/Schreibtisch/FLJava/src/FWJ.g4 by ANTLR 4.6
|
||||
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||
|
||||
/**
|
||||
* This interface defines a complete generic visitor for a parse tree produced
|
||||
* by {@link FWJParser}.
|
||||
*
|
||||
* @param <T> The return type of the visit operation. Use {@link Void} for
|
||||
* operations with no return type.
|
||||
*/
|
||||
public interface FWJVisitor<T> extends ParseTreeVisitor<T> {
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#sourceFile}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitSourceFile(FWJParser.SourceFileContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#classX}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitClassX(FWJParser.ClassXContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#feld}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitFeld(FWJParser.FeldContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#generics}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitGenerics(FWJParser.GenericsContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#generic}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitGeneric(FWJParser.GenericContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#methodDecl}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitMethodDecl(FWJParser.MethodDeclContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#methodDeclArgs}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitMethodDeclArgs(FWJParser.MethodDeclArgsContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#returnExpr}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitReturnExpr(FWJParser.ReturnExprContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#exprMCall}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitExprMCall(FWJParser.ExprMCallContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#exprVar}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitExprVar(FWJParser.ExprVarContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#exprField}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitExprField(FWJParser.ExprFieldContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#exprNew}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitExprNew(FWJParser.ExprNewContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#expr}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitExpr(FWJParser.ExprContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#exprMCallArgs}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitExprMCallArgs(FWJParser.ExprMCallArgsContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by {@link FWJParser#bezeichner}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitBezeichner(FWJParser.BezeichnerContext ctx);
|
||||
}
|
56
src/de/dhbwstuttgart/strucTypes4/parser/Parser.java
Normal file
56
src/de/dhbwstuttgart/strucTypes4/parser/Parser.java
Normal file
@ -0,0 +1,56 @@
|
||||
package de.dhbwstuttgart.strucTypes4.parser;
|
||||
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
/*
|
||||
public class Parser {
|
||||
|
||||
|
||||
|
||||
public void parse(String quellcode) {
|
||||
|
||||
ANTLRInputStream inputStream = new ANTLRInputStream(quellcode);
|
||||
FLJLexer lexer = new FLJLexer(inputStream);
|
||||
|
||||
// Fehler
|
||||
|
||||
|
||||
|
||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||
FLJParser parser = new FLJParser(tokens);
|
||||
ParserRuleContext tree = parser.l2();
|
||||
ParseTreeWalker walker = new ParseTreeWalker();
|
||||
|
||||
SourceFileWalker sourceFileWalker = new SourceFileWalker();
|
||||
|
||||
walker.walk(sourceFileWalker,tree);
|
||||
|
||||
String res = sourceFileWalker.sourceFile.toString();
|
||||
System.out.println(res);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//L2Walker nummerGesamtWalker = new NummerGesamtWalker(laendercode);
|
||||
//walker.walk(nummerGesamtWalker, tree);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//System.out.println(nummerGesamtWalker.toString().replace("\n" , " - "));
|
||||
//return new String[]{nummerGesamtWalker.lv, nummerGesamtWalker.ov, nummerGesamtWalker.hn, nummerGesamtWalker.dw};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
@ -0,0 +1,72 @@
|
||||
package de.dhbwstuttgart.strucTypes4.parser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.Field;
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.SourceFile;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
/*
|
||||
public class SourceFileWalker extends FWJBaseListener {
|
||||
|
||||
|
||||
SourceFile sourceFile = null;
|
||||
List<Field> felder = new ArrayList<>();
|
||||
List<Method> methods = new ArrayList<>();
|
||||
List<Class> klassen = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void enterL(FLJParser.LContext ctx) {
|
||||
System.out.println(ctx.ClassName().getText());
|
||||
|
||||
|
||||
super.enterL(ctx);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void enterFeld(FLJParser.FeldContext ctx) {
|
||||
super.enterFeld(ctx);
|
||||
|
||||
//ToDo: Check einführen
|
||||
Field field = new Field( ctx.ClassName().getText() , ctx.Var().getText() );
|
||||
felder.add(field);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterMethod(FLJParser.MethodContext ctx) {
|
||||
super.enterMethod(ctx);
|
||||
|
||||
|
||||
Method method = new Method(ctx.Var().toString() , null, null ,ctx.getText() );
|
||||
methods.add(method);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exitL(FLJParser.LContext ctx) {
|
||||
super.exitL(ctx);
|
||||
Class cl = new Class(ctx.ClassName().getText().toString() , felder,methods);
|
||||
felder = new ArrayList<>();
|
||||
methods = new ArrayList<>();
|
||||
klassen.add(cl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitL2(FLJParser.L2Context ctx) {
|
||||
super.exitL2(ctx);
|
||||
sourceFile = new SourceFile(klassen);
|
||||
}
|
||||
}
|
||||
*/
|
178
src/de/dhbwstuttgart/strucTypes4/parserFWJ/Parser.java
Normal file
178
src/de/dhbwstuttgart/strucTypes4/parserFWJ/Parser.java
Normal file
@ -0,0 +1,178 @@
|
||||
package de.dhbwstuttgart.strucTypes4.parserFWJ;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.Arg;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.Algo.*;
|
||||
import de.dhbwstuttgart.strucTypes4.grammar.FWJLexer;
|
||||
import de.dhbwstuttgart.strucTypes4.grammar.FWJParser;
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.*;
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
import org.antlr.v4.runtime.ANTLRInputStream;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
|
||||
public class Parser {
|
||||
|
||||
public SourceFile parse(String quellcode) {
|
||||
|
||||
ANTLRInputStream inputStream = new ANTLRInputStream(quellcode);
|
||||
FWJLexer lexer = new FWJLexer(inputStream);
|
||||
|
||||
|
||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||
FWJParser parser = new FWJParser(tokens);
|
||||
ParserRuleContext tree = parser.sourceFile();
|
||||
ParseTreeWalker walker = new ParseTreeWalker();
|
||||
|
||||
SourceFileWalker sourceFileWalker = new SourceFileWalker();
|
||||
|
||||
walker.walk(sourceFileWalker, tree);
|
||||
|
||||
return sourceFileWalker.getSourceFile();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Testmethode
|
||||
public ClassTyped parseCode(String quellcode) {
|
||||
SourceFile sf = parse(quellcode);
|
||||
Map<String,TPH> assumptions = new HashMap<>();
|
||||
TI typeinference = new TI(assumptions,sf.getClassList().get(0));
|
||||
return typeinference.getResultClassTypedWithInterfaces();
|
||||
}
|
||||
|
||||
|
||||
public ClassTyped parseCode(String quellcode , Map<String,TPH> ass ) {
|
||||
SourceFile sf = parse(quellcode);
|
||||
TI typeinference = new TI(ass,sf.getClassList().get(0));
|
||||
return typeinference.getResultClassTypedWithInterfaces();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// - ----------- Ab hier der Type AlgoRythmus
|
||||
|
||||
|
||||
|
||||
class TI {
|
||||
|
||||
ClassTyped resultClassTypedWithInterfaces;
|
||||
|
||||
public TI (Map<String,TPH> ass, Class aClass) {
|
||||
|
||||
Type type = new Type(ass,aClass);
|
||||
|
||||
Construct construct = new Construct(type.resultConstraintSet);
|
||||
//construct.constructInterfaces(type.resultConstraintSet,type.resultClassTyped );
|
||||
List<Interface> interfaces = construct.getResultInterfaces();
|
||||
|
||||
//System.out.println(interfaces);
|
||||
|
||||
//Construct construct2 = new Construct(type.resultConstraintSet, type.resultClassTyped);
|
||||
|
||||
//ClassTyped classTypedWithInterfaces = construct2.getResultClassTypedWithInterfaces();
|
||||
|
||||
|
||||
Set<TPH> generics = new HashSet<>();
|
||||
|
||||
// Typen der Methoden
|
||||
List<TPH> typesArg = new ArrayList<>();
|
||||
for (Method m : aClass.getMethoden()) {
|
||||
for (Argument arg : m.getArgs()) {
|
||||
typesArg.add(arg.typePlaceHolder);
|
||||
generics.add(m.getExpression().typePlaceHolder);
|
||||
}
|
||||
}
|
||||
|
||||
// Erstellen der Generics - Muss aus den Constraints von den interfaces ausgeführt werden
|
||||
Set<TPH> genericsSet = new HashSet<>();
|
||||
for (ConstraintAbstract t : construct.getResultConstraints()) {
|
||||
genericsSet.addAll(t.getAllReceiver());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Nur die Arg die tatsälich benutzt werden
|
||||
for (TPH tph : typesArg) {
|
||||
if (genericsSet.contains(tph)) {
|
||||
generics.add(tph);
|
||||
}
|
||||
}
|
||||
|
||||
// Generics Ressult
|
||||
List<TPH> genericsResult = new ArrayList<>();
|
||||
genericsResult.addAll(generics);
|
||||
|
||||
|
||||
|
||||
//#### Zwischenergebnis
|
||||
ClassTyped classTyped = new ClassTyped(interfaces, type.resultClassTyped , genericsResult , construct.getResultConstraints());
|
||||
System.out.println("__________________________________");
|
||||
System.out.println(classTyped.toString());
|
||||
System.out.println("__________________________________");
|
||||
|
||||
|
||||
// Solve muss Hier eingefügt werden
|
||||
|
||||
resultClassTypedWithInterfaces = classTyped;
|
||||
}
|
||||
|
||||
public ClassTyped getResultClassTypedWithInterfaces() {
|
||||
return resultClassTypedWithInterfaces;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class Type {
|
||||
|
||||
Class resultClassTyped;
|
||||
List<ConstraintAbstract> resultConstraintSet = new ArrayList<>();
|
||||
|
||||
public Type(Map<String,TPH> ass, Class aClass) {
|
||||
|
||||
// 1. Erstellen der Assumptions für die Klasse
|
||||
Map<String,TPH> fass_mass = aClass.makeAssumptions();
|
||||
|
||||
// ToDo Vereinigen der Assumptions
|
||||
fass_mass.putAll(ass);
|
||||
|
||||
|
||||
|
||||
// 2. Erstellen der classTyped
|
||||
// Eigentlich die Kombination aus Assumptions, Class TPH und ConstriantSet
|
||||
resultClassTyped = aClass;
|
||||
|
||||
|
||||
// 3. Erstellen des Constraint Sets
|
||||
for (Method method : aClass.getMethoden()) {
|
||||
|
||||
// AssAll Ass und fass und mass und this:A
|
||||
// ToDo this:a
|
||||
Map<String,TPH> assMethod = method.makeAssumptions();
|
||||
|
||||
assMethod.putAll(fass_mass);
|
||||
resultConstraintSet.addAll(method.typeExpr(assMethod));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
280
src/de/dhbwstuttgart/strucTypes4/parserFWJ/SourceFileWalker.java
Normal file
280
src/de/dhbwstuttgart/strucTypes4/parserFWJ/SourceFileWalker.java
Normal file
@ -0,0 +1,280 @@
|
||||
package de.dhbwstuttgart.strucTypes4.parserFWJ;
|
||||
|
||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.grammar.FWJBaseListener;
|
||||
import de.dhbwstuttgart.strucTypes4.grammar.FWJParser;
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.*;
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.Class;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
|
||||
public class SourceFileWalker extends FWJBaseListener {
|
||||
|
||||
|
||||
SourceFile sourceFile = null;
|
||||
private List<Field> felder = new ArrayList<>();
|
||||
private List<Method> methods = new ArrayList<>();
|
||||
private List<Class> klassen = new ArrayList<>();
|
||||
|
||||
private List<Argument> methodenArgs = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
// Rein Informell
|
||||
@Override
|
||||
public void enterClassX(FWJParser.ClassXContext ctx) {
|
||||
super.enterClassX(ctx);
|
||||
System.out.println(ctx.getText());
|
||||
|
||||
}
|
||||
|
||||
// Feldparser
|
||||
@Override
|
||||
public void exitFeld(FWJParser.FeldContext ctx) {
|
||||
super.exitFeld(ctx);
|
||||
//ToDo momentan nur typ und var
|
||||
felder.add(new Field(ctx.bezeichner(0).getText() , ctx.bezeichner(1).getText()));
|
||||
}
|
||||
|
||||
// MethodenParser
|
||||
@Override
|
||||
public void exitMethodDecl(FWJParser.MethodDeclContext ctx) {
|
||||
super.exitMethodDecl(ctx);
|
||||
// Methode Implementieren
|
||||
|
||||
|
||||
List<String> argList = new ArrayList<>();
|
||||
|
||||
ParseTreeWalker ptl = new ParseTreeWalker();
|
||||
|
||||
//for (ctx.methodDeclArgs().getToken())
|
||||
Method method = new Method(ctx.bezeichner().getText() ,"returnType:", methodenArgs , ExpressAdapter.adapt(ctx.returnExpr().expr()));
|
||||
methods.add(method);
|
||||
methodenArgs = new ArrayList<>();
|
||||
}
|
||||
|
||||
// Parser für Argumente der Methode
|
||||
@Override
|
||||
public void exitMethodDeclArgs(FWJParser.MethodDeclArgsContext ctx) {
|
||||
super.exitMethodDeclArgs(ctx);
|
||||
|
||||
ParseTreeWalker walker = new ParseTreeWalker();
|
||||
walker.walk(new FWJBaseListener(){
|
||||
@Override
|
||||
public void exitBezeichner(FWJParser.BezeichnerContext ctx) {
|
||||
super.exitBezeichner(ctx);
|
||||
methodenArgs.add(new Argument(ctx.getText()));
|
||||
}
|
||||
} , ctx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Parser der Return exprression
|
||||
|
||||
|
||||
/*
|
||||
@Override
|
||||
public void exitReturnExpr(FWJParser.ReturnExprContext ctx) {
|
||||
super.exitReturnExpr(ctx);
|
||||
ExpressionAbstract exp = ExpressAdapter.adapt(ctx.expr());
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void exitClassX(FWJParser.ClassXContext ctx) {
|
||||
super.exitClassX(ctx);
|
||||
// Klasse in SourceFile schreiben
|
||||
// Variablen löschen
|
||||
Class cl = new Class(ctx.bezeichner().getText(),felder,methods);
|
||||
felder = new ArrayList<>();
|
||||
methods = new ArrayList<>();
|
||||
klassen.add(cl);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exitSourceFile(FWJParser.SourceFileContext ctx) {
|
||||
super.exitSourceFile(ctx);
|
||||
// Parsevorgang beendet
|
||||
sourceFile = new SourceFile(klassen);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public SourceFile getSourceFile() {
|
||||
return sourceFile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Diese Idee hat nich funktioniert
|
||||
/*
|
||||
class ExprWalker2 extends FWJBaseListener {
|
||||
|
||||
|
||||
List<ExpressionAbstract> rtExpressionStore;
|
||||
|
||||
List<ExpressionAbstract> rtExpression = new ArrayList<>();
|
||||
List<List<ExpressionAbstract>> mtCallExpressions = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
public void exitExprVar(FWJParser.ExprVarContext ctx) {
|
||||
super.exitExprVar(ctx);
|
||||
rtExpression.add(new ExprVar(ctx.bezeichner().getText()));
|
||||
System.out.println(rtExpression.toString());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exitExprField(FWJParser.ExprFieldContext ctx) {
|
||||
super.exitExprField(ctx);
|
||||
rtExpression.add(new ExprField(ctx.bezeichner().getText()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void enterExprMCallArgs(FWJParser.ExprMCallArgsContext ctx) {
|
||||
super.enterExprMCallArgs(ctx);
|
||||
rtExpressionStore = rtExpression;
|
||||
rtExpression = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitExprMCallArgs(FWJParser.ExprMCallArgsContext ctx) {
|
||||
super.exitExprMCallArgs(ctx);
|
||||
List<ExpressionAbstract> l = rtExpression;
|
||||
mtCallExpressions.add(l);
|
||||
rtExpression = rtExpressionStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitExprMCall(FWJParser.ExprMCallContext ctx) {
|
||||
super.exitExprMCall(ctx);
|
||||
|
||||
List<ExpressionAbstract> ex = new ArrayList<>();
|
||||
//wenn keine parameter
|
||||
if (mtCallExpressions.size() != 0) {
|
||||
ex = mtCallExpressions.get(mtCallExpressions.size() - 1);
|
||||
}
|
||||
rtExpression.add(new ExprMCall(ctx.bezeichner().getText(), ex));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exitExprNew(FWJParser.ExprNewContext ctx) {
|
||||
super.exitExprNew(ctx);
|
||||
System.err.println("Fehler");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/* Beispiel, wird nicht benötigt :
|
||||
|
||||
class ExprWalker extends FWJBaseListener{
|
||||
|
||||
List<ExpressionAbstract> rtExpression = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void exitExpr(FWJParser.ExprContext ctx) {
|
||||
super.exitExpr(ctx);
|
||||
System.out.println("aussere klasse "+ ctx.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterExprMCallArgs(FWJParser.ExprMCallArgsContext ctx) {
|
||||
super.enterExprMCallArgs(ctx);
|
||||
|
||||
ParseTreeWalker walter = new ParseTreeWalker();
|
||||
walter.walk(new FWJBaseListener() {
|
||||
|
||||
@Override
|
||||
public void exitExpr(FWJParser.ExprContext ctx) {
|
||||
super.exitExpr(ctx);
|
||||
System.out.println("Innere Klasse: " + ctx.getText());
|
||||
}
|
||||
},ctx );
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Parst die Expression und erstellt eine Rekursive Datenstruktur
|
||||
class ExpressAdapter {
|
||||
|
||||
public static ExpressionAbstract adapt(FWJParser.ExprContext ctx) {
|
||||
|
||||
if (ctx.expr() != null ) {
|
||||
if (ctx.expr().size() == 1) {
|
||||
return adapt(ctx.expr(0));
|
||||
}
|
||||
else if (ctx.expr().size() == 2) {
|
||||
ExpressionAbstract receiver = adapt(ctx.expr(0));
|
||||
ExpressionAbstract caller = adapt(ctx.expr(1));
|
||||
Expression ex = new Expression(receiver,caller);
|
||||
return ex;
|
||||
}
|
||||
else if (ctx.exprVar() != null) {
|
||||
return new ExprVar(ctx.exprVar().getText());
|
||||
}
|
||||
else if (ctx.exprField() != null ) {
|
||||
return new ExprField(ctx.exprField().bezeichner().getText());
|
||||
}
|
||||
else if (ctx.exprMCall() != null) {
|
||||
List<ExpressionAbstract> args = new ArrayList<>();
|
||||
if (ctx.exprMCall().exprMCallArgs() != null ) {
|
||||
if (ctx.exprMCall().exprMCallArgs().expr() != null) {
|
||||
for (FWJParser.ExprContext exp : ctx.exprMCall().exprMCallArgs().expr()) {
|
||||
args.add(adapt(exp));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ExprMCall(ctx.exprMCall().bezeichner().getText() , args);
|
||||
}
|
||||
else if (ctx.exprNew() != null) {
|
||||
|
||||
// Argumente
|
||||
List<ExpressionAbstract> args = new ArrayList<>();
|
||||
if (ctx.exprNew().exprMCallArgs() != null) {
|
||||
if (ctx.exprNew().exprMCallArgs().expr() != null) {
|
||||
for (FWJParser.ExprContext exp : ctx.exprNew().exprMCallArgs().expr()) {
|
||||
args.add((adapt(exp)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Generics
|
||||
// Zugriff erfolgt äquivalent zu den Argumenten
|
||||
Map<String,String> generics = new HashMap<>();
|
||||
if (ctx.exprNew().generics() != null) {
|
||||
if (ctx.exprNew().generics().generic() != null) {
|
||||
for (FWJParser.GenericContext genericContext : ctx.exprNew().generics().generic()) {
|
||||
generics.put(genericContext.bezeichner(0).getText() , genericContext.bezeichner(1).getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ExprNew(ctx.exprNew().bezeichner().getText() , generics, args);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
36
src/de/dhbwstuttgart/strucTypes4/syntaxtree/Argument.java
Normal file
36
src/de/dhbwstuttgart/strucTypes4/syntaxtree/Argument.java
Normal file
@ -0,0 +1,36 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 09.04.17.
|
||||
*/
|
||||
public class Argument extends SyntaxNode {
|
||||
|
||||
String name;
|
||||
|
||||
public Argument(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String toCodeTyped() {
|
||||
return String.format("%s : %s " , name , typePlaceHolder );
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
104
src/de/dhbwstuttgart/strucTypes4/syntaxtree/Class.java
Normal file
104
src/de/dhbwstuttgart/strucTypes4/syntaxtree/Class.java
Normal file
@ -0,0 +1,104 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
public class Class extends SyntaxNode{
|
||||
|
||||
|
||||
String name;
|
||||
List<Field> felder;
|
||||
List<Method> methoden;
|
||||
|
||||
|
||||
public Class(String name, List<Field> felder , List<Method> methoden) {
|
||||
this.name = name;
|
||||
this.felder = felder;
|
||||
this.methoden = methoden;
|
||||
}
|
||||
|
||||
|
||||
public Map<String,TPH> makeAssumptions() {
|
||||
|
||||
// Name bei Feldern feld, name bei methoden methode()
|
||||
Map<String, TPH> ass = new HashMap<>();
|
||||
// felder
|
||||
for (Field f : felder) {
|
||||
ass.put(f.getVar_name() , f.typePlaceHolder);
|
||||
}
|
||||
|
||||
// methoden
|
||||
for (Method m : methoden) {
|
||||
ass.put(m.getName()+"()", m.typePlaceHolder );
|
||||
}
|
||||
|
||||
// This einfügen
|
||||
ass.put("this" , typePlaceHolder);
|
||||
|
||||
return ass;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Field> getFelder() {
|
||||
return felder;
|
||||
}
|
||||
|
||||
public void setFelder(List<Field> felder) {
|
||||
this.felder = felder;
|
||||
}
|
||||
|
||||
public List<Method> getMethoden() {
|
||||
return methoden;
|
||||
}
|
||||
|
||||
public void setMethoden(List<Method> methoden) {
|
||||
this.methoden = methoden;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String res = "class " + name + " \n";
|
||||
for (Field f : felder) {
|
||||
res = res.concat(f.toString() + "\n");
|
||||
}
|
||||
|
||||
for (Method m : methoden) {
|
||||
res = res.concat(m.toString() + "\n");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String toCodeTyped() {
|
||||
String res = "class " + name + " \n";
|
||||
for (Field f : felder) {
|
||||
res = res.concat(f.toCodeTyped() + "\n");
|
||||
}
|
||||
|
||||
for (Method m : methoden) {
|
||||
res = res.concat(m.toCodeTyped() + "\n");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
90
src/de/dhbwstuttgart/strucTypes4/syntaxtree/ClassTyped.java
Normal file
90
src/de/dhbwstuttgart/strucTypes4/syntaxtree/ClassTyped.java
Normal file
@ -0,0 +1,90 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.Algo.ConstraintAbstract;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 09.04.17.
|
||||
*/
|
||||
public class ClassTyped {
|
||||
|
||||
List<Interface> implementedInterfaces;
|
||||
Class aClass;
|
||||
List<TPH> generics;
|
||||
List<ConstraintAbstract> constraints;
|
||||
|
||||
|
||||
public ClassTyped(List<Interface> implementedInterfaces, Class aClass, List<TPH> generics, List<ConstraintAbstract> constraints) {
|
||||
this.implementedInterfaces = implementedInterfaces;
|
||||
this.aClass = aClass;
|
||||
this.generics = generics;
|
||||
this.constraints = constraints;
|
||||
}
|
||||
|
||||
// Dummy Konstruktor
|
||||
public ClassTyped(String name) {
|
||||
this.implementedInterfaces = new ArrayList<>();
|
||||
this.aClass = new Class(name,new ArrayList<>(), new ArrayList<>());
|
||||
this.generics = new ArrayList<>();
|
||||
this.constraints = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format( "Class Typed - \n " +
|
||||
"// Interfaces: \n %s \n " +
|
||||
"// Generics %s \n " +
|
||||
"// Constraints %s \n " +
|
||||
"%s " , implementedInterfaces.toString(), generics.toString() , constraints.toString() , aClass.toString() );
|
||||
}
|
||||
|
||||
|
||||
public String toCodeTyped() {
|
||||
return String.format( "Class Code Typed - \n " +
|
||||
"// Interfaces: \n %s \n " +
|
||||
"// Generics %s \n " +
|
||||
"// Constraints %s \n " +
|
||||
"%s " , implementedInterfaces.toString(), generics.toString() , constraints.toString() , aClass.toCodeTyped() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Interface> getImplementedInterfaces() {
|
||||
return implementedInterfaces;
|
||||
}
|
||||
|
||||
public void setImplementedInterfaces(List<Interface> implementedInterfaces) {
|
||||
this.implementedInterfaces = implementedInterfaces;
|
||||
}
|
||||
|
||||
public Class getaClass() {
|
||||
return aClass;
|
||||
}
|
||||
|
||||
public void setaClass(Class aClass) {
|
||||
this.aClass = aClass;
|
||||
}
|
||||
|
||||
public List<TPH> getGenerics() {
|
||||
return generics;
|
||||
}
|
||||
|
||||
public void setGenerics(List<TPH> generics) {
|
||||
this.generics = generics;
|
||||
}
|
||||
|
||||
public List<ConstraintAbstract> getConstraints() {
|
||||
return constraints;
|
||||
}
|
||||
|
||||
public void setConstraints(List<ConstraintAbstract> constraints) {
|
||||
this.constraints = constraints;
|
||||
}
|
||||
}
|
42
src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprField.java
Normal file
42
src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprField.java
Normal file
@ -0,0 +1,42 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.Algo.ConstraintGleich;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
public class ExprField extends ExpressionAbstract {
|
||||
|
||||
String nameField;
|
||||
|
||||
|
||||
public List<ConstraintGleich> typeExpr( ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public ExprField(String nameField) {
|
||||
this.nameField = nameField;
|
||||
}
|
||||
|
||||
public String getNameField() {
|
||||
return nameField;
|
||||
}
|
||||
|
||||
public void setNameField(String nameField) {
|
||||
this.nameField = nameField;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "." + nameField;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toCodeTyped() {
|
||||
return "." + nameField;
|
||||
}
|
||||
}
|
116
src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprMCall.java
Normal file
116
src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprMCall.java
Normal file
@ -0,0 +1,116 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.Algo.*;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPHFactory;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
public class ExprMCall extends ExpressionAbstract {
|
||||
|
||||
String name;
|
||||
List<ExpressionAbstract> args;
|
||||
|
||||
public ExprMCall(String name, List<ExpressionAbstract> args) {
|
||||
this.name = name;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
|
||||
public List<ConstraintAbstract> typeExpr (Map<String, TPH> ass , TPH receiver , TPH returnType) {
|
||||
List<ConstraintAbstract> constraints = new ArrayList<>();
|
||||
|
||||
|
||||
// Receivertyp ist keine TypVariable
|
||||
if (receiver.getType() != null) {
|
||||
|
||||
Class aclass = receiver.getType().aClass;
|
||||
|
||||
|
||||
// Typeexpr Der Argumente der Methode
|
||||
args.forEach(x -> constraints.addAll( TypeExpr.typeExpr( x,ass,null,null) ));
|
||||
|
||||
|
||||
// Methode m-Type für neuen Constraint für argument typen der Methode mt hinzu
|
||||
|
||||
for (Method m : aclass.getMethoden()) {
|
||||
if (m.getName().equals(name)) {
|
||||
int i = 0;
|
||||
for (Argument arg : m.getArgs() ) {
|
||||
String type = args.get(i).typePlaceHolder.getType().aClass.name;
|
||||
i++;
|
||||
constraints.add(new ConstraintSubType(new TPH(type) ,arg.typePlaceHolder ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//constraints.add( new ConstraintMethod(receiver , name, types , returnType , betaTypes ));
|
||||
return constraints;
|
||||
|
||||
}
|
||||
// Receivertyp ist TypVariable
|
||||
else {
|
||||
|
||||
// Typeexpr Der Argumente der Methode
|
||||
args.forEach(x -> constraints.addAll( TypeExpr.typeExpr( x,ass,null,null) ));
|
||||
|
||||
// Liste mit Typen der Argumente der Methode sammeln
|
||||
List<TPH> types = new ArrayList<>();
|
||||
args.forEach(x -> types.add(x.typePlaceHolder));
|
||||
|
||||
// Neue Liste mit neuen Beta - Argumenten erstellen
|
||||
List<TPH> betaTypes = new ArrayList<>();
|
||||
args.forEach(x -> betaTypes.add( TPHFactory.makeTPH()));
|
||||
|
||||
|
||||
// Erstellen der Substyp constraints
|
||||
for (int i = 0 ; i < types.size() ; i++) {
|
||||
ConstraintSubType con = new ConstraintSubType(types.get(i) , betaTypes.get(i) );
|
||||
constraints.add(con);
|
||||
}
|
||||
|
||||
constraints.add( new ConstraintMethod(receiver , name, types , returnType , betaTypes ));
|
||||
return constraints;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<ExpressionAbstract> getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
public void setArgs(List<ExpressionAbstract> args) {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "." + name + "(" + args.toString() +")";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toCodeTyped() {
|
||||
String argsString = "";
|
||||
for (ExpressionAbstract a : args) {
|
||||
argsString = argsString.concat(a.toCodeTyped());
|
||||
}
|
||||
|
||||
return String.format(" .%s ( %s )" , name , argsString );
|
||||
}
|
||||
}
|
61
src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprNew.java
Normal file
61
src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprNew.java
Normal file
@ -0,0 +1,61 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 08.04.17.
|
||||
*/
|
||||
public class ExprNew extends ExpressionAbstract {
|
||||
|
||||
|
||||
String classType;
|
||||
// key Value
|
||||
Map<String,String> generics;
|
||||
List<ExpressionAbstract> args;
|
||||
|
||||
public ExprNew(String classType, Map<String,String> generics, List<ExpressionAbstract> args) {
|
||||
this.classType = classType;
|
||||
this.generics = generics;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
|
||||
public String getClassType() {
|
||||
return classType;
|
||||
}
|
||||
|
||||
public void setClassType(String classType) {
|
||||
this.classType = classType;
|
||||
}
|
||||
|
||||
public Map<String,String> getGenerics() {
|
||||
return generics;
|
||||
}
|
||||
|
||||
public void setGenerics(Map<String,String> generics) {
|
||||
this.generics = generics;
|
||||
}
|
||||
|
||||
public List<ExpressionAbstract> getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
public void setArgs(List<ExpressionAbstract> args) {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return String.format("new %s< %s >( %s )" , classType.toString(), generics.toString() , args.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCodeTyped() {
|
||||
return String.format("[new %s< %s >( %s )]" , classType.toString(), generics.toString() , args.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
51
src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprVar.java
Normal file
51
src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprVar.java
Normal file
@ -0,0 +1,51 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.Algo.ConstraintAbstract;
|
||||
import de.dhbwstuttgart.strucTypes4.Algo.ConstraintGleich;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
public class ExprVar extends ExpressionAbstract {
|
||||
|
||||
String name;
|
||||
|
||||
|
||||
public List<ConstraintAbstract> typeExpr(Map<String,TPH> ass) {
|
||||
List<ConstraintAbstract> constriants = new ArrayList<>();
|
||||
//ConstraintGleich constraint = new ConstraintGleich(typePlaceHolder,ass.get(name));
|
||||
//constriants.add(constraint);
|
||||
|
||||
super.typePlaceHolder = ass.get(name);
|
||||
System.out.println("TPH:" + super.typePlaceHolder + "name: " + name);
|
||||
return constriants;
|
||||
}
|
||||
|
||||
public ExprVar(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCodeTyped() {
|
||||
return String.format( " %s : %s " , name , typePlaceHolder );
|
||||
}
|
||||
}
|
42
src/de/dhbwstuttgart/strucTypes4/syntaxtree/Expression.java
Normal file
42
src/de/dhbwstuttgart/strucTypes4/syntaxtree/Expression.java
Normal file
@ -0,0 +1,42 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
public class Expression extends ExpressionAbstract {
|
||||
|
||||
ExpressionAbstract receiver;
|
||||
ExpressionAbstract caller;
|
||||
|
||||
public Expression(ExpressionAbstract receiver, ExpressionAbstract caller) {
|
||||
this.receiver = receiver;
|
||||
this.caller = caller;
|
||||
}
|
||||
|
||||
|
||||
public ExpressionAbstract getReceiver() {
|
||||
return receiver;
|
||||
}
|
||||
|
||||
public void setReceiver(ExpressionAbstract receiver) {
|
||||
this.receiver = receiver;
|
||||
}
|
||||
|
||||
public ExpressionAbstract getCaller() {
|
||||
return caller;
|
||||
}
|
||||
|
||||
public void setCaller(ExpressionAbstract caller) {
|
||||
this.caller = caller;
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
public String toString() {
|
||||
return receiver.toString() + caller.toString();
|
||||
}
|
||||
|
||||
public String toCodeTyped() {
|
||||
return String.format(" [[ %s ] %s ]:%s " , receiver.toCodeTyped() , caller.toCodeTyped() , typePlaceHolder );
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 08.04.17.
|
||||
*/
|
||||
public abstract class ExpressionAbstract extends SyntaxNode {
|
||||
|
||||
|
||||
public String toCodeTyped() {
|
||||
return "?";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
43
src/de/dhbwstuttgart/strucTypes4/syntaxtree/Field.java
Normal file
43
src/de/dhbwstuttgart/strucTypes4/syntaxtree/Field.java
Normal file
@ -0,0 +1,43 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
public class Field extends SyntaxNode {
|
||||
|
||||
private String var_name;
|
||||
private String type;
|
||||
|
||||
public Field(String type, String var_name) {
|
||||
this.var_name = var_name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getVar_name() {
|
||||
return var_name;
|
||||
}
|
||||
|
||||
public void setVar_name(String var_name) {
|
||||
this.var_name = var_name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Feld: %s %s " , type , var_name);
|
||||
}
|
||||
|
||||
public String toCodeTyped() {
|
||||
return String.format("Feld %s %s : %s" , type, var_name , this.typePlaceHolder);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 09.04.17.
|
||||
*/
|
||||
public class FieldInterface {
|
||||
|
||||
TPH type;
|
||||
String name;
|
||||
|
||||
public FieldInterface(TPH type, String name) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public TPH getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(TPH type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s %s " , type , name );
|
||||
}
|
||||
}
|
62
src/de/dhbwstuttgart/strucTypes4/syntaxtree/Interface.java
Normal file
62
src/de/dhbwstuttgart/strucTypes4/syntaxtree/Interface.java
Normal file
@ -0,0 +1,62 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
|
||||
/**
|
||||
* Created by sebastian on 09.04.17.
|
||||
*/
|
||||
public class Interface {
|
||||
|
||||
String name_interface;
|
||||
List<FieldInterface> fields;
|
||||
List<MethodInterface> methods;
|
||||
List<TPH> generics;
|
||||
|
||||
|
||||
public Interface(String name_interface, List<FieldInterface> fields, List<MethodInterface> methods, List<TPH> generics) {
|
||||
this.name_interface = name_interface;
|
||||
this.fields = fields;
|
||||
this.methods = methods;
|
||||
this.generics = generics;
|
||||
}
|
||||
|
||||
public String getName_interface() {
|
||||
return name_interface;
|
||||
}
|
||||
|
||||
public void setName_interface(String name_interface) {
|
||||
this.name_interface = name_interface;
|
||||
}
|
||||
|
||||
public List<FieldInterface> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public void setFields(List<FieldInterface> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
public List<MethodInterface> getMethods() {
|
||||
return methods;
|
||||
}
|
||||
|
||||
public void setMethods(List<MethodInterface> methods) {
|
||||
this.methods = methods;
|
||||
}
|
||||
|
||||
public List<TPH> getGenerics() {
|
||||
return generics;
|
||||
}
|
||||
|
||||
public void setGenerics(List<TPH> generics) {
|
||||
this.generics = generics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("interface %s < %s > { \n %s \n %s } \n \n " , name_interface , generics, fields.toString() , methods.toString());
|
||||
}
|
||||
}
|
93
src/de/dhbwstuttgart/strucTypes4/syntaxtree/Method.java
Normal file
93
src/de/dhbwstuttgart/strucTypes4/syntaxtree/Method.java
Normal file
@ -0,0 +1,93 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.Algo.ConstraintAbstract;
|
||||
import de.dhbwstuttgart.strucTypes4.Algo.TypeExpr;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
public class Method extends SyntaxNode {
|
||||
|
||||
private String name;
|
||||
private String rtype;
|
||||
private List<Argument> args;
|
||||
private ExpressionAbstract expression;
|
||||
|
||||
|
||||
public Method(String name, String rtype, List<Argument> args, ExpressionAbstract expression) {
|
||||
this.name = name;
|
||||
this.rtype = rtype;
|
||||
this.args = args;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, TPH> makeAssumptions() {
|
||||
Map<String, TPH> assLokal = new HashMap<>();
|
||||
for (Argument arg : args ) {
|
||||
assLokal.put(arg.getName(), arg.typePlaceHolder);
|
||||
}
|
||||
return assLokal;
|
||||
}
|
||||
|
||||
public List<ConstraintAbstract> typeExpr(Map<String,TPH> ass) {
|
||||
return TypeExpr.typeExpr(expression,ass,null , null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getRtype() {
|
||||
return rtype;
|
||||
}
|
||||
|
||||
public void setRtype(String rtype) {
|
||||
this.rtype = rtype;
|
||||
}
|
||||
|
||||
public List<Argument> getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
public void setArgs(List<Argument> args) {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public ExpressionAbstract getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
public void setExpression(ExpressionAbstract expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return String.format("Methode: %s ( %s ) { return %s }" , name , args.toString() , expression.toString());
|
||||
}
|
||||
|
||||
|
||||
public String toCodeTyped() {
|
||||
|
||||
String argsString = "";
|
||||
for (Argument argument : args) {
|
||||
argsString = argsString.concat(argument.toCodeTyped() + " ");
|
||||
}
|
||||
return String.format("%s Methode: %s ( %s ) { return %s }" , expression.typePlaceHolder, name , argsString , expression.toCodeTyped() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 09.04.17.
|
||||
*/
|
||||
public class MethodInterface {
|
||||
|
||||
String name;
|
||||
TPH rtType;
|
||||
List<TPH> argsTypes;
|
||||
|
||||
|
||||
public MethodInterface(String name, TPH rtType, List<TPH> argsTypes) {
|
||||
this.name = name;
|
||||
this.rtType = rtType;
|
||||
this.argsTypes = argsTypes;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public TPH getRtType() {
|
||||
return rtType;
|
||||
}
|
||||
|
||||
public void setRtType(TPH rtType) {
|
||||
this.rtType = rtType;
|
||||
}
|
||||
|
||||
public List<TPH> getArgsTypes() {
|
||||
return argsTypes;
|
||||
}
|
||||
|
||||
public void setArgsTypes(List<TPH> argsTypes) {
|
||||
this.argsTypes = argsTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(" %s %s ( %s ); " , rtType, name, argsTypes.toString());
|
||||
}
|
||||
}
|
36
src/de/dhbwstuttgart/strucTypes4/syntaxtree/SourceFile.java
Normal file
36
src/de/dhbwstuttgart/strucTypes4/syntaxtree/SourceFile.java
Normal file
@ -0,0 +1,36 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
public class SourceFile {
|
||||
|
||||
private List<Class> classList = new ArrayList<>();
|
||||
|
||||
|
||||
public SourceFile(List<Class> classList) {
|
||||
this.classList = classList;
|
||||
}
|
||||
|
||||
public List<Class> getClassList() {
|
||||
return classList;
|
||||
}
|
||||
|
||||
public void setClassList(List<Class> classList) {
|
||||
this.classList = classList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String s2 = "";
|
||||
for (Class cl : classList) {
|
||||
s2 = s2.concat(cl.toString() + "\n");
|
||||
}
|
||||
|
||||
|
||||
return s2;
|
||||
}
|
||||
}
|
19
src/de/dhbwstuttgart/strucTypes4/syntaxtree/SyntaxNode.java
Normal file
19
src/de/dhbwstuttgart/strucTypes4/syntaxtree/SyntaxNode.java
Normal file
@ -0,0 +1,19 @@
|
||||
package de.dhbwstuttgart.strucTypes4.syntaxtree;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPH;
|
||||
import de.dhbwstuttgart.strucTypes4.typen.TPHFactory;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 07.04.17.
|
||||
*/
|
||||
public class SyntaxNode {
|
||||
|
||||
public TPH typePlaceHolder;
|
||||
|
||||
public SyntaxNode() {
|
||||
typePlaceHolder = TPHFactory.makeTPH();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
61
src/de/dhbwstuttgart/strucTypes4/typen/TPH.java
Normal file
61
src/de/dhbwstuttgart/strucTypes4/typen/TPH.java
Normal file
@ -0,0 +1,61 @@
|
||||
package de.dhbwstuttgart.strucTypes4.typen;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.ClassTyped;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 08.04.17.
|
||||
*/
|
||||
|
||||
// Ein Typeplaceholder
|
||||
public class TPH {
|
||||
String id;
|
||||
|
||||
ClassTyped type;
|
||||
|
||||
// unschön aber ...
|
||||
public TPH() {
|
||||
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public ClassTyped getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ClassTyped type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public TPH(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj.getClass().equals(TPH.class)) {
|
||||
TPH t = (TPH) obj;
|
||||
if (t.id.equals(id)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
34
src/de/dhbwstuttgart/strucTypes4/typen/TPHFactory.java
Normal file
34
src/de/dhbwstuttgart/strucTypes4/typen/TPHFactory.java
Normal file
@ -0,0 +1,34 @@
|
||||
package de.dhbwstuttgart.strucTypes4.typen;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.Interface;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 08.04.17.
|
||||
*/
|
||||
public class TPHFactory {
|
||||
|
||||
// Für Typeplaceholder T
|
||||
static Integer startwert = 1;
|
||||
static Integer offset = 0;
|
||||
|
||||
|
||||
// Für Typeplaceholder V
|
||||
static Integer startwertV = 1;
|
||||
static Integer offsetV = 0;
|
||||
|
||||
|
||||
public static TPH makeTPH() {
|
||||
Integer akt = startwert+offset;
|
||||
offset = offset +1;
|
||||
return new TPH("T" + akt.toString());
|
||||
}
|
||||
|
||||
|
||||
public static TPH makeTPHV() {
|
||||
Integer akt = startwertV + offsetV;
|
||||
offsetV = offsetV +1;
|
||||
return new TPH( "V" + akt.toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
11
src/de/dhbwstuttgart/strucTypes4/typen/TPHStore.java
Normal file
11
src/de/dhbwstuttgart/strucTypes4/typen/TPHStore.java
Normal file
@ -0,0 +1,11 @@
|
||||
package de.dhbwstuttgart.strucTypes4.typen;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 08.04.17.
|
||||
*/
|
||||
public class TPHStore {
|
||||
public Map<TPH,List<String>> tph;
|
||||
}
|
36
src/de/dhbwstuttgart/strucTypes4/typen/TPHV.java
Normal file
36
src/de/dhbwstuttgart/strucTypes4/typen/TPHV.java
Normal file
@ -0,0 +1,36 @@
|
||||
package de.dhbwstuttgart.strucTypes4.typen;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 08.04.17.
|
||||
*/
|
||||
|
||||
// Ein Typeplaceholder
|
||||
public class TPHV {
|
||||
String id;
|
||||
|
||||
public TPHV(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "V"+id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj.getClass().equals(TPHV.class)) {
|
||||
TPHV t = (TPHV) obj;
|
||||
if (t.id.equals(id)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
17
src/de/dhbwstuttgart/strucTypes4/typen/TPHVFactory.java
Normal file
17
src/de/dhbwstuttgart/strucTypes4/typen/TPHVFactory.java
Normal file
@ -0,0 +1,17 @@
|
||||
package de.dhbwstuttgart.strucTypes4.typen;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 08.04.17.
|
||||
*/
|
||||
public class TPHVFactory {
|
||||
|
||||
static Integer startwert = 1;
|
||||
static Integer offset = 0;
|
||||
|
||||
|
||||
public static TPHV makeTPHV() {
|
||||
Integer akt = startwert+offset;
|
||||
offset = offset +1;
|
||||
return new TPHV(akt.toString());
|
||||
}
|
||||
}
|
18
src/de/dhbwstuttgart/strucTypes4/typen/TPHwithClass.java
Normal file
18
src/de/dhbwstuttgart/strucTypes4/typen/TPHwithClass.java
Normal file
@ -0,0 +1,18 @@
|
||||
package de.dhbwstuttgart.strucTypes4.typen;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes4.syntaxtree.ClassTyped;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 12.04.17.
|
||||
*/
|
||||
public class TPHwithClass extends TPH {
|
||||
|
||||
|
||||
public TPHwithClass() {
|
||||
super.id = "default";
|
||||
}
|
||||
|
||||
|
||||
public ClassTyped classTyped = null;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user