ret = parameterLists.stream().filter(aspParameterList -> aspParameterList.name.equals(rs)).findAny();
+ //return ret.get();
}
}
\ No newline at end of file
diff --git a/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResult.g4 b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResult.g4
new file mode 100644
index 00000000..98b6a5fb
--- /dev/null
+++ b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResult.g4
@@ -0,0 +1,37 @@
+grammar UnifyResult;
+
+answer : 'ANSWER' (resultSetRule '.')*;
+
+resultSetRule :
+ parameter
+ | equals
+ | smaller
+ | typeVar
+ | type
+ | otherRule
+ ;
+
+parameterList : '(' value (',' value)* ')';
+value : NAME
+ | resultSetRule ;
+
+parameter : PARAMLIST_NAME parameterList;
+equals : EQUALS_NAME parameterList;
+smaller : SMALLER_NAME parameterList;
+typeVar : TYPEVAR_NAME parameterList;
+type : TYPE_NAME parameterList;
+otherRule : NAME parameterList;
+
+//TODO: Es sollte Regeln für das Result set geben, welche sich nicht mit den anderen überdecken, dann auch nur diese im Result ausgeben
+PARAMLIST_NAME : 'param';
+EQUALS_NAME : 'equals';
+SMALLER_NAME : 'smaller';
+TYPEVAR_NAME : 'typeVar';
+TYPE_NAME : 'type';
+NAME : [a-zA-Z0-9_]+;
+
+WS : [ \t\r\n\u000C]+ -> skip
+ ;
+LINE_COMMENT
+ : '%' ~[\r\n]* -> skip
+ ;
diff --git a/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResult.tokens b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResult.tokens
new file mode 100644
index 00000000..8f9c0e0a
--- /dev/null
+++ b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResult.tokens
@@ -0,0 +1,23 @@
+T__0=1
+T__1=2
+T__2=3
+T__3=4
+T__4=5
+PARAMLIST_NAME=6
+EQUALS_NAME=7
+SMALLER_NAME=8
+TYPEVAR_NAME=9
+TYPE_NAME=10
+NAME=11
+WS=12
+LINE_COMMENT=13
+'ANSWER'=1
+'.'=2
+'('=3
+','=4
+')'=5
+'param'=6
+'equals'=7
+'smaller'=8
+'typeVar'=9
+'type'=10
diff --git a/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultBaseListener.java b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultBaseListener.java
new file mode 100644
index 00000000..f33525d7
--- /dev/null
+++ b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultBaseListener.java
@@ -0,0 +1,159 @@
+// Generated from UnifyResult.g4 by ANTLR 4.7
+package de.dhbwstuttgart.sat.asp.parser.antlr;
+
+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 UnifyResultListener},
+ * which can be extended to create a listener which only needs to handle a subset
+ * of the available methods.
+ */
+public class UnifyResultBaseListener implements UnifyResultListener {
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterAnswer(UnifyResultParser.AnswerContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitAnswer(UnifyResultParser.AnswerContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterResultSetRule(UnifyResultParser.ResultSetRuleContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitResultSetRule(UnifyResultParser.ResultSetRuleContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterParameterList(UnifyResultParser.ParameterListContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitParameterList(UnifyResultParser.ParameterListContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterValue(UnifyResultParser.ValueContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitValue(UnifyResultParser.ValueContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterParameter(UnifyResultParser.ParameterContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitParameter(UnifyResultParser.ParameterContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterEquals(UnifyResultParser.EqualsContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitEquals(UnifyResultParser.EqualsContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterSmaller(UnifyResultParser.SmallerContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitSmaller(UnifyResultParser.SmallerContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterTypeVar(UnifyResultParser.TypeVarContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitTypeVar(UnifyResultParser.TypeVarContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterType(UnifyResultParser.TypeContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitType(UnifyResultParser.TypeContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterOtherRule(UnifyResultParser.OtherRuleContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitOtherRule(UnifyResultParser.OtherRuleContext ctx) { }
+
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void enterEveryRule(ParserRuleContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void exitEveryRule(ParserRuleContext ctx) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void visitTerminal(TerminalNode node) { }
+ /**
+ * {@inheritDoc}
+ *
+ * The default implementation does nothing.
+ */
+ @Override public void visitErrorNode(ErrorNode node) { }
+}
\ No newline at end of file
diff --git a/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultLexer.java b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultLexer.java
new file mode 100644
index 00000000..b8660eba
--- /dev/null
+++ b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultLexer.java
@@ -0,0 +1,134 @@
+// Generated from UnifyResult.g4 by ANTLR 4.7
+package de.dhbwstuttgart.sat.asp.parser.antlr;
+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 UnifyResultLexer extends Lexer {
+ static { RuntimeMetaData.checkVersion("4.7", 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, PARAMLIST_NAME=6, EQUALS_NAME=7,
+ SMALLER_NAME=8, TYPEVAR_NAME=9, TYPE_NAME=10, NAME=11, WS=12, LINE_COMMENT=13;
+ public static String[] channelNames = {
+ "DEFAULT_TOKEN_CHANNEL", "HIDDEN"
+ };
+
+ public static String[] modeNames = {
+ "DEFAULT_MODE"
+ };
+
+ public static final String[] ruleNames = {
+ "T__0", "T__1", "T__2", "T__3", "T__4", "PARAMLIST_NAME", "EQUALS_NAME",
+ "SMALLER_NAME", "TYPEVAR_NAME", "TYPE_NAME", "NAME", "WS", "LINE_COMMENT"
+ };
+
+ private static final String[] _LITERAL_NAMES = {
+ null, "'ANSWER'", "'.'", "'('", "','", "')'", "'param'", "'equals'", "'smaller'",
+ "'typeVar'", "'type'"
+ };
+ private static final String[] _SYMBOLIC_NAMES = {
+ null, null, null, null, null, null, "PARAMLIST_NAME", "EQUALS_NAME", "SMALLER_NAME",
+ "TYPEVAR_NAME", "TYPE_NAME", "NAME", "WS", "LINE_COMMENT"
+ };
+ 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] = "";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+
+ public UnifyResultLexer(CharStream input) {
+ super(input);
+ _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+
+ @Override
+ public String getGrammarFileName() { return "UnifyResult.g4"; }
+
+ @Override
+ public String[] getRuleNames() { return ruleNames; }
+
+ @Override
+ public String getSerializedATN() { return _serializedATN; }
+
+ @Override
+ public String[] getChannelNames() { return channelNames; }
+
+ @Override
+ public String[] getModeNames() { return modeNames; }
+
+ @Override
+ public ATN getATN() { return _ATN; }
+
+ public static final String _serializedATN =
+ "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\17c\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\3\2\3\2\3\2\3\2\3\2\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\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\b\3"+
+ "\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\13"+
+ "\3\13\3\13\3\13\3\13\3\f\6\fP\n\f\r\f\16\fQ\3\r\6\rU\n\r\r\r\16\rV\3\r"+
+ "\3\r\3\16\3\16\7\16]\n\16\f\16\16\16`\13\16\3\16\3\16\2\2\17\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\3\2\5\6\2\62;C\\"+
+ "aac|\5\2\13\f\16\17\"\"\4\2\f\f\17\17\2e\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\3\35"+
+ "\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\62"+
+ "\3\2\2\2\219\3\2\2\2\23A\3\2\2\2\25I\3\2\2\2\27O\3\2\2\2\31T\3\2\2\2\33"+
+ "Z\3\2\2\2\35\36\7C\2\2\36\37\7P\2\2\37 \7U\2\2 !\7Y\2\2!\"\7G\2\2\"#\7"+
+ "T\2\2#\4\3\2\2\2$%\7\60\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,-\7r\2\2-.\7c\2\2./\7t\2\2/\60\7c\2\2"+
+ "\60\61\7o\2\2\61\16\3\2\2\2\62\63\7g\2\2\63\64\7s\2\2\64\65\7w\2\2\65"+
+ "\66\7c\2\2\66\67\7n\2\2\678\7u\2\28\20\3\2\2\29:\7u\2\2:;\7o\2\2;<\7c"+
+ "\2\2<=\7n\2\2=>\7n\2\2>?\7g\2\2?@\7t\2\2@\22\3\2\2\2AB\7v\2\2BC\7{\2\2"+
+ "CD\7r\2\2DE\7g\2\2EF\7X\2\2FG\7c\2\2GH\7t\2\2H\24\3\2\2\2IJ\7v\2\2JK\7"+
+ "{\2\2KL\7r\2\2LM\7g\2\2M\26\3\2\2\2NP\t\2\2\2ON\3\2\2\2PQ\3\2\2\2QO\3"+
+ "\2\2\2QR\3\2\2\2R\30\3\2\2\2SU\t\3\2\2TS\3\2\2\2UV\3\2\2\2VT\3\2\2\2V"+
+ "W\3\2\2\2WX\3\2\2\2XY\b\r\2\2Y\32\3\2\2\2Z^\7\'\2\2[]\n\4\2\2\\[\3\2\2"+
+ "\2]`\3\2\2\2^\\\3\2\2\2^_\3\2\2\2_a\3\2\2\2`^\3\2\2\2ab\b\16\2\2b\34\3"+
+ "\2\2\2\6\2QV^\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);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultLexer.tokens b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultLexer.tokens
new file mode 100644
index 00000000..8f9c0e0a
--- /dev/null
+++ b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultLexer.tokens
@@ -0,0 +1,23 @@
+T__0=1
+T__1=2
+T__2=3
+T__3=4
+T__4=5
+PARAMLIST_NAME=6
+EQUALS_NAME=7
+SMALLER_NAME=8
+TYPEVAR_NAME=9
+TYPE_NAME=10
+NAME=11
+WS=12
+LINE_COMMENT=13
+'ANSWER'=1
+'.'=2
+'('=3
+','=4
+')'=5
+'param'=6
+'equals'=7
+'smaller'=8
+'typeVar'=9
+'type'=10
diff --git a/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultListener.java b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultListener.java
new file mode 100644
index 00000000..6158b123
--- /dev/null
+++ b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultListener.java
@@ -0,0 +1,110 @@
+// Generated from UnifyResult.g4 by ANTLR 4.7
+package de.dhbwstuttgart.sat.asp.parser.antlr;
+import org.antlr.v4.runtime.tree.ParseTreeListener;
+
+/**
+ * This interface defines a complete listener for a parse tree produced by
+ * {@link UnifyResultParser}.
+ */
+public interface UnifyResultListener extends ParseTreeListener {
+ /**
+ * Enter a parse tree produced by {@link UnifyResultParser#answer}.
+ * @param ctx the parse tree
+ */
+ void enterAnswer(UnifyResultParser.AnswerContext ctx);
+ /**
+ * Exit a parse tree produced by {@link UnifyResultParser#answer}.
+ * @param ctx the parse tree
+ */
+ void exitAnswer(UnifyResultParser.AnswerContext ctx);
+ /**
+ * Enter a parse tree produced by {@link UnifyResultParser#resultSetRule}.
+ * @param ctx the parse tree
+ */
+ void enterResultSetRule(UnifyResultParser.ResultSetRuleContext ctx);
+ /**
+ * Exit a parse tree produced by {@link UnifyResultParser#resultSetRule}.
+ * @param ctx the parse tree
+ */
+ void exitResultSetRule(UnifyResultParser.ResultSetRuleContext ctx);
+ /**
+ * Enter a parse tree produced by {@link UnifyResultParser#parameterList}.
+ * @param ctx the parse tree
+ */
+ void enterParameterList(UnifyResultParser.ParameterListContext ctx);
+ /**
+ * Exit a parse tree produced by {@link UnifyResultParser#parameterList}.
+ * @param ctx the parse tree
+ */
+ void exitParameterList(UnifyResultParser.ParameterListContext ctx);
+ /**
+ * Enter a parse tree produced by {@link UnifyResultParser#value}.
+ * @param ctx the parse tree
+ */
+ void enterValue(UnifyResultParser.ValueContext ctx);
+ /**
+ * Exit a parse tree produced by {@link UnifyResultParser#value}.
+ * @param ctx the parse tree
+ */
+ void exitValue(UnifyResultParser.ValueContext ctx);
+ /**
+ * Enter a parse tree produced by {@link UnifyResultParser#parameter}.
+ * @param ctx the parse tree
+ */
+ void enterParameter(UnifyResultParser.ParameterContext ctx);
+ /**
+ * Exit a parse tree produced by {@link UnifyResultParser#parameter}.
+ * @param ctx the parse tree
+ */
+ void exitParameter(UnifyResultParser.ParameterContext ctx);
+ /**
+ * Enter a parse tree produced by {@link UnifyResultParser#equals}.
+ * @param ctx the parse tree
+ */
+ void enterEquals(UnifyResultParser.EqualsContext ctx);
+ /**
+ * Exit a parse tree produced by {@link UnifyResultParser#equals}.
+ * @param ctx the parse tree
+ */
+ void exitEquals(UnifyResultParser.EqualsContext ctx);
+ /**
+ * Enter a parse tree produced by {@link UnifyResultParser#smaller}.
+ * @param ctx the parse tree
+ */
+ void enterSmaller(UnifyResultParser.SmallerContext ctx);
+ /**
+ * Exit a parse tree produced by {@link UnifyResultParser#smaller}.
+ * @param ctx the parse tree
+ */
+ void exitSmaller(UnifyResultParser.SmallerContext ctx);
+ /**
+ * Enter a parse tree produced by {@link UnifyResultParser#typeVar}.
+ * @param ctx the parse tree
+ */
+ void enterTypeVar(UnifyResultParser.TypeVarContext ctx);
+ /**
+ * Exit a parse tree produced by {@link UnifyResultParser#typeVar}.
+ * @param ctx the parse tree
+ */
+ void exitTypeVar(UnifyResultParser.TypeVarContext ctx);
+ /**
+ * Enter a parse tree produced by {@link UnifyResultParser#type}.
+ * @param ctx the parse tree
+ */
+ void enterType(UnifyResultParser.TypeContext ctx);
+ /**
+ * Exit a parse tree produced by {@link UnifyResultParser#type}.
+ * @param ctx the parse tree
+ */
+ void exitType(UnifyResultParser.TypeContext ctx);
+ /**
+ * Enter a parse tree produced by {@link UnifyResultParser#otherRule}.
+ * @param ctx the parse tree
+ */
+ void enterOtherRule(UnifyResultParser.OtherRuleContext ctx);
+ /**
+ * Exit a parse tree produced by {@link UnifyResultParser#otherRule}.
+ * @param ctx the parse tree
+ */
+ void exitOtherRule(UnifyResultParser.OtherRuleContext ctx);
+}
\ No newline at end of file
diff --git a/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultParser.java b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultParser.java
new file mode 100644
index 00000000..bf0789f1
--- /dev/null
+++ b/src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultParser.java
@@ -0,0 +1,639 @@
+// Generated from UnifyResult.g4 by ANTLR 4.7
+package de.dhbwstuttgart.sat.asp.parser.antlr;
+import org.antlr.v4.runtime.atn.*;
+import org.antlr.v4.runtime.dfa.DFA;
+import org.antlr.v4.runtime.*;
+import org.antlr.v4.runtime.misc.*;
+import org.antlr.v4.runtime.tree.*;
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
+public class UnifyResultParser extends Parser {
+ static { RuntimeMetaData.checkVersion("4.7", 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, PARAMLIST_NAME=6, EQUALS_NAME=7,
+ SMALLER_NAME=8, TYPEVAR_NAME=9, TYPE_NAME=10, NAME=11, WS=12, LINE_COMMENT=13;
+ public static final int
+ RULE_answer = 0, RULE_resultSetRule = 1, RULE_parameterList = 2, RULE_value = 3,
+ RULE_parameter = 4, RULE_equals = 5, RULE_smaller = 6, RULE_typeVar = 7,
+ RULE_type = 8, RULE_otherRule = 9;
+ public static final String[] ruleNames = {
+ "answer", "resultSetRule", "parameterList", "value", "parameter", "equals",
+ "smaller", "typeVar", "type", "otherRule"
+ };
+
+ private static final String[] _LITERAL_NAMES = {
+ null, "'ANSWER'", "'.'", "'('", "','", "')'", "'param'", "'equals'", "'smaller'",
+ "'typeVar'", "'type'"
+ };
+ private static final String[] _SYMBOLIC_NAMES = {
+ null, null, null, null, null, null, "PARAMLIST_NAME", "EQUALS_NAME", "SMALLER_NAME",
+ "TYPEVAR_NAME", "TYPE_NAME", "NAME", "WS", "LINE_COMMENT"
+ };
+ 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] = "";
+ }
+ }
+ }
+
+ @Override
+ @Deprecated
+ public String[] getTokenNames() {
+ return tokenNames;
+ }
+
+ @Override
+
+ public Vocabulary getVocabulary() {
+ return VOCABULARY;
+ }
+
+ @Override
+ public String getGrammarFileName() { return "UnifyResult.g4"; }
+
+ @Override
+ public String[] getRuleNames() { return ruleNames; }
+
+ @Override
+ public String getSerializedATN() { return _serializedATN; }
+
+ @Override
+ public ATN getATN() { return _ATN; }
+
+ public UnifyResultParser(TokenStream input) {
+ super(input);
+ _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
+ }
+ public static class AnswerContext extends ParserRuleContext {
+ public List resultSetRule() {
+ return getRuleContexts(ResultSetRuleContext.class);
+ }
+ public ResultSetRuleContext resultSetRule(int i) {
+ return getRuleContext(ResultSetRuleContext.class,i);
+ }
+ public AnswerContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_answer; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterAnswer(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitAnswer(this);
+ }
+ }
+
+ public final AnswerContext answer() throws RecognitionException {
+ AnswerContext _localctx = new AnswerContext(_ctx, getState());
+ enterRule(_localctx, 0, RULE_answer);
+ int _la;
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(20);
+ match(T__0);
+ setState(26);
+ _errHandler.sync(this);
+ _la = _input.LA(1);
+ while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << PARAMLIST_NAME) | (1L << EQUALS_NAME) | (1L << SMALLER_NAME) | (1L << TYPEVAR_NAME) | (1L << TYPE_NAME) | (1L << NAME))) != 0)) {
+ {
+ {
+ setState(21);
+ resultSetRule();
+ setState(22);
+ match(T__1);
+ }
+ }
+ setState(28);
+ _errHandler.sync(this);
+ _la = _input.LA(1);
+ }
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class ResultSetRuleContext extends ParserRuleContext {
+ public ParameterContext parameter() {
+ return getRuleContext(ParameterContext.class,0);
+ }
+ public EqualsContext equals() {
+ return getRuleContext(EqualsContext.class,0);
+ }
+ public SmallerContext smaller() {
+ return getRuleContext(SmallerContext.class,0);
+ }
+ public TypeVarContext typeVar() {
+ return getRuleContext(TypeVarContext.class,0);
+ }
+ public TypeContext type() {
+ return getRuleContext(TypeContext.class,0);
+ }
+ public OtherRuleContext otherRule() {
+ return getRuleContext(OtherRuleContext.class,0);
+ }
+ public ResultSetRuleContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_resultSetRule; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterResultSetRule(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitResultSetRule(this);
+ }
+ }
+
+ public final ResultSetRuleContext resultSetRule() throws RecognitionException {
+ ResultSetRuleContext _localctx = new ResultSetRuleContext(_ctx, getState());
+ enterRule(_localctx, 2, RULE_resultSetRule);
+ try {
+ setState(35);
+ _errHandler.sync(this);
+ switch (_input.LA(1)) {
+ case PARAMLIST_NAME:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(29);
+ parameter();
+ }
+ break;
+ case EQUALS_NAME:
+ enterOuterAlt(_localctx, 2);
+ {
+ setState(30);
+ equals();
+ }
+ break;
+ case SMALLER_NAME:
+ enterOuterAlt(_localctx, 3);
+ {
+ setState(31);
+ smaller();
+ }
+ break;
+ case TYPEVAR_NAME:
+ enterOuterAlt(_localctx, 4);
+ {
+ setState(32);
+ typeVar();
+ }
+ break;
+ case TYPE_NAME:
+ enterOuterAlt(_localctx, 5);
+ {
+ setState(33);
+ type();
+ }
+ break;
+ case NAME:
+ enterOuterAlt(_localctx, 6);
+ {
+ setState(34);
+ otherRule();
+ }
+ break;
+ default:
+ throw new NoViableAltException(this);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class ParameterListContext extends ParserRuleContext {
+ public List value() {
+ return getRuleContexts(ValueContext.class);
+ }
+ public ValueContext value(int i) {
+ return getRuleContext(ValueContext.class,i);
+ }
+ public ParameterListContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_parameterList; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterParameterList(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitParameterList(this);
+ }
+ }
+
+ public final ParameterListContext parameterList() throws RecognitionException {
+ ParameterListContext _localctx = new ParameterListContext(_ctx, getState());
+ enterRule(_localctx, 4, RULE_parameterList);
+ int _la;
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(37);
+ match(T__2);
+ setState(38);
+ value();
+ setState(43);
+ _errHandler.sync(this);
+ _la = _input.LA(1);
+ while (_la==T__3) {
+ {
+ {
+ setState(39);
+ match(T__3);
+ setState(40);
+ value();
+ }
+ }
+ setState(45);
+ _errHandler.sync(this);
+ _la = _input.LA(1);
+ }
+ setState(46);
+ match(T__4);
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class ValueContext extends ParserRuleContext {
+ public TerminalNode NAME() { return getToken(UnifyResultParser.NAME, 0); }
+ public ResultSetRuleContext resultSetRule() {
+ return getRuleContext(ResultSetRuleContext.class,0);
+ }
+ public ValueContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_value; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterValue(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitValue(this);
+ }
+ }
+
+ public final ValueContext value() throws RecognitionException {
+ ValueContext _localctx = new ValueContext(_ctx, getState());
+ enterRule(_localctx, 6, RULE_value);
+ try {
+ setState(50);
+ _errHandler.sync(this);
+ switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) {
+ case 1:
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(48);
+ match(NAME);
+ }
+ break;
+ case 2:
+ enterOuterAlt(_localctx, 2);
+ {
+ setState(49);
+ resultSetRule();
+ }
+ break;
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class ParameterContext extends ParserRuleContext {
+ public TerminalNode PARAMLIST_NAME() { return getToken(UnifyResultParser.PARAMLIST_NAME, 0); }
+ public ParameterListContext parameterList() {
+ return getRuleContext(ParameterListContext.class,0);
+ }
+ public ParameterContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_parameter; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterParameter(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitParameter(this);
+ }
+ }
+
+ public final ParameterContext parameter() throws RecognitionException {
+ ParameterContext _localctx = new ParameterContext(_ctx, getState());
+ enterRule(_localctx, 8, RULE_parameter);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(52);
+ match(PARAMLIST_NAME);
+ setState(53);
+ parameterList();
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class EqualsContext extends ParserRuleContext {
+ public TerminalNode EQUALS_NAME() { return getToken(UnifyResultParser.EQUALS_NAME, 0); }
+ public ParameterListContext parameterList() {
+ return getRuleContext(ParameterListContext.class,0);
+ }
+ public EqualsContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_equals; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterEquals(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitEquals(this);
+ }
+ }
+
+ public final EqualsContext equals() throws RecognitionException {
+ EqualsContext _localctx = new EqualsContext(_ctx, getState());
+ enterRule(_localctx, 10, RULE_equals);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(55);
+ match(EQUALS_NAME);
+ setState(56);
+ parameterList();
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class SmallerContext extends ParserRuleContext {
+ public TerminalNode SMALLER_NAME() { return getToken(UnifyResultParser.SMALLER_NAME, 0); }
+ public ParameterListContext parameterList() {
+ return getRuleContext(ParameterListContext.class,0);
+ }
+ public SmallerContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_smaller; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterSmaller(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitSmaller(this);
+ }
+ }
+
+ public final SmallerContext smaller() throws RecognitionException {
+ SmallerContext _localctx = new SmallerContext(_ctx, getState());
+ enterRule(_localctx, 12, RULE_smaller);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(58);
+ match(SMALLER_NAME);
+ setState(59);
+ parameterList();
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class TypeVarContext extends ParserRuleContext {
+ public TerminalNode TYPEVAR_NAME() { return getToken(UnifyResultParser.TYPEVAR_NAME, 0); }
+ public ParameterListContext parameterList() {
+ return getRuleContext(ParameterListContext.class,0);
+ }
+ public TypeVarContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_typeVar; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterTypeVar(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitTypeVar(this);
+ }
+ }
+
+ public final TypeVarContext typeVar() throws RecognitionException {
+ TypeVarContext _localctx = new TypeVarContext(_ctx, getState());
+ enterRule(_localctx, 14, RULE_typeVar);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(61);
+ match(TYPEVAR_NAME);
+ setState(62);
+ parameterList();
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class TypeContext extends ParserRuleContext {
+ public TerminalNode TYPE_NAME() { return getToken(UnifyResultParser.TYPE_NAME, 0); }
+ public ParameterListContext parameterList() {
+ return getRuleContext(ParameterListContext.class,0);
+ }
+ public TypeContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_type; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterType(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitType(this);
+ }
+ }
+
+ public final TypeContext type() throws RecognitionException {
+ TypeContext _localctx = new TypeContext(_ctx, getState());
+ enterRule(_localctx, 16, RULE_type);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(64);
+ match(TYPE_NAME);
+ setState(65);
+ parameterList();
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static class OtherRuleContext extends ParserRuleContext {
+ public TerminalNode NAME() { return getToken(UnifyResultParser.NAME, 0); }
+ public ParameterListContext parameterList() {
+ return getRuleContext(ParameterListContext.class,0);
+ }
+ public OtherRuleContext(ParserRuleContext parent, int invokingState) {
+ super(parent, invokingState);
+ }
+ @Override public int getRuleIndex() { return RULE_otherRule; }
+ @Override
+ public void enterRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterOtherRule(this);
+ }
+ @Override
+ public void exitRule(ParseTreeListener listener) {
+ if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitOtherRule(this);
+ }
+ }
+
+ public final OtherRuleContext otherRule() throws RecognitionException {
+ OtherRuleContext _localctx = new OtherRuleContext(_ctx, getState());
+ enterRule(_localctx, 18, RULE_otherRule);
+ try {
+ enterOuterAlt(_localctx, 1);
+ {
+ setState(67);
+ match(NAME);
+ setState(68);
+ parameterList();
+ }
+ }
+ catch (RecognitionException re) {
+ _localctx.exception = re;
+ _errHandler.reportError(this, re);
+ _errHandler.recover(this, re);
+ }
+ finally {
+ exitRule();
+ }
+ return _localctx;
+ }
+
+ public static final String _serializedATN =
+ "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\17I\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\3"+
+ "\2\3\2\3\2\3\2\7\2\33\n\2\f\2\16\2\36\13\2\3\3\3\3\3\3\3\3\3\3\3\3\5\3"+
+ "&\n\3\3\4\3\4\3\4\3\4\7\4,\n\4\f\4\16\4/\13\4\3\4\3\4\3\5\3\5\5\5\65\n"+
+ "\5\3\6\3\6\3\6\3\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\t\3\n\3\n\3\n\3\13\3"+
+ "\13\3\13\3\13\2\2\f\2\4\6\b\n\f\16\20\22\24\2\2\2F\2\26\3\2\2\2\4%\3\2"+
+ "\2\2\6\'\3\2\2\2\b\64\3\2\2\2\n\66\3\2\2\2\f9\3\2\2\2\16<\3\2\2\2\20?"+
+ "\3\2\2\2\22B\3\2\2\2\24E\3\2\2\2\26\34\7\3\2\2\27\30\5\4\3\2\30\31\7\4"+
+ "\2\2\31\33\3\2\2\2\32\27\3\2\2\2\33\36\3\2\2\2\34\32\3\2\2\2\34\35\3\2"+
+ "\2\2\35\3\3\2\2\2\36\34\3\2\2\2\37&\5\n\6\2 &\5\f\7\2!&\5\16\b\2\"&\5"+
+ "\20\t\2#&\5\22\n\2$&\5\24\13\2%\37\3\2\2\2% \3\2\2\2%!\3\2\2\2%\"\3\2"+
+ "\2\2%#\3\2\2\2%$\3\2\2\2&\5\3\2\2\2\'(\7\5\2\2(-\5\b\5\2)*\7\6\2\2*,\5"+
+ "\b\5\2+)\3\2\2\2,/\3\2\2\2-+\3\2\2\2-.\3\2\2\2.\60\3\2\2\2/-\3\2\2\2\60"+
+ "\61\7\7\2\2\61\7\3\2\2\2\62\65\7\r\2\2\63\65\5\4\3\2\64\62\3\2\2\2\64"+
+ "\63\3\2\2\2\65\t\3\2\2\2\66\67\7\b\2\2\678\5\6\4\28\13\3\2\2\29:\7\t\2"+
+ "\2:;\5\6\4\2;\r\3\2\2\2<=\7\n\2\2=>\5\6\4\2>\17\3\2\2\2?@\7\13\2\2@A\5"+
+ "\6\4\2A\21\3\2\2\2BC\7\f\2\2CD\5\6\4\2D\23\3\2\2\2EF\7\r\2\2FG\5\6\4\2"+
+ "G\25\3\2\2\2\6\34%-\64";
+ 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);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/de/dhbwstuttgart/sat/asp/parser/model/ParsedASPStatement.java b/src/de/dhbwstuttgart/sat/asp/parser/model/ParsedASPStatement.java
deleted file mode 100644
index 614bddb0..00000000
--- a/src/de/dhbwstuttgart/sat/asp/parser/model/ParsedASPStatement.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package de.dhbwstuttgart.sat.asp.parser.model;
-
-public class ParsedASPStatement {
- public ParsedASPStatement(String statement){
-
- }
-}
diff --git a/src/de/dhbwstuttgart/sat/asp/parser/model/ParsedType.java b/src/de/dhbwstuttgart/sat/asp/parser/model/ParsedType.java
new file mode 100644
index 00000000..d9e06e50
--- /dev/null
+++ b/src/de/dhbwstuttgart/sat/asp/parser/model/ParsedType.java
@@ -0,0 +1,12 @@
+package de.dhbwstuttgart.sat.asp.parser.model;
+
+import java.util.List;
+
+public class ParsedType {
+ public final String name;
+ public final String params;
+ public ParsedType(String name, String params){
+ this.name = name;
+ this.params = params;
+ }
+}
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/ASPFactory.java b/src/de/dhbwstuttgart/sat/asp/writer/ASPFactory.java
new file mode 100644
index 00000000..1777eabd
--- /dev/null
+++ b/src/de/dhbwstuttgart/sat/asp/writer/ASPFactory.java
@@ -0,0 +1,127 @@
+package de.dhbwstuttgart.sat.asp.writer;
+
+import de.dhbwstuttgart.exceptions.NotImplementedException;
+import de.dhbwstuttgart.parser.SyntaxTreeGenerator.FCGenerator;
+import de.dhbwstuttgart.sat.asp.ASPStringConverter;
+import de.dhbwstuttgart.sat.asp.model.ASPRule;
+import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
+import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
+import de.dhbwstuttgart.syntaxtree.type.*;
+import de.dhbwstuttgart.typeinference.constraints.Constraint;
+import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
+import de.dhbwstuttgart.typeinference.constraints.Pair;
+import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
+
+import java.util.*;
+
+public class ASPFactory implements TypeVisitor{
+
+ public static String generateASP(ConstraintSet constraints, Collection fcClasses) throws ClassNotFoundException{
+ ASPFactory factory = new ASPFactory();
+ factory.convertFC(fcClasses);
+ List> constraints1 = constraints.cartesianProduct().iterator().next();
+ for(Constraint constraint : constraints1){
+ for(Pair p : constraint){
+ factory.convertPair(p);
+ }
+ }
+
+ return factory.writer.getASPFile();
+ }
+
+ ASPWriter writer = new ASPWriter();
+ boolean isFCType = false;
+
+ private void convertFC(Collection classes) throws ClassNotFoundException {
+ Set fc = FCGenerator.toFC(classes);
+ isFCType = true;
+ for(Pair fcp : fc){
+ convertPair(fcp);
+ }
+ isFCType = false;
+ }
+
+ private void convertPair(Pair p){
+ String ls = p.TA1.acceptTV(this);
+ String rs = p.TA2.acceptTV(this);
+ ASPStatement pairStmt = null;
+ if(p.GetOperator().equals(PairOperator.SMALLERDOT)){
+ pairStmt = makeStatement(ASPRule.ASP_PAIR_SMALLER_DOT_NAME.toString(), ls, rs);
+ }else if(p.GetOperator().equals(PairOperator.EQUALSDOT)){
+ pairStmt = makeStatement(ASPRule.ASP_PAIR_EQUALS_NAME.toString(), ls, rs);
+ }else if(p.GetOperator().equals(PairOperator.SMALLER)){
+ pairStmt = makeStatement(ASPRule.ASP_PAIR_SMALLER_NAME.toString(), ls, rs);
+ }else throw new NotImplementedException();
+ writer.add(pairStmt);
+ }
+
+ private ASPStatement makeStatement(String rule, String... params){
+ String stmt = rule + "(";
+ for(String param : params){
+ stmt += param + ",";
+ }
+ stmt = stmt.substring(0,stmt.length()-1);
+ stmt += ")";
+ return new ASPStatement(stmt);
+ }
+
+ private String convertParameterlist(List pointers){
+ String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
+ Iterator it = pointers.iterator();
+ String p = pointer;
+ if(!it.hasNext()){
+ return ASPRule.ASP_PARAMLIST_END_POINTER.toString();
+ }
+ while (it.hasNext()){
+ ASPStatement stmt;
+ String type = it.next();
+ String nextP = ASPStringConverter.toConstant(NameGenerator.makeNewName());
+ if(it.hasNext()){
+ stmt = makeStatement(ASPRule.ASP_PARAMLIST_NAME.toString(), p, type, nextP);
+ }else{
+ stmt = makeStatement(ASPRule.ASP_PARAMLIST_NAME.toString(), p, type,
+ ASPRule.ASP_PARAMLIST_END_POINTER.toString());
+ }
+ p = nextP;
+ writer.add(stmt);
+ }
+ return pointer;
+ }
+
+ @Override
+ public String visit(RefType refType) {
+ String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
+ List params = new ArrayList<>();
+ for(RefTypeOrTPHOrWildcardOrGeneric param : refType.getParaList()){
+ params.add(param.acceptTV(this));
+ }
+ String typeName = ASPStringConverter.toConstant(refType.getName());
+ String ruleName = isFCType?ASPRule.ASP_FCTYPE.toString():ASPRule.ASP_TYPE.toString();
+ ASPStatement stmt = makeStatement(ruleName, pointer, typeName, convertParameterlist(params));
+ writer.add(stmt);
+ return pointer;
+ }
+
+ @Override
+ public String visit(SuperWildcardType superWildcardType) {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public String visit(TypePlaceholder typePlaceholder) {
+ String name = ASPStringConverter.toConstant(typePlaceholder.getName());
+ ASPStatement stmt = makeStatement(ASPRule.ASP_TYPE_VAR.toString(), name);
+ writer.add(stmt);
+ return name;
+ }
+
+ @Override
+ public String visit(ExtendsWildcardType extendsWildcardType) {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public String visit(GenericRefType genericRefType) {
+ throw new NotImplementedException();
+ }
+}
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/ASPGencayFactory.java b/src/de/dhbwstuttgart/sat/asp/writer/ASPGencayFactory.java
new file mode 100644
index 00000000..11408c25
--- /dev/null
+++ b/src/de/dhbwstuttgart/sat/asp/writer/ASPGencayFactory.java
@@ -0,0 +1,264 @@
+package de.dhbwstuttgart.sat.asp.writer;
+
+import de.dhbwstuttgart.exceptions.NotImplementedException;
+import de.dhbwstuttgart.parser.SyntaxTreeGenerator.FCGenerator;
+import de.dhbwstuttgart.sat.asp.ASPStringConverter;
+import de.dhbwstuttgart.sat.asp.model.ASPGencayRule;
+import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
+import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
+import de.dhbwstuttgart.syntaxtree.type.*;
+import de.dhbwstuttgart.typeinference.constraints.Constraint;
+import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
+import de.dhbwstuttgart.typeinference.constraints.Pair;
+import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
+
+import java.util.*;
+
+
+public class ASPGencayFactory implements TypeVisitor {
+ /* TODO:
+ * Alle TPHs müssen als var(tph) definiert sein
+ * Wenn es eine Variable ist, dann direkt in die type-Regel schreiben: type(p, type, tph)
+ * Für die FCTypen eindeutige Namen für die pph-Regeln
+ * (ergibt sich von selbst, weil man einfach den Namen der TPH in der FC verwenden kann)
+ * paramOrder wird benötigt!
+ * Nur bei parameterlisten > 1
+ * paramOrder(paralistPointer, parameter, num)
+ * (ähnlich meiner paramNum)
+ * Trennung von FC und Eq:
+ * sub -> type -> param
+ * ...Eq -> typeEq -> paramEq
+ * type..(_,_,_p): p kann sein:
+ * 1. Variable
+ * 2. ParameterPointer
+ * 3. null
+ */
+ ASPWriter writer = new ASPWriter();
+ boolean isFCType = false;
+
+ private static List generateVar(ConstraintSet constraints){
+ List ret = new ArrayList<>();
+ for(TypePlaceholder tph : getInvolvedTPHS(constraints)){
+ ret.add(makeStatement(ASPGencayRule.ASP_TYPE_VAR.toString(),
+ ASPStringConverter.toConstant(tph.getName())));
+ }
+ return ret;
+ }
+
+ protected static Collection getInvolvedTPHS(ConstraintSet toTest) {
+ List ret = new ArrayList<>();
+ toTest.map((Pair p)-> {
+ ret.addAll(p.TA1.acceptTV(new TPHExtractor()));
+ ret.addAll(p.TA2.acceptTV(new TPHExtractor()));
+ return p;
+ });
+ return ret;
+ }
+
+ public static String generateASP(ConstraintSet constraints, Collection fcClasses) throws ClassNotFoundException{
+ ASPGencayFactory factory = new ASPGencayFactory();
+ factory.convertFC(fcClasses);
+ List> constraints1 = constraints.cartesianProduct().iterator().next();
+ for(Constraint constraint : constraints1){
+ for(Pair p : constraint){
+ factory.convertPair(p);
+ }
+ }
+ factory.writer.addAll(generateVar(constraints));
+
+ return factory.writer.getASPFile();
+ }
+
+ private void convertFC(Collection classes) throws ClassNotFoundException {
+ Set fc = FCGenerator.toFC(classes);
+ isFCType = true;
+ for(Pair fcp : fc){
+ generateTheta((RefType) fcp.TA1);
+ generateTheta((RefType) fcp.TA2);
+ convertPair(fcp);
+ }
+ isFCType = false;
+ }
+
+ private void generateTheta(RefType t){
+ String rule = "theta"+t.getParaList().size() ;
+ String name = ASPStringConverter.toConstant(t.getName());
+ writer.add(makeStatement(rule, name));
+ }
+
+ private void convertPair(Pair p){
+ String ls = p.TA1.acceptTV(this);
+ String rs = p.TA2.acceptTV(this);
+ ASPStatement pairStmt = null;
+ if(p.GetOperator().equals(PairOperator.SMALLERDOT)){
+ pairStmt = makeStatement(ASPGencayRule.ASP_PAIR_SMALLER_DOT_NAME.toString(), ls, rs);
+ }else if(p.GetOperator().equals(PairOperator.EQUALSDOT)){
+ pairStmt = makeStatement(ASPGencayRule.ASP_PAIR_EQUALS_NAME.toString(), ls, rs);
+ }else if(p.GetOperator().equals(PairOperator.SMALLER)){
+ pairStmt = makeStatement(ASPGencayRule.ASP_PAIR_SMALLER_NAME.toString(), ls, rs);
+ }else throw new NotImplementedException();
+ writer.add(pairStmt);
+ }
+
+ private static ASPStatement makeStatement(String rule, String... params){
+ String stmt = rule + "(";
+ for(String param : params){
+ stmt += param + ",";
+ }
+ stmt = stmt.substring(0,stmt.length()-1);
+ stmt += ")";
+ return new ASPStatement(stmt);
+ }
+
+ private String convertParameterlist(List pointers){
+ //if(pointers.size()==1)return pointers.get(0);
+ String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
+ Iterator it = pointers.iterator();
+ String p = pointer;
+ String paramname = ASPGencayRule.ASP_PARAMLIST_NAME.toString();
+ if(this.isFCType)paramname = ASPGencayRule.ASP_FC_PARAMLIST_NAME.toString();
+ if(!it.hasNext()){
+ return ASPGencayRule.ASP_PARAMLIST_END_POINTER.toString();
+ }
+ while (it.hasNext()){
+ ASPStatement stmt;
+ String type = it.next();
+ String nextP = ASPStringConverter.toConstant(NameGenerator.makeNewName());
+ if(it.hasNext()){
+ stmt = makeStatement(paramname, p, type, nextP);
+ }else{
+ stmt = makeStatement(paramname, p, type,
+ ASPGencayRule.ASP_PARAMLIST_END_POINTER.toString());
+ }
+ p = nextP;
+ writer.add(stmt);
+ }
+ return pointer;
+ }
+
+ //Wird zum erstellen der pph(..) Regeln gebraucht
+ private String currentFCTypePointer = "";
+ @Override
+ public String visit(RefType refType) {
+ String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
+ currentFCTypePointer = pointer;
+ String paramPointer = ASPGencayRule.ASP_PARAMLIST_END_POINTER.toString();
+ if(refType.getParaList().size() == 1 ){
+ if(refType.getParaList().get(0) instanceof TypePlaceholder){
+ TypePlaceholder typePlaceholder = (TypePlaceholder) refType.getParaList().get(0);
+ paramPointer = typePlaceholder.acceptTV(this);
+ }
+ }else{
+ List params = null;
+ params = generateParameter(refType);
+ params.remove(0);
+ paramPointer = convertParameterlist(params);
+ if(refType.getParaList().size()>1){
+ //paramOrder generieren:
+ for(String param : params) {
+ ASPStatement pOstmt = makeStatement(ASPGencayRule.ASP_PARAMLIST_ORDER.toString(),
+ paramPointer, param);
+ writer.add(pOstmt);
+ }
+ }
+ }
+ String typeName = ASPStringConverter.toConstant(refType.getName());
+ String ruleName = isFCType? ASPGencayRule.ASP_FCTYPE.toString(): ASPGencayRule.ASP_TYPE.toString();
+ ASPStatement stmt = makeStatement(ruleName, pointer, typeName, paramPointer);
+ writer.add(stmt);
+ return pointer;
+ /*
+ String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
+ List params = null;
+ params = generateParameter(refType);
+ params.remove(0); //Das erste ist der eigentliche Typ kein parameter
+ String typeName = ASPStringConverter.toConstant(refType.getName());
+ String ruleName = isFCType? ASPGencayRule.ASP_FCTYPE.toString(): ASPGencayRule.ASP_TYPE.toString();
+ ASPStatement stmt = makeStatement(ruleName, pointer, typeName, convertParameterlist(params));
+ writer.add(stmt);
+ return pointer;
+ */
+ }
+
+ /**
+ * Erstellt die Parameterliste, wobei type auch schon als Parameter betrachtet wird.
+ * Die RefTypes werden nicht zu extra type-Regeln umgewandelt. Es wird nur ihr Name als Konstante benutzt
+ * Das funktioniert, weil nacher das ParamOrder zuteilt, welche Typen zusammenhängen.
+ * Diese funktion nur verwenden, wenn auch ein paramOrder generiert wird
+ */
+ private List generateParameter(RefType type){
+ List ret = new ArrayList<>();
+ ret.add(ASPStringConverter.toConstant(type.getName()));
+ for(RefTypeOrTPHOrWildcardOrGeneric param : type.getParaList()){
+ if(param instanceof RefType){
+ ret.addAll(generateParameter((RefType) param));
+ }else if(param instanceof TypePlaceholder){
+ ret.add(param.acceptTV(this));
+ }else throw new NotImplementedException();
+ }
+ return ret;
+ }
+
+ @Override
+ public String visit(SuperWildcardType superWildcardType) {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public String visit(TypePlaceholder typePlaceholder) {
+ String name = ASPStringConverter.toConstant(typePlaceholder.getName());
+
+ ASPStatement stmt = null;
+ if(isFCType){
+ stmt = makeStatement(ASPGencayRule.ASP_GENERIC_VAR.toString(),
+ currentFCTypePointer, name);
+ } else {
+ stmt = makeStatement(ASPGencayRule.ASP_TYPE_VAR.toString(), name);
+ }
+
+ writer.add(stmt);
+ return name;
+ }
+
+ @Override
+ public String visit(ExtendsWildcardType extendsWildcardType) {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public String visit(GenericRefType genericRefType) {
+ throw new NotImplementedException();
+ }
+
+ private static class TPHExtractor implements TypeVisitor>{
+ @Override
+ public List visit(RefType refType) {
+ ArrayList ret = new ArrayList<>();
+ for(RefTypeOrTPHOrWildcardOrGeneric param : refType.getParaList()){
+ ret.addAll(param.acceptTV(this));
+ }
+ return ret;
+ }
+
+ @Override
+ public List visit(SuperWildcardType superWildcardType) {
+ return superWildcardType.getInnerType().acceptTV(this);
+ }
+
+ @Override
+ public List visit(TypePlaceholder typePlaceholder) {
+ return Arrays.asList(typePlaceholder);
+ }
+
+ @Override
+ public List visit(ExtendsWildcardType extendsWildcardType) {
+ return extendsWildcardType.getInnerType().acceptTV(this);
+ }
+
+ @Override
+ public List visit(GenericRefType genericRefType) {
+ return new ArrayList<>();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/ASPGenerator.java b/src/de/dhbwstuttgart/sat/asp/writer/ASPGenerator.java
deleted file mode 100644
index 002e3c7f..00000000
--- a/src/de/dhbwstuttgart/sat/asp/writer/ASPGenerator.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package de.dhbwstuttgart.sat.asp.writer;
-
-import de.dhbwstuttgart.exceptions.NotImplementedException;
-import de.dhbwstuttgart.parser.scope.JavaClassName;
-import de.dhbwstuttgart.sat.asp.writer.model.*;
-import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
-import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
-import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
-import de.dhbwstuttgart.syntaxtree.type.*;
-import de.dhbwstuttgart.typeinference.constraints.Constraint;
-import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
-import de.dhbwstuttgart.typeinference.constraints.Pair;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-public class ASPGenerator {
- ASPWriter writer = new ASPWriter();
- private final String asp;
-
- public ASPGenerator(ConstraintSet constraints, Collection fcClasses){
- List> constraints1 = constraints.cartesianProduct().iterator().next();
- List constraintPairs = new ArrayList<>();
- for(Constraint constraint : constraints1){
- System.out.println(UnifyTypeFactory.convert(constraint));
- constraintPairs.addAll(constraint);
- }
- asp = toASP(constraintPairs, fcClasses);
- }
-
- public String getASP(){
- return asp;
- }
-
- private String toASP(List constraintSet, Collection fcClasses){
- TypeConverter converter = new TypeConverter();
- for(ClassOrInterface cl : fcClasses){
- ASPType superClass = cl.getSuperClass().acceptTV(converter);
- ASPPairSmaller fcEntry = new ASPPairSmaller(convert(cl), superClass);
- writer.add(new ASPStatement(fcEntry.toASP()));
- }
- for(Pair cons : constraintSet){
- writer.add(new ASPStatement(convert(cons).toASP()));
- }
-
- return writer.getASPFile();
- }
-
- private ASPPair convert(Pair pair){
- TypeConverter converter = new TypeConverter();
- ASPType ls = pair.TA1.acceptTV(converter);
- ASPType rs = pair.TA2.acceptTV(converter);
- if(pair.OperatorEqual()){
- return new ASPPairEquals(ls, rs);
- }else if(pair.OperatorSmallerDot()){
- return new ASPPairSmallerDot(ls, rs);
- }else throw new NotImplementedException();
- }
-
- private ASPType convert(ClassOrInterface cl){
- List paramList = new ArrayList<>();
- for(GenericTypeVar gtv : cl.getGenerics()){
- paramList.add(new ASPGenericType(toConstant(gtv.getName())));
- }
- ASPParameterList params = new ASPParameterList(paramList, writer);
- return new ASPRefType(toConstant(cl.getClassName()), params);
- }
-
- public static String toConstant(JavaClassName name){
- return toConstant(name.toString().replace(".", "_"));
- }
-
- public static String toConstant(String name){
- return "c" + name.toString().replace(".", "_");
- }
-
- private class TypeConverter implements TypeVisitor{
-
- @Override
- public ASPType visit(RefType type) {
- List paramList = new ArrayList<>();
- for(RefTypeOrTPHOrWildcardOrGeneric gtv : type.getParaList()){
- paramList.add(gtv.acceptTV(this));
- }
- ASPParameterList params = new ASPParameterList(paramList, writer);
- return new ASPRefType(toConstant(type.getName()), params);
- }
-
- @Override
- public ASPType visit(SuperWildcardType superWildcardType) {
- throw new NotImplementedException();
- }
-
- @Override
- public ASPType visit(TypePlaceholder typePlaceholder) {
- return new ASPTypeVar(toConstant(typePlaceholder.getName()));
- }
-
- @Override
- public ASPType visit(ExtendsWildcardType extendsWildcardType) {
- throw new NotImplementedException();
- }
-
- @Override
- public ASPType visit(GenericRefType genericRefType) {
- return new ASPRefType(toConstant(genericRefType.getName()),
- new ASPParameterList(new ArrayList<>(), writer));
- }
- }
-}
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPStatement.java b/src/de/dhbwstuttgart/sat/asp/writer/ASPStatement.java
similarity index 91%
rename from src/de/dhbwstuttgart/sat/asp/writer/model/ASPStatement.java
rename to src/de/dhbwstuttgart/sat/asp/writer/ASPStatement.java
index 76bb63e8..8d342464 100644
--- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPStatement.java
+++ b/src/de/dhbwstuttgart/sat/asp/writer/ASPStatement.java
@@ -1,4 +1,4 @@
-package de.dhbwstuttgart.sat.asp.writer.model;
+package de.dhbwstuttgart.sat.asp.writer;
public class ASPStatement {
private final String stmt;
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/ASPWriter.java b/src/de/dhbwstuttgart/sat/asp/writer/ASPWriter.java
index 450950d9..57aef860 100644
--- a/src/de/dhbwstuttgart/sat/asp/writer/ASPWriter.java
+++ b/src/de/dhbwstuttgart/sat/asp/writer/ASPWriter.java
@@ -1,8 +1,8 @@
package de.dhbwstuttgart.sat.asp.writer;
-import de.dhbwstuttgart.sat.asp.writer.model.ASPStatement;
-
+import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
public class ASPWriter {
@@ -19,4 +19,8 @@ public class ASPWriter {
}
return ret;
}
+
+ public void addAll(Collection aspStatements) {
+ content.addAll(aspStatements);
+ }
}
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPGenericType.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPGenericType.java
deleted file mode 100644
index 57619edf..00000000
--- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPGenericType.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package de.dhbwstuttgart.sat.asp.writer.model;
-
-import de.dhbwstuttgart.sat.asp.model.ASPRule;
-
-public class ASPGenericType implements ASPType{
- private final String name;
-
- public ASPGenericType(String name){
- this.name = name;
- }
-
- public String toString(){
- return ASPRule.ASP_GENERIC_TYPE_NAME + "(" + name + ")";
- }
-}
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPair.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPair.java
deleted file mode 100644
index 662f995c..00000000
--- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPair.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package de.dhbwstuttgart.sat.asp.writer.model;
-
-public abstract class ASPPair {
- public final ASPType leftSide;
- public final ASPType rightSide;
-
- public ASPPair(ASPType ls, ASPType rs){
- this.leftSide = ls;
- this.rightSide = rs;
- }
-
- public String toASP(){
- return this.getRuleName() + "(" + leftSide + ","+ rightSide + ")";
- }
-
- public String toString(){
- return toASP();
- }
-
- protected abstract String getRuleName();
-}
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairEquals.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairEquals.java
deleted file mode 100644
index 8806f2ce..00000000
--- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairEquals.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package de.dhbwstuttgart.sat.asp.writer.model;
-
-import de.dhbwstuttgart.sat.asp.model.ASPRule;
-
-public class ASPPairEquals extends ASPPair{
- public ASPPairEquals(ASPType ls, ASPType rs){
- super(ls, rs);
- }
-
- @Override
- protected String getRuleName() {
- return ASPRule.ASP_PAIR_EQUALS_NAME.toString();
- }
-}
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmaller.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmaller.java
deleted file mode 100644
index f57170f6..00000000
--- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmaller.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package de.dhbwstuttgart.sat.asp.writer.model;
-
-import de.dhbwstuttgart.sat.asp.model.ASPRule;
-
-import java.util.Map;
-
-public class ASPPairSmaller extends ASPPair{
- public ASPPairSmaller(ASPType ls, ASPType rs){
- super(ls, rs);
- }
-
- @Override
- protected String getRuleName() {
- return ASPRule.ASP_PAIR_SMALLER_NAME.toString();
- }
-}
\ No newline at end of file
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmallerDot.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmallerDot.java
deleted file mode 100644
index e8482bfc..00000000
--- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmallerDot.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package de.dhbwstuttgart.sat.asp.writer.model;
-
-import de.dhbwstuttgart.sat.asp.model.ASPRule;
-
-public class ASPPairSmallerDot extends ASPPair{
- public ASPPairSmallerDot(ASPType ls, ASPType rs){
- super(ls, rs);
- }
-
- @Override
- protected String getRuleName() {
- return ASPRule.ASP_PAIR_SMALLER_DOT_NAME.toString();
- }
-}
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPParameterList.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPParameterList.java
deleted file mode 100644
index 3c176e49..00000000
--- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPParameterList.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package de.dhbwstuttgart.sat.asp.writer.model;
-
-import de.dhbwstuttgart.sat.asp.model.ASPRule;
-import de.dhbwstuttgart.sat.asp.writer.ASPGenerator;
-import de.dhbwstuttgart.sat.asp.writer.ASPWriter;
-import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
-
-import java.util.Iterator;
-import java.util.List;
-
-public class ASPParameterList {
- public final String name;
- private final List types;
-
- public ASPParameterList(List types, ASPWriter writer){
- int paramNum = 0;
- this.types = types;
- if(types.size() == 0){
- name = ASPRule.ASP_PARAMLIST_END_POINTER.toString();
- }else{
- name = newName();
- String nextPointer = name;
- Iterator it = types.iterator();
- while(it.hasNext()){
- ASPType t = it.next();
- String param = nextPointer + "," + t.toString() + ",";
- nextPointer = newName();
- if(! it.hasNext())nextPointer = ASPRule.ASP_PARAMLIST_END_POINTER.toString();
- param += nextPointer;
- writer.add(new ASPStatement(ASPRule.ASP_PARAMLIST_NAME + "(" + param + ")"));
- writer.add(new ASPStatement(ASPRule.ASP_PARAMLISTNUMERATION_NAME + "(" + name + "," +t + "," + paramNum + ")"));
- paramNum++;
- //paramDefinitions.add(new ASPStatement(ASP_PARAMLIST_NAME + "(" + param + ")"));
- }
- }
- }
-
- private String newName() {
- return ASPGenerator.toConstant(NameGenerator.makeNewName());
- }
-
- public String toString(){
- return name;
- }
-}
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPRefType.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPRefType.java
deleted file mode 100644
index 6491ff33..00000000
--- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPRefType.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package de.dhbwstuttgart.sat.asp.writer.model;
-
-import de.dhbwstuttgart.sat.asp.model.ASPRule;
-
-public class ASPRefType implements ASPType {
- private final ASPParameterList params;
- private final String name;
-
- public ASPRefType(String name, ASPParameterList params){
- this.name = name;
- this.params = params;
- }
-
- public ASPParameterList getParams() {
- return params;
- }
-
- public String toString(){
- return ASPRule.ASP_TYPE + "(" + name +"," + params.name + ")";
- }
-}
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPType.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPType.java
deleted file mode 100644
index da694218..00000000
--- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPType.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package de.dhbwstuttgart.sat.asp.writer.model;
-
-public interface ASPType {
-}
diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPTypeVar.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPTypeVar.java
deleted file mode 100644
index 4b07d30b..00000000
--- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPTypeVar.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package de.dhbwstuttgart.sat.asp.writer.model;
-
-public class ASPTypeVar implements ASPType{
- private final String name;
-
- public ASPTypeVar(String name){
- this.name = name;
- }
-
- @Override
- public String toString() {
- return "typeVar("+ name +")";
- }
-}
diff --git a/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java b/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java
index 5d5fc3e2..72097fc0 100644
--- a/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java
+++ b/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java
@@ -13,6 +13,7 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
/**
@@ -26,11 +27,11 @@ public class ClassOrInterface extends SyntaxTreeNode implements TypeScope{
private GenericDeclarationList genericClassParameters;
private RefType superClass;
protected boolean isInterface;
- private List extends RefTypeOrTPHOrWildcardOrGeneric> implementedInterfaces;
+ private List implementedInterfaces;
private List constructors;
public ClassOrInterface(int modifiers, JavaClassName name, List fielddecl, List methods, List constructors, GenericDeclarationList genericClassParameters,
- RefType superClass, Boolean isInterface, List extends RefTypeOrTPHOrWildcardOrGeneric> implementedInterfaces, Token offset){
+ RefType superClass, Boolean isInterface, List implementedInterfaces, Token offset){
super(offset);
this.modifiers = modifiers;
this.name = name;
@@ -101,4 +102,8 @@ public class ClassOrInterface extends SyntaxTreeNode implements TypeScope{
public void accept(ASTVisitor visitor) {
visitor.visit(this);
}
+
+ public Collection getSuperInterfaces() {
+ return implementedInterfaces;
+ }
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/GenericTypeVar.java b/src/de/dhbwstuttgart/syntaxtree/GenericTypeVar.java
index 02042ca3..6ee03b60 100644
--- a/src/de/dhbwstuttgart/syntaxtree/GenericTypeVar.java
+++ b/src/de/dhbwstuttgart/syntaxtree/GenericTypeVar.java
@@ -1,7 +1,5 @@
package de.dhbwstuttgart.syntaxtree;
-import de.dhbwstuttgart.parser.scope.GenericTypeName;
-import de.dhbwstuttgart.parser.scope.JavaClassName;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
@@ -26,9 +24,9 @@ public class GenericTypeVar extends SyntaxTreeNode
*/
List extends RefTypeOrTPHOrWildcardOrGeneric> bounds=new ArrayList();
private Token endOffset;
- private GenericTypeName name;
+ private String name;
- public GenericTypeVar(GenericTypeName s, List extends RefTypeOrTPHOrWildcardOrGeneric> bounds, Token offset, Token endOffset)
+ public GenericTypeVar(String s, List extends RefTypeOrTPHOrWildcardOrGeneric> bounds, Token offset, Token endOffset)
{
super(offset);
name = s;
@@ -50,18 +48,15 @@ public class GenericTypeVar extends SyntaxTreeNode
return "BoGTV " + this.name;
}
- public GenericTypeName getName() {
- return name;
- }
-
- public String getParsedName(){
+ public String getName(){
return name.toString();
}
+ /*
public JavaClassName definingClass(){
return name.getParentClass();
}
-
+*/
@Override
public void accept(ASTVisitor visitor) {
visitor.visit(this);
diff --git a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java
index b0683569..52921c5d 100644
--- a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java
+++ b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java
@@ -8,7 +8,6 @@ import java.util.List;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.GenericContext;
-import de.dhbwstuttgart.parser.scope.GenericTypeName;
import de.dhbwstuttgart.parser.scope.JavaClassName;
import de.dhbwstuttgart.parser.scope.JavaClassRegistry;
import de.dhbwstuttgart.syntaxtree.Field;
@@ -43,19 +42,22 @@ public class ASTFactory {
}
int modifier = jreClass.getModifiers();
boolean isInterface = jreClass.isInterface();
+ //see: https://stackoverflow.com/questions/9934774/getting-generic-parameter-from-supertype-class
+ ParameterizedType parameterSuperClass = null;
+ Type tempSuperClass = jreClass.getGenericSuperclass();
+ if(tempSuperClass != null && tempSuperClass instanceof ParameterizedType)
+ parameterSuperClass = (ParameterizedType) tempSuperClass;
java.lang.Class superjreClass = jreClass.getSuperclass();
RefType superClass;
- if(superjreClass != null){
- List params = new ArrayList<>();
- for(TypeVariable tv : superjreClass.getTypeParameters()){
- params.add(new GenericRefType(new GenericTypeName(new GenericContext( name, null),tv.getName()), new NullToken()));
- }
- superClass = new RefType(new JavaClassName(superjreClass.getName()), params, new NullToken());
+ if(parameterSuperClass != null){
+ superClass = (RefType) convertType(parameterSuperClass);
+ }else if(superjreClass != null){
+ superClass = (RefType) convertType(superjreClass);
}else{//Jede Klasse und jedes Interface erbt von Object: (auch Object selbst!)
superClass = (RefType) createType(java.lang.Object.class, name, "");
}
List implementedInterfaces = new ArrayList<>();
- for(java.lang.Class jreInterface : jreClass.getInterfaces()){
+ for(Type jreInterface : jreClass.getGenericInterfaces()){
implementedInterfaces.add((RefType) createType(jreInterface, name, ""));
}
GenericDeclarationList genericDeclarationList = createGenerics(jreClass.getTypeParameters(), jreClass, null);
@@ -65,18 +67,46 @@ public class ASTFactory {
return new ClassOrInterface(modifier, name, felder, methoden, konstruktoren, genericDeclarationList, superClass,isInterface, implementedInterfaces, offset);
}
+ private static RefTypeOrTPHOrWildcardOrGeneric convertType(Type type){
+ if(type instanceof ParameterizedType){
+ List params = new ArrayList<>();
+ for(Type paramType : ((ParameterizedType)type).getActualTypeArguments()){
+ params.add(convertType(paramType));
+ }
+ JavaClassName name = new JavaClassName(((ParameterizedType) type).getRawType().getTypeName());
+ return new RefType(name, params, new NullToken());
+ }else if(type instanceof TypeVariable){
+ return new GenericRefType(((TypeVariable) type).getName(), new NullToken());
+ }else if(type instanceof Class){
+ List params = new ArrayList<>();
+ Class paramClass = (Class) type;
+ for(TypeVariable tv : paramClass.getTypeParameters()){
+ params.add(new GenericRefType(tv.getName(), new NullToken()));
+ }
+ JavaClassName name = new JavaClassName(paramClass.getName());
+ return new RefType(name, params, new NullToken());
+ }else throw new NotImplementedException();
+ }
+
private static Field createField(java.lang.reflect.Field field, JavaClassName jreClass) {
return new Field(field.getName(), createType(field.getType(), jreClass, null), field.getModifiers(), new NullToken());
}
+ //private static RefType createType(Class classType) {
+ // return createClass(classType).getType();
+ //}
+
private static de.dhbwstuttgart.syntaxtree.Constructor createConstructor(Constructor constructor, Class inClass) {
String name = constructor.getName();
RefTypeOrTPHOrWildcardOrGeneric returnType = createType(inClass, new JavaClassName(inClass.getName()), name);
Parameter[] jreParams = constructor.getParameters();
+ Type[] jreGenericParams = constructor.getGenericParameterTypes();
List params = new ArrayList<>();
- for(Parameter jreParam : jreParams){
- RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam.getType(),new JavaClassName(inClass.getName()), name);
- params.add(new FormalParameter(jreParam.getName(),paramType, new NullToken()));
+ int i = 0;
+ for(Type jreParam : jreGenericParams){
+ RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam,new JavaClassName(inClass.getName()), name);
+ params.add(new FormalParameter(jreParams[i].getName(),paramType, new NullToken()));
+ i++;
}
ParameterList parameterList = new ParameterList(params, new NullToken());
Block block = new Block(new ArrayList(), new NullToken());
@@ -89,21 +119,26 @@ public class ASTFactory {
}
return new de.dhbwstuttgart.syntaxtree.Constructor(modifier, name,returnType, parameterList, block, gtvDeclarations, offset, new ArrayList<>());
- }
-
- //private static RefType createType(Class classType) {
- // return createClass(classType).getType();
- //}
+ }
public static Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass){
String name = jreMethod.getName();
RefTypeOrTPHOrWildcardOrGeneric returnType;
- returnType = createType(jreMethod.getReturnType(),new JavaClassName(inClass.getName()), name);
+ Type jreRetType;
+ if(jreMethod.getGenericReturnType()!=null){
+ jreRetType = jreMethod.getGenericReturnType();
+ }else{
+ jreRetType = jreMethod.getReturnType();
+ }
+ returnType = createType(jreRetType,new JavaClassName(inClass.getName()), name);
Parameter[] jreParams = jreMethod.getParameters();
+ Type[] jreGenericParams = jreMethod.getGenericParameterTypes();
List params = new ArrayList<>();
- for(Parameter jreParam : jreParams){
- RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam.getType(),new JavaClassName(inClass.getName()), name);
- params.add(new FormalParameter(jreParam.getName(),paramType, new NullToken()));
+ int i = 0;
+ for(Type jreParam : jreGenericParams){
+ RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam,new JavaClassName(inClass.getName()), name);
+ params.add(new FormalParameter(jreParams[i].getName(),paramType, new NullToken()));
+ i++;
}
ParameterList parameterList = new ParameterList(params, new NullToken());
Block block = new Block(new ArrayList(), new NullToken());
@@ -153,9 +188,7 @@ public class ASTFactory {
}else{
if(type instanceof TypeVariable){
//GTVDeclarationContext via "(TypeVariable) type).getGenericDeclaration()"
- return new GenericRefType(
- new GenericTypeName(new GenericContext(parentClass, parentMethod),type.getTypeName()),
- new NullToken());
+ return new GenericRefType(type.getTypeName(), new NullToken());
}
List params = new ArrayList<>();
if(type instanceof ParameterizedType){
@@ -163,7 +196,12 @@ public class ASTFactory {
params.add(createType(t, parentClass, parentMethod));
}
}
- RefType ret = new RefType(new JavaClassName(type.getTypeName()), params, new NullToken());
+ String name = type.getTypeName();
+ if(name.contains("<")){ //Komischer fix. Type von Generischen Typen kann die Generics im Namen enthalten Type
+ //Diese entfernen:
+ name = name.split("<")[0];
+ }
+ RefType ret = new RefType(new JavaClassName(name), params, new NullToken());
return ret;
}
}
@@ -177,9 +215,7 @@ public class ASTFactory {
genericBounds.add((RefType) createType(bound, parentClass, parentMethod));
}
}
- return new de.dhbwstuttgart.syntaxtree.GenericTypeVar(
- new GenericTypeName(new GenericContext(parentClass, parentMethod), jreTVName)
- , genericBounds, new NullToken(), new NullToken());
+ return new de.dhbwstuttgart.syntaxtree.GenericTypeVar(jreTVName, genericBounds, new NullToken(), new NullToken());
}
public static ClassOrInterface createObjectClass() {
diff --git a/src/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java b/src/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java
index a962c2bc..e58ce50f 100644
--- a/src/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java
+++ b/src/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java
@@ -1,6 +1,8 @@
package de.dhbwstuttgart.syntaxtree.factory;
import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
import de.dhbwstuttgart.exceptions.DebugException;
@@ -8,8 +10,9 @@ import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.FCGenerator;
import de.dhbwstuttgart.parser.scope.JavaClassName;
+import de.dhbwstuttgart.sat.asp.model.ASPRule;
+import de.dhbwstuttgart.sat.asp.parser.ASPParser;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
-import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.*;
import de.dhbwstuttgart.syntaxtree.type.Void;
import de.dhbwstuttgart.syntaxtree.type.WildcardType;
@@ -35,7 +38,7 @@ public class UnifyTypeFactory {
Generell dürfen sie immer die gleichen Namen haben.
TODO: die transitive Hülle bilden
*/
- return new FiniteClosure(FCGenerator.toFC(fromClasses));
+ return new FiniteClosure(FCGenerator.toUnifyFC(fromClasses));
}
public static UnifyPair generateSmallerPair(UnifyType tl, UnifyType tr){
@@ -74,6 +77,16 @@ public class UnifyTypeFactory {
}
public static UnifyType convert(RefType t){
+ //Check if it is a FunN Type:
+ Pattern p = Pattern.compile("Fun(\\d+)");
+ Matcher m = p.matcher(t.getName().toString());
+ boolean b = m.matches();
+ if(b){
+ Integer N = Integer.valueOf(m.group(1));
+ if((N + 1) == t.getParaList().size()){
+ return convert(new FunN(t.getParaList()));
+ }
+ }
UnifyType ret;
if(t.getParaList() != null && t.getParaList().size() > 0){
List params = new ArrayList<>();
@@ -129,10 +142,13 @@ public class UnifyTypeFactory {
UnifyPair ret = generateSmallerDotPair(UnifyTypeFactory.convert(p.TA1)
, UnifyTypeFactory.convert(p.TA2));
return ret;
- }else if(p.GetOperator().equals(PairOperator.EQUALSDOT)){
+ }else if(p.GetOperator().equals(PairOperator.EQUALSDOT)) {
UnifyPair ret = generateEqualDotPair(UnifyTypeFactory.convert(p.TA1)
, UnifyTypeFactory.convert(p.TA2));
return ret;
+ }else if(p.GetOperator().equals(PairOperator.SMALLER)){
+ return generateSmallerPair(UnifyTypeFactory.convert(p.TA1),
+ UnifyTypeFactory.convert(p.TA2));
}else throw new NotImplementedException();
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/BinaryExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/BinaryExpr.java
index f7db0481..bb631e04 100644
--- a/src/de/dhbwstuttgart/syntaxtree/statement/BinaryExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/BinaryExpr.java
@@ -13,16 +13,17 @@ public class BinaryExpr extends Expression
}
public enum Operator{
- ADD,
- SUB,
- MUL,
- AND,
- OR,
- DIV,
- LESSTHAN,
- BIGGERTHAN,
- LESSEQUAL,
- BIGGEREQUAL
+ ADD, // +
+ SUB, // -
+ MUL, // *
+ MOD, // Modulo Operator %
+ AND, // &&
+ OR, // ||
+ DIV, // /
+ LESSTHAN, // <
+ BIGGERTHAN, // >
+ LESSEQUAL, // <=
+ BIGGEREQUAL // >=
}
public final Operator operation;
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/GenericRefType.java b/src/de/dhbwstuttgart/syntaxtree/type/GenericRefType.java
index a5d394aa..a14813e7 100644
--- a/src/de/dhbwstuttgart/syntaxtree/type/GenericRefType.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/GenericRefType.java
@@ -1,25 +1,19 @@
package de.dhbwstuttgart.syntaxtree.type;
-import de.dhbwstuttgart.parser.scope.GenericTypeName;
-import de.dhbwstuttgart.parser.scope.JavaClassName;
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
import de.dhbwstuttgart.typeinference.result.ResultSetVisitor;
import org.antlr.v4.runtime.Token;
public class GenericRefType extends RefTypeOrTPHOrWildcardOrGeneric
{
- private GenericTypeName name;
+ private String name;
- public GenericRefType(GenericTypeName name, Token offset)
+ public GenericRefType(String name, Token offset)
{
super(offset);
this.name = name;
}
- public GenericTypeName getName(){
- return name;
- }
-
public String getParsedName(){
return name.toString();
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
index 4cf85297..3c9a5907 100644
--- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
@@ -29,14 +29,17 @@ public class RefType extends RefTypeOrTPHOrWildcardOrGeneric
@Override
public String toString(){
- String params = "<";
- Iterator it = parameter.iterator();
- while(it.hasNext()){
- RefTypeOrTPHOrWildcardOrGeneric param = it.next();
- params += param.toString();
- if(it.hasNext())params += ", ";
+ String params = "";
+ if(parameter.size()>0){
+ params += "<";
+ Iterator it = parameter.iterator();
+ while(it.hasNext()){
+ RefTypeOrTPHOrWildcardOrGeneric param = it.next();
+ params += param.toString();
+ if(it.hasNext())params += ", ";
+ }
+ params += ">";
}
- params += ">";
return this.name.toString() + params;
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java
index f630583e..740c80e5 100644
--- a/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java
@@ -30,7 +30,7 @@ public class SuperWildcardType extends WildcardType{
* Beispiel: ? super Integer.
* Integer wird zurückgegeben.
*/
- public RefTypeOrTPHOrWildcardOrGeneric get_SuperType()
+ public RefTypeOrTPHOrWildcardOrGeneric getInnerType()
{
return this.innerType;
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/visual/OutputGenerator.java b/src/de/dhbwstuttgart/syntaxtree/visual/OutputGenerator.java
index c7a06502..0c623548 100644
--- a/src/de/dhbwstuttgart/syntaxtree/visual/OutputGenerator.java
+++ b/src/de/dhbwstuttgart/syntaxtree/visual/OutputGenerator.java
@@ -1,6 +1,5 @@
package de.dhbwstuttgart.syntaxtree.visual;
-import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.statement.*;
@@ -171,7 +170,7 @@ public class OutputGenerator implements ASTVisitor{
@Override
public void visit(GenericRefType genericRefType) {
- out.append(genericRefType.getName().toString());
+ out.append(genericRefType.getParsedName().toString());
}
@Override
diff --git a/src/de/dhbwstuttgart/syntaxtree/visual/ResultSetOutputGenerator.java b/src/de/dhbwstuttgart/syntaxtree/visual/ResultSetOutputGenerator.java
new file mode 100644
index 00000000..f50b05a6
--- /dev/null
+++ b/src/de/dhbwstuttgart/syntaxtree/visual/ResultSetOutputGenerator.java
@@ -0,0 +1,34 @@
+package de.dhbwstuttgart.syntaxtree.visual;
+
+import de.dhbwstuttgart.syntaxtree.type.*;
+import de.dhbwstuttgart.typeinference.result.*;
+
+public class ResultSetOutputGenerator extends OutputGenerator implements ResultSetVisitor{
+
+ public ResultSetOutputGenerator(StringBuilder out) {
+ super(out);
+ }
+
+ @Override
+ public void visit(PairTPHsmallerTPH p) {
+ print(p, "<");
+ }
+
+ @Override
+ public void visit(PairTPHequalRefTypeOrWildcardType p) {
+ print(p, "=.");
+ }
+
+ @Override
+ public void visit(PairTPHEqualTPH p) {
+ print(p, "=.");
+ }
+
+ private void print(ResultPair p , String operator){
+ out.append("(");
+ p.getLeft().accept((ResultSetVisitor) this);
+ out.append(" "+operator+" ");
+ p.getRight().accept((ResultSetVisitor) this);
+ out.append(")");
+ }
+}
diff --git a/src/de/dhbwstuttgart/syntaxtree/visual/ResultSetPrinter.java b/src/de/dhbwstuttgart/syntaxtree/visual/ResultSetPrinter.java
new file mode 100644
index 00000000..fc67a723
--- /dev/null
+++ b/src/de/dhbwstuttgart/syntaxtree/visual/ResultSetPrinter.java
@@ -0,0 +1,20 @@
+package de.dhbwstuttgart.syntaxtree.visual;
+
+import de.dhbwstuttgart.syntaxtree.SourceFile;
+import de.dhbwstuttgart.typeinference.result.ResultPair;
+import de.dhbwstuttgart.typeinference.result.ResultSet;
+
+import java.util.Set;
+
+public class ResultSetPrinter {
+
+ public static String print(ResultSet toPrint){
+ StringBuilder output = new StringBuilder();
+ for(ResultPair p : toPrint.results){
+ p.accept(new ResultSetOutputGenerator(output));
+ output.append("\n");
+ }
+ return output.toString();
+ }
+
+}
diff --git a/src/de/dhbwstuttgart/typedeployment/TypeInsertFactory.java b/src/de/dhbwstuttgart/typedeployment/TypeInsertFactory.java
index 29492c31..8834f859 100644
--- a/src/de/dhbwstuttgart/typedeployment/TypeInsertFactory.java
+++ b/src/de/dhbwstuttgart/typedeployment/TypeInsertFactory.java
@@ -126,7 +126,7 @@ class TypeToInsertString implements ResultSetVisitor{
@Override
public void visit(GenericRefType genericRefType) {
- insert += genericRefType.getName();
+ insert += genericRefType.getParsedName();
}
@Override
diff --git a/src/de/dhbwstuttgart/typeinference/assumptions/FieldAssumption.java b/src/de/dhbwstuttgart/typeinference/assumptions/FieldAssumption.java
index 62867a26..e039dcbe 100644
--- a/src/de/dhbwstuttgart/typeinference/assumptions/FieldAssumption.java
+++ b/src/de/dhbwstuttgart/typeinference/assumptions/FieldAssumption.java
@@ -1,5 +1,6 @@
package de.dhbwstuttgart.typeinference.assumptions;
+import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.TypeScope;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
@@ -25,7 +26,7 @@ public class FieldAssumption extends Assumption{
}
public RefTypeOrTPHOrWildcardOrGeneric getReceiverType(GenericsResolver resolver) {
-
- return null;
+ //TODO
+ throw new NotImplementedException();
}
}
diff --git a/src/de/dhbwstuttgart/typeinference/assumptions/FunNClass.java b/src/de/dhbwstuttgart/typeinference/assumptions/FunNClass.java
index a04ce9bb..3518c16a 100644
--- a/src/de/dhbwstuttgart/typeinference/assumptions/FunNClass.java
+++ b/src/de/dhbwstuttgart/typeinference/assumptions/FunNClass.java
@@ -1,8 +1,6 @@
package de.dhbwstuttgart.typeinference.assumptions;
import de.dhbwstuttgart.parser.NullToken;
-import de.dhbwstuttgart.parser.SyntaxTreeGenerator.GenericContext;
-import de.dhbwstuttgart.parser.scope.GenericTypeName;
import de.dhbwstuttgart.parser.scope.JavaClassName;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
@@ -29,8 +27,7 @@ public class FunNClass extends ClassOrInterface {
private static GenericDeclarationList createGenerics(List funNParams) {
List generics = new ArrayList<>();
for(RefTypeOrTPHOrWildcardOrGeneric param : funNParams){
- generics.add(new GenericTypeVar(new GenericTypeName(new GenericContext(
- new JavaClassName("Fun"+(funNParams.size()-1)), null), NameGenerator.makeNewName()),
+ generics.add(new GenericTypeVar(NameGenerator.makeNewName(),
new ArrayList<>(), new NullToken(), new NullToken()));
}
return new GenericDeclarationList(generics, new NullToken());
diff --git a/src/de/dhbwstuttgart/typeinference/assumptions/MethodAssumption.java b/src/de/dhbwstuttgart/typeinference/assumptions/MethodAssumption.java
index 066c3246..e17281e5 100644
--- a/src/de/dhbwstuttgart/typeinference/assumptions/MethodAssumption.java
+++ b/src/de/dhbwstuttgart/typeinference/assumptions/MethodAssumption.java
@@ -3,9 +3,7 @@ package de.dhbwstuttgart.typeinference.assumptions;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
-import de.dhbwstuttgart.syntaxtree.ParameterList;
import de.dhbwstuttgart.syntaxtree.TypeScope;
-import de.dhbwstuttgart.syntaxtree.statement.Assign;
import de.dhbwstuttgart.syntaxtree.type.FunN;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
import de.dhbwstuttgart.syntaxtree.type.RefType;
@@ -14,7 +12,6 @@ import de.dhbwstuttgart.typeinference.constraints.GenericsResolver;
import java.util.ArrayList;
import java.util.List;
-import java.util.stream.Collectors;
public class MethodAssumption extends Assumption{
private ClassOrInterface receiver;
@@ -40,7 +37,8 @@ public class MethodAssumption extends Assumption{
return receiver;
}
- public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
+ public RefTypeOrTPHOrWildcardOrGeneric getReturnType(GenericsResolver resolver) {
+ if(retType instanceof GenericRefType)return resolver.resolve(retType);
return retType;
}
diff --git a/src/de/dhbwstuttgart/typeinference/result/PairTPHEqualTPH.java b/src/de/dhbwstuttgart/typeinference/result/PairTPHEqualTPH.java
index 64d0ce0b..c24fe211 100644
--- a/src/de/dhbwstuttgart/typeinference/result/PairTPHEqualTPH.java
+++ b/src/de/dhbwstuttgart/typeinference/result/PairTPHEqualTPH.java
@@ -9,7 +9,7 @@ public class PairTPHEqualTPH extends ResultPair numericAdditionOrStringConcatenation = new HashSet<>();
+ Constraint numeric = new Constraint<>();
+ //Zuerst der Fall für Numerische AusdrücPairOpnumericeratorke, das sind Mul, Mod und Div immer:
+ //see: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.17
+ //Expression muss zu Numeric Convertierbar sein. also von Numeric erben
+ numeric.add(new Pair(binary.lexpr.getType(), number, PairOperator.SMALLERDOT));
+ numeric.add(new Pair(binary.rexpr.getType(), number, PairOperator.SMALLERDOT));
+ /*
+ In Java passiert bei den binären Operatoren eine sogenannte Type Promotion:
+ https://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.6.2
+ Das bedeutet, dass Java die Typen je nach belieben castet, so lange sie nur von Number erben
+ */
+ numeric.add(new Pair(binary.getType(), number, PairOperator.SMALLERDOT));
+ numericAdditionOrStringConcatenation.add(numeric);
+ if(binary.operation.equals(BinaryExpr.Operator.ADD)) {
+ //Dann kann der Ausdruck auch das aneinanderfügen zweier Strings sein: ("a" + "b") oder (1 + 2)
+ Constraint stringConcat = new Constraint<>();
+ stringConcat.add(new Pair(binary.lexpr.getType(), string, PairOperator.EQUALSDOT));
+ stringConcat.add(new Pair(binary.rexpr.getType(), string, PairOperator.EQUALSDOT));
+ stringConcat.add(new Pair(binary.getType(), string, PairOperator.EQUALSDOT));
+ numericAdditionOrStringConcatenation.add(stringConcat);
+ }
+ constraintsSet.addOderConstraint(numericAdditionOrStringConcatenation);
+ }else if(binary.operation.equals(BinaryExpr.Operator.LESSEQUAL) ||
+ binary.operation.equals(BinaryExpr.Operator.BIGGEREQUAL) ||
+ binary.operation.equals(BinaryExpr.Operator.BIGGERTHAN) ||
+ binary.operation.equals(BinaryExpr.Operator.LESSTHAN)){
+ constraintsSet.addUndConstraint(new Pair(binary.lexpr.getType(), number, PairOperator.SMALLERDOT));
+ constraintsSet.addUndConstraint(new Pair(binary.rexpr.getType(), number, PairOperator.SMALLERDOT));
+ //Rückgabetyp ist Boolean
+ constraintsSet.addUndConstraint(new Pair(bool, binary.getType(), PairOperator.EQUALSDOT));
+ }else{
+ throw new NotImplementedException();
+ }
+ }
+
@Override
public void visit(Literal literal) {
- //Nothing to do here. Literale kriegen beim parsen den korrekten Typ.
+ //Nothing to do here. Literale erzeugen keine Constraints
}
@Override
@@ -303,14 +342,14 @@ public class TYPEStmt implements StatementVisitor{
List params = new ArrayList<>();
for(GenericTypeVar gtv : receiverCl.getGenerics()){
//Die Generics werden alle zu TPHs umgewandelt.
- params.add(resolver.resolve(gtv.getParsedName()));
+ params.add(resolver.resolve(gtv.getName()));
}
RefTypeOrTPHOrWildcardOrGeneric receiverType = new RefType(assumption.getReceiver().getClassName(), params, forMethod.getOffset());
*/
methodConstraint.add(new Pair(forMethod.receiver.getType(), assumption.getReceiverType(resolver),
PairOperator.SMALLERDOT));
- methodConstraint.add(new Pair(assumption.getReturnType(), forMethod.getType(),
+ methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(),
PairOperator.EQUALSDOT));
methodConstraint.addAll(generateParameterConstraints(forMethod, assumption, info, resolver));
return methodConstraint;
@@ -354,7 +393,7 @@ public class TYPEStmt implements StatementVisitor{
for(Method m : cl.getMethods()){
if(m.getName().equals(name) &&
m.getParameterList().getFormalparalist().size() == numArgs){
- RefTypeOrTPHOrWildcardOrGeneric retType = info.checkGTV(m.getReturnType());
+ RefTypeOrTPHOrWildcardOrGeneric retType = m.getReturnType();//info.checkGTV(m.getReturnType());
ret.add(new MethodAssumption(cl, retType, convertParams(m.getParameterList(),info),
createTypeScope(cl, m)));
@@ -403,7 +442,7 @@ public class TYPEStmt implements StatementVisitor{
protected Constraint generateConstructorConstraint(NewClass forConstructor, MethodAssumption assumption,
TypeInferenceBlockInformation info, GenericsResolver resolver){
Constraint methodConstraint = new Constraint();
- methodConstraint.add(new Pair(assumption.getReturnType(), forConstructor.getType(),
+ methodConstraint.add(new Pair(assumption.getReturnType(resolver), forConstructor.getType(),
PairOperator.SMALLERDOT));
methodConstraint.addAll(generateParameterConstraints(forConstructor, assumption, info, resolver));
return methodConstraint;
diff --git a/src/de/dhbwstuttgart/typeinference/unify/Match.java b/src/de/dhbwstuttgart/typeinference/unify/Match.java
new file mode 100644
index 00000000..78f7360f
--- /dev/null
+++ b/src/de/dhbwstuttgart/typeinference/unify/Match.java
@@ -0,0 +1,89 @@
+package de.dhbwstuttgart.typeinference.unify;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import de.dhbwstuttgart.typeinference.unify.interfaces.IMatch;
+import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
+import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
+import de.dhbwstuttgart.typeinference.unify.model.TypeParams;
+import de.dhbwstuttgart.typeinference.unify.model.Unifier;
+import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
+import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
+
+/**
+ * Implementation of match derived from unification algorithm.
+ * @author Martin Pluemicke
+ */
+public class Match implements IMatch {
+
+ @Override
+ public Optional match(ArrayList termsList) {
+
+ // Start with the identity unifier. Substitutions will be added later.
+ Unifier mgu = Unifier.identity();
+
+ // Apply rules while possible
+ int idx = 0;
+ while(idx < termsList.size()) {
+ UnifyPair pair = termsList.get(idx);
+ UnifyType rhsType = pair.getRhsType();
+ UnifyType lhsType = pair.getLhsType();
+ TypeParams rhsTypeParams = rhsType.getTypeParams();
+ TypeParams lhsTypeParams = lhsType.getTypeParams();
+
+ // REDUCE - Rule
+ if(!(rhsType instanceof PlaceholderType) && !(lhsType instanceof PlaceholderType)) {
+ Set result = new HashSet<>();
+
+ // f<...> = g<...> with f != g are not unifiable
+ if(!rhsType.getName().equals(lhsType.getName()))
+ return Optional.empty(); // conflict
+ // f = f are not unifiable
+ if(rhsTypeParams.size() != lhsTypeParams.size())
+ return Optional.empty(); // conflict
+ // f = g is not unifiable (cannot be f = f because erase rule would have been applied)
+ //if(rhsTypeParams.size() == 0)
+ //return Optional.empty();
+
+ // Unpack the arguments
+ for(int i = 0; i < rhsTypeParams.size(); i++)
+ result.add(new UnifyPair(lhsTypeParams.get(i), rhsTypeParams.get(i), PairOperator.EQUALSDOT));
+
+ termsList.remove(idx);
+ termsList.addAll(result);
+ continue;
+ }
+
+ // DELETE - Rule
+ if(pair.getRhsType().equals(pair.getLhsType())) {
+ termsList.remove(idx);
+ continue;
+ }
+
+ // SWAP - Rule
+ if(!(lhsType instanceof PlaceholderType) && (rhsType instanceof PlaceholderType)) {
+ return Optional.empty(); // conflict
+ }
+
+ // OCCURS-CHECK
+ //deleted
+
+ // SUBST - Rule
+ if(lhsType instanceof PlaceholderType) {
+ mgu.add((PlaceholderType) lhsType, rhsType);
+ termsList = termsList.stream().map(mgu::applyleft).collect(Collectors.toCollection(ArrayList::new));
+ idx = idx+1 == termsList.size() ? 0 : idx+1;
+ continue;
+ }
+
+ idx++;
+ }
+
+ return Optional.of(mgu);
+ }
+}
diff --git a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
index 2005a387..e51679e2 100644
--- a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
+++ b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
@@ -34,6 +34,7 @@ import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
public class TypeUnifyTask extends RecursiveTask>> {
private static final long serialVersionUID = 1L;
+ private static int i = 0;
/**
* The implementation of setOps that will be used during the unification
@@ -77,6 +78,7 @@ public class TypeUnifyTask extends RecursiveTask>> {
/*
* Step 1: Repeated application of reduce, adapt, erase, swap
*/
+ //System.out.println("Unifikation: " + eq);
Set eq0 = applyTypeUnificationRules(eq, fc);
/*
@@ -97,6 +99,8 @@ public class TypeUnifyTask extends RecursiveTask>> {
// cartesian product of the sets created by pattern matching.
List>> topLevelSets = new ArrayList<>();
+ System.out.println(eq2s);
+
if(eq1s.size() != 0) { // Do not add empty sets or the cartesian product will always be empty.
Set> wrap = new HashSet<>();
wrap.add(eq1s);
@@ -134,12 +138,16 @@ public class TypeUnifyTask extends RecursiveTask>> {
// Sub cartesian products of the second level (pattern matched) sets
// "the big (x)"
for(Set>> secondLevelSet : secondLevelSets) {
+ //System.out.println("secondLevelSet "+secondLevelSet.size());
List>> secondLevelSetList = new ArrayList<>(secondLevelSet);
Set>> cartResult = setOps.cartesianProduct(secondLevelSetList);
-
+ //System.out.println("CardResult: "+cartResult.size());
// Flatten and add to top level sets
Set> flat = new HashSet<>();
+ int j = 0;
for(List> s : cartResult) {
+ j++;
+ //System.out.println("s from CardResult: "+cartResult.size() + " " + j);
Set flat1 = new HashSet<>();
for(Set s1 : s)
flat1.addAll(s1);
@@ -164,6 +172,7 @@ public class TypeUnifyTask extends RecursiveTask>> {
/*
* Step 5: Substitution
*/
+ System.out.println("vor Subst: " + eqPrime);
Optional> eqPrimePrime = rules.subst(eqPrime);
/*
@@ -176,11 +185,13 @@ public class TypeUnifyTask extends RecursiveTask>> {
//(!eqPrimePrime.isPresent()) erfolgt ist, ist das Ergebnis erzielt.
eqPrimePrimeSet.add(eqPrime);
else if(eqPrimePrime.isPresent()) {
+ System.out.println("nextStep: " + eqPrimePrime.get());
TypeUnifyTask fork = new TypeUnifyTask(eqPrimePrime.get(), fc, true);
forks.add(fork);
fork.fork();
}
else {
+ System.out.println("nextStep: " + eqPrime);
TypeUnifyTask fork = new TypeUnifyTask(eqPrime, fc, true);
forks.add(fork);
fork.fork();
@@ -381,9 +392,12 @@ public class TypeUnifyTask extends RecursiveTask>> {
UnifyType rhsType = pair.getRhsType();
// Case 1: (a <. Theta')
- if(pairOp == PairOperator.SMALLERDOT && lhsType instanceof PlaceholderType)
- result.get(0).add(unifyCase1((PlaceholderType) pair.getLhsType(), pair.getRhsType(), fc));
-
+ if(pairOp == PairOperator.SMALLERDOT && lhsType instanceof PlaceholderType) {
+ System.out.println(pair);
+ Set> x1 = unifyCase1((PlaceholderType) pair.getLhsType(), pair.getRhsType(), fc);
+ System.out.println(x1);
+ result.get(0).add(x1);
+ }
// Case 2: (a <.? ? ext Theta')
else if(pairOp == PairOperator.SMALLERDOTWC && lhsType instanceof PlaceholderType && rhsType instanceof ExtendsType)
result.get(1).add(unifyCase2((PlaceholderType) pair.getLhsType(), (ExtendsType) pair.getRhsType(), fc));
@@ -442,13 +456,24 @@ public class TypeUnifyTask extends RecursiveTask>> {
break;
}
- Set cs = fc.getAllTypesByName(thetaPrime.getName());
- cs.add(thetaPrime);
+ Set cs = fc.getAllTypesByName(thetaPrime.getName());//cs= [java.util.Vector, java.util.Vector>, ????java.util.Vector???]
+
+ //PL 18-02-06 entfernt, kommt durch unify wieder rein
+ //cs.add(thetaPrime);
+ //PL 18-02-06 entfernt
for(UnifyType c : cs) {
- Set thetaQs = fc.getChildren(c).stream().collect(Collectors.toCollection(HashSet::new));
- thetaQs.add(thetaPrime); //PL 2017-10-03: War auskommentiert habe ich wieder einkommentiert,
- //da children offensichtlich ein echtes kleiner und kein kleinergleich ist
+ //PL 18-02-05 getChildren durch smaller ersetzt in getChildren werden die Varianlen nicht ersetzt.
+ Set thetaQs = fc.smaller(c).stream().collect(Collectors.toCollection(HashSet::new));
+ //Set thetaQs = fc.getChildren(c).stream().collect(Collectors.toCollection(HashSet::new));
+ //thetaQs.add(thetaPrime); //PL 18-02-05 wieder geloescht
+ //PL 2017-10-03: War auskommentiert habe ich wieder einkommentiert,
+ //da children offensichtlich ein echtes kleiner und kein kleinergleich ist
+
+ //PL 18-02-06: eingefuegt, thetaQs der Form V> <. V'> werden entfernt
+ thetaQs = thetaQs.stream().filter(ut -> ut.getTypeParams().arePlaceholders()).collect(Collectors.toCollection(HashSet::new));
+ //PL 18-02-06: eingefuegt
+
Set thetaQPrimes = new HashSet<>();
TypeParams cParams = c.getTypeParams();
if(cParams.size() == 0)
@@ -464,6 +489,11 @@ public class TypeUnifyTask extends RecursiveTask>> {
}
for(UnifyType tqp : thetaQPrimes) {
+ //System.out.println(tqp.toString());
+ //i++;
+ //System.out.println(i);
+ //if (i == 62)
+ // System.out.println(tqp.toString());
Optional opt = stdUnify.unify(tqp, thetaPrime);
if (!opt.isPresent())
continue;
@@ -474,10 +504,11 @@ public class TypeUnifyTask extends RecursiveTask>> {
for (Entry sigma : unifier)
substitutionSet.add(new UnifyPair(sigma.getKey(), sigma.getValue(), PairOperator.EQUALSDOT));
- List freshTphs = new ArrayList<>();
+ //List freshTphs = new ArrayList<>(); PL 18-02-06 in die For-Schleife verschoben
for (UnifyType tq : thetaQs) {
- Set smaller = fc.smaller(unifier.apply(tq));
+ Set smaller = fc.smaller(unifier.apply(tq));
for(UnifyType theta : smaller) {
+ List freshTphs = new ArrayList<>();
Set resultPrime = new HashSet<>();
for(int i = 0; !allGen && i < theta.getTypeParams().size(); i++) {
diff --git a/src/de/dhbwstuttgart/typeinference/unify/interfaces/IMatch.java b/src/de/dhbwstuttgart/typeinference/unify/interfaces/IMatch.java
new file mode 100644
index 00000000..5e201dd7
--- /dev/null
+++ b/src/de/dhbwstuttgart/typeinference/unify/interfaces/IMatch.java
@@ -0,0 +1,35 @@
+package de.dhbwstuttgart.typeinference.unify.interfaces;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
+import de.dhbwstuttgart.typeinference.unify.model.Unifier;
+import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
+
+/**
+ * Match
+ * @author Martin Pluemicke
+ */
+public interface IMatch {
+
+ /**
+ * Finds the most general unifier sigma of the set {t1,...,tn} so that
+ * sigma(t1) = sigma(t2) = ... = sigma(tn).
+ * @param terms The set of terms to be unified
+ * @return An optional of the most general unifier if it exists or an empty optional if there is no unifier.
+ */
+ public Optional