Commit fbfe9ac5 authored by Lulu Luong's avatar Lulu Luong

merge with master

parents 7e12bf82 36832366
Pipeline #33843 failed with stages
in 54 seconds
...@@ -100,9 +100,7 @@ literals : ...@@ -100,9 +100,7 @@ literals :
</pre>*/ </pre>*/
matchPattern matchPattern
: :
MATCH ( MATCH ((pattern=expression (USING LBRACKET argList RBRACKET)?)
derivable=DERIVABLE derivableExpression=expression
| (pattern=expression (USING LBRACKET argList RBRACKET)?)
) )
; ;
...@@ -123,7 +121,8 @@ casesStmt ...@@ -123,7 +121,8 @@ casesStmt
casesList casesList
: (TRY | : (TRY |
(CASE (expression (CASE (expression
| (CLOSES INDENT closesGuard=stmtList DEDENT) ) ) ) |(CLOSES INDENT closesGuard=stmtList DEDENT)
|(derivable=DERIVABLE derivableExpression=expression) ) ))
COLON INDENT? body=stmtList DEDENT? COLON INDENT? body=stmtList DEDENT?
; ;
......
...@@ -160,6 +160,7 @@ public interface ASTTraversal<T> extends Visitor<T> { ...@@ -160,6 +160,7 @@ public interface ASTTraversal<T> extends Visitor<T> {
return null; return null;
} }
@Override @Override
default T visit(ForeachStatement foreach) { default T visit(ForeachStatement foreach) {
foreach.getBody().accept(this); foreach.getBody().accept(this);
...@@ -209,6 +210,14 @@ public interface ASTTraversal<T> extends Visitor<T> { ...@@ -209,6 +210,14 @@ public interface ASTTraversal<T> extends Visitor<T> {
return null; return null;
} }
@Override
default T visit(DerivableCase derivableCase){
derivableCase.getExpression().accept(this);
derivableCase.getBody().accept(this);
return null;
}
@Override @Override
default T visit(SubstituteExpression subst) { default T visit(SubstituteExpression subst) {
subst.getSub().accept(this); subst.getSub().accept(this);
......
...@@ -92,6 +92,11 @@ public class DefaultASTVisitor<T> implements Visitor<T> { ...@@ -92,6 +92,11 @@ public class DefaultASTVisitor<T> implements Visitor<T> {
return defaultVisit(defCase); return defaultVisit(defCase);
} }
@Override
public T visit(DerivableCase derivableCase) {
return defaultVisit(derivableCase);
}
@Override @Override
public T visit(CaseStatement caseStatement) { public T visit(CaseStatement caseStatement) {
return defaultVisit(caseStatement); return defaultVisit(caseStatement);
......
...@@ -370,16 +370,9 @@ public class TransformAst implements ScriptLanguageVisitor<Object> { ...@@ -370,16 +370,9 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
MatchExpression match = new MatchExpression(); MatchExpression match = new MatchExpression();
match.setRuleContext(ctx); match.setRuleContext(ctx);
if (ctx.derivable != null) {
match.setDerivable(true);
Expression<ParserRuleContext> e = (Expression<ParserRuleContext>) ctx.derivableExpression.accept(this);
e.setParent(match);
match.setDerivableTerm(e);
} else {
Expression<ParserRuleContext> e = (Expression<ParserRuleContext>) ctx.pattern.accept(this); Expression<ParserRuleContext> e = (Expression<ParserRuleContext>) ctx.pattern.accept(this);
match.setPattern(e); match.setPattern(e);
e.setParent(match); e.setParent(match);
}
return match; return match;
} }
...@@ -416,7 +409,13 @@ public class TransformAst implements ScriptLanguageVisitor<Object> { ...@@ -416,7 +409,13 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
Statements closes = (Statements) ctx.closesGuard.accept(this); Statements closes = (Statements) ctx.closesGuard.accept(this);
((ClosesCase) cs).setClosesGuard(closes); ((ClosesCase) cs).setClosesGuard(closes);
closes.setParent(cs); closes.setParent(cs);
} else { } else if (ctx.derivable != null) {
cs = new DerivableCase();
Expression pattern = (Expression) ctx.derivableExpression.accept(this);
((DerivableCase) cs).setExpression(pattern);
pattern.setParent(cs);
} else
{
cs = new GuardedCaseStatement(); cs = new GuardedCaseStatement();
Expression<ParserRuleContext> guard = (Expression<ParserRuleContext>) ctx.expression().accept(this); Expression<ParserRuleContext> guard = (Expression<ParserRuleContext>) ctx.expression().accept(this);
((GuardedCaseStatement) cs).setGuard(guard); ((GuardedCaseStatement) cs).setGuard(guard);
......
...@@ -53,6 +53,8 @@ public interface Visitor<T> { ...@@ -53,6 +53,8 @@ public interface Visitor<T> {
T visit(DefaultCaseStatement defCase); T visit(DefaultCaseStatement defCase);
T visit(DerivableCase derivableCase);
//T visit(CaseStatement case_); //T visit(CaseStatement case_);
T visit(CallStatement call); T visit(CallStatement call);
......
package edu.kit.iti.formal.psdbg.parser.ast;
import edu.kit.iti.formal.psdbg.parser.Visitor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class DerivableCase extends CaseStatement{
private Expression expression;
public DerivableCase(Statements copy, Expression copy1) {
super(copy);
this.expression=copy1;
}
@Override
public <T> T accept(Visitor<T> visitor) {
return visitor.visit(this);
}
@Override
public CaseStatement copy() {
DerivableCase dc = new DerivableCase(body.copy(), expression.copy());
dc.setRuleContext(this.getRuleContext());
return dc;
}
}
...@@ -30,6 +30,8 @@ import edu.kit.iti.formal.psdbg.parser.types.SimpleType; ...@@ -30,6 +30,8 @@ import edu.kit.iti.formal.psdbg.parser.types.SimpleType;
import edu.kit.iti.formal.psdbg.parser.types.TermType; import edu.kit.iti.formal.psdbg.parser.types.TermType;
import edu.kit.iti.formal.psdbg.parser.types.Type; import edu.kit.iti.formal.psdbg.parser.types.Type;
import lombok.Data; import lombok.Data;
import lombok.Getter;
import lombok.Setter;
/** /**
* A match expression contains an argument and a uses clause. * A match expression contains an argument and a uses clause.
...@@ -41,6 +43,7 @@ import lombok.Data; ...@@ -41,6 +43,7 @@ import lombok.Data;
public class MatchExpression extends Expression<ScriptLanguageParser.MatchPatternContext> { public class MatchExpression extends Expression<ScriptLanguageParser.MatchPatternContext> {
//private Signature signature = new Signature(); //private Signature signature = new Signature();
private Expression pattern; private Expression pattern;
@Deprecated @Getter @Setter
private boolean isDerivable = false; private boolean isDerivable = false;
@Deprecated @Deprecated
private Expression derivableTerm; private Expression derivableTerm;
......
...@@ -47,7 +47,9 @@ public class Statements extends ASTNode<ScriptLanguageParser.StmtListContext> ...@@ -47,7 +47,9 @@ public class Statements extends ASTNode<ScriptLanguageParser.StmtListContext>
@Override @Override
public ASTNode[] getChildren() { public ASTNode[] getChildren() {
return (ASTNode[]) toArray(); Object[] arr = toArray();
return toArray(new ASTNode[arr.length]);
//return (ASTNode[]) toArray();
} }
public Statements(Statements body) { public Statements(Statements body) {
......
...@@ -8,6 +8,7 @@ import de.uka.ilkd.key.java.Services; ...@@ -8,6 +8,7 @@ import de.uka.ilkd.key.java.Services;
import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.proof.Goal;
import de.uka.ilkd.key.proof.Proof; import de.uka.ilkd.key.proof.Proof;
import de.uka.ilkd.key.proof.init.ProofInputException; import de.uka.ilkd.key.proof.init.ProofInputException;
import de.uka.ilkd.key.proof.init.ProofOblInput;
import de.uka.ilkd.key.proof.io.ProblemLoaderException; import de.uka.ilkd.key.proof.io.ProblemLoaderException;
import de.uka.ilkd.key.speclang.Contract; import de.uka.ilkd.key.speclang.Contract;
import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode; import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode;
...@@ -91,8 +92,23 @@ public class KeYProofFacade { ...@@ -91,8 +92,23 @@ public class KeYProofFacade {
*/ */
public void reload(File problemFile) throws ProofInputException, ProblemLoaderException { public void reload(File problemFile) throws ProofInputException, ProblemLoaderException {
if (contract.get() != null) {// reinstante the contract if (contract.get() != null) {// reinstante the contract
setProof(getEnvironment().createProof( pma = KeYApi.loadFromKeyFile(problemFile);
contract.get().getProofObl(getEnvironment().getServices()))); List<Contract> contracts = pma.getProofContracts();
contracts.forEach(contract1 -> {
if(contract.get().getName().equals(contract1.getName())){
contractProperty().set(contract1);
}
});
if(contract.get() != null){
try{
activateContract(contract.get());
}catch (ProofInputException pie){
throw new ProofInputException("Contract not reloadable.", pie.getCause());
}
}
/*setProof(getEnvironment().createProof(
contract.get().getProofObl(getEnvironment().getServices())));*/
} else { } else {
setProof(KeYApi.loadFromKeyFile(problemFile).getLoadedProof().getProof()); setProof(KeYApi.loadFromKeyFile(problemFile).getLoadedProof().getProof());
} }
......
...@@ -3,11 +3,16 @@ package edu.kit.iti.formal.psdbg.interpreter; ...@@ -3,11 +3,16 @@ package edu.kit.iti.formal.psdbg.interpreter;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableBiMap;
import de.uka.ilkd.key.api.VariableAssignments; import de.uka.ilkd.key.api.VariableAssignments;
import de.uka.ilkd.key.java.Services;
import de.uka.ilkd.key.logic.Term;
import de.uka.ilkd.key.logic.TermBuilder;
import de.uka.ilkd.key.parser.ParserException;
import de.uka.ilkd.key.proof.Node; import de.uka.ilkd.key.proof.Node;
import de.uka.ilkd.key.proof.Proof; import de.uka.ilkd.key.proof.Proof;
import edu.kit.iti.formal.psdbg.interpreter.data.*; import edu.kit.iti.formal.psdbg.interpreter.data.*;
import edu.kit.iti.formal.psdbg.interpreter.exceptions.InvalidTypeException; import edu.kit.iti.formal.psdbg.interpreter.exceptions.InvalidTypeException;
import edu.kit.iti.formal.psdbg.interpreter.funchdl.CommandLookup; import edu.kit.iti.formal.psdbg.interpreter.funchdl.CommandLookup;
import edu.kit.iti.formal.psdbg.interpreter.matcher.KeYMatcher;
import edu.kit.iti.formal.psdbg.parser.Visitor; import edu.kit.iti.formal.psdbg.parser.Visitor;
import edu.kit.iti.formal.psdbg.parser.ast.*; import edu.kit.iti.formal.psdbg.parser.ast.*;
import edu.kit.iti.formal.psdbg.parser.data.Value; import edu.kit.iti.formal.psdbg.parser.data.Value;
...@@ -15,7 +20,9 @@ import edu.kit.iti.formal.psdbg.parser.types.SimpleType; ...@@ -15,7 +20,9 @@ import edu.kit.iti.formal.psdbg.parser.types.SimpleType;
import edu.kit.iti.formal.psdbg.parser.types.TermType; import edu.kit.iti.formal.psdbg.parser.types.TermType;
import edu.kit.iti.formal.psdbg.parser.types.TypeFacade; import edu.kit.iti.formal.psdbg.parser.types.TypeFacade;
import lombok.Getter; import lombok.Getter;
import lombok.Setter;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Function; import java.util.function.Function;
...@@ -141,6 +148,8 @@ public class KeyInterpreter extends Interpreter<KeyData> { ...@@ -141,6 +148,8 @@ public class KeyInterpreter extends Interpreter<KeyData> {
} }
@Override @Override
public Object visit(LetStatement let) { public Object visit(LetStatement let) {
enterScope(let); enterScope(let);
......
...@@ -42,6 +42,7 @@ public class TermValue { ...@@ -42,6 +42,7 @@ public class TermValue {
} }
} }
public TermValue copy() { public TermValue copy() {
TermValue tv = new TermValue(); TermValue tv = new TermValue();
......
package edu.kit.iti.formal.psdbg.interpreter.exceptions; package edu.kit.iti.formal.psdbg.interpreter.exceptions;
import de.uka.ilkd.key.macros.scripts.AbstractCommand;
import de.uka.ilkd.key.macros.scripts.RuleCommand; import de.uka.ilkd.key.macros.scripts.RuleCommand;
import java.util.Map; import java.util.Map;
...@@ -13,6 +14,9 @@ public class ScriptCommandNotApplicableException extends InterpreterRuntimeExcep ...@@ -13,6 +14,9 @@ public class ScriptCommandNotApplicableException extends InterpreterRuntimeExcep
public ScriptCommandNotApplicableException(Exception e, RuleCommand c) { public ScriptCommandNotApplicableException(Exception e, RuleCommand c) {
System.out.println("Call " + c.getName() + " was not applicable"); System.out.println("Call " + c.getName() + " was not applicable");
} }
public ScriptCommandNotApplicableException(Exception e, AbstractCommand c) {
System.out.println("Call " + c.getName() + " was not applicable");
}
public ScriptCommandNotApplicableException(Exception e, RuleCommand c, Map<String, Object> params) { public ScriptCommandNotApplicableException(Exception e, RuleCommand c, Map<String, Object> params) {
super(createMessage(c, params), e); super(createMessage(c, params), e);
......
...@@ -14,6 +14,7 @@ import edu.kit.iti.formal.psdbg.interpreter.data.KeyData; ...@@ -14,6 +14,7 @@ import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.data.State; import edu.kit.iti.formal.psdbg.interpreter.data.State;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment; import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import edu.kit.iti.formal.psdbg.parser.ast.CallStatement; import edu.kit.iti.formal.psdbg.parser.ast.CallStatement;
import javafx.scene.control.Alert;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
...@@ -22,6 +23,8 @@ import org.apache.logging.log4j.Logger; ...@@ -22,6 +23,8 @@ import org.apache.logging.log4j.Logger;
import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableList;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
...@@ -62,7 +65,26 @@ public class ProofScriptCommandBuilder implements CommandHandler<KeyData> { ...@@ -62,7 +65,26 @@ public class ProofScriptCommandBuilder implements CommandHandler<KeyData> {
VariableAssignment params, KeyData data) { VariableAssignment params, KeyData data) {
ProofScriptCommand c = commands.get(call.getCommand()); ProofScriptCommand c = commands.get(call.getCommand());
State<KeyData> state = interpreter.getCurrentState(); State<KeyData> state = interpreter.getCurrentState();
//multiple goals exist
if(state.getGoals().size() > 1) {
throw new IllegalStateException("Multiple open goals: Please use a selector.");
/*
//TODO: Utils showWarning
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Multiple open Goals");
alert.setHeaderText("Multiple open Goals");
alert.setContentText("There are multiple open goals so its undefined on which goal the command " + call.getCommand() +" should be applied. Please use a selector.");
alert.setWidth(400);
alert.setHeight(400);
alert.setHeight(600);
alert.setWidth(400);
alert.showAndWait();
*/
}
GoalNode<KeyData> expandedNode = state.getSelectedGoalNode(); GoalNode<KeyData> expandedNode = state.getSelectedGoalNode();
KeyData kd = expandedNode.getData(); KeyData kd = expandedNode.getData();
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
params.asMap().forEach((k, v) -> { params.asMap().forEach((k, v) -> {
......
...@@ -77,7 +77,7 @@ public class RuleCommandHandler implements CommandHandler<KeyData> { ...@@ -77,7 +77,7 @@ public class RuleCommandHandler implements CommandHandler<KeyData> {
try { try {
for (SequentFormula sf : g.node().sequent().succedent()) { for (SequentFormula sf : g.node().sequent().succedent()) {
ImmutableList<TacletApp> apps = index.getTacletAppAtAndBelow(filter, ImmutableList<TacletApp> apps = index.getTacletAppAtAndBelow(filter,
new PosInOccurrence(sf, PosInTerm.getTopLevel(), true), new PosInOccurrence(sf, PosInTerm.getTopLevel(), false),
services); services);
apps.forEach(t -> set.add(t.taclet().name().toString())); apps.forEach(t -> set.add(t.taclet().name().toString()));
} }
......
...@@ -3,8 +3,10 @@ package edu.kit.iti.formal.psdbg.interpreter.matcher; ...@@ -3,8 +3,10 @@ package edu.kit.iti.formal.psdbg.interpreter.matcher;
import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.Services;
import de.uka.ilkd.key.logic.Name; import de.uka.ilkd.key.logic.Name;
import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.Term;
import de.uka.ilkd.key.logic.TermBuilder;
import de.uka.ilkd.key.logic.op.LogicVariable; import de.uka.ilkd.key.logic.op.LogicVariable;
import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.logic.op.SchemaVariable;
import de.uka.ilkd.key.parser.ParserException;
import de.uka.ilkd.key.pp.LogicPrinter; import de.uka.ilkd.key.pp.LogicPrinter;
import de.uka.ilkd.key.proof.ApplyStrategy; import de.uka.ilkd.key.proof.ApplyStrategy;
import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.proof.Goal;
...@@ -14,14 +16,12 @@ import de.uka.ilkd.key.rule.NoPosTacletApp; ...@@ -14,14 +16,12 @@ import de.uka.ilkd.key.rule.NoPosTacletApp;
import de.uka.ilkd.key.rule.Taclet; import de.uka.ilkd.key.rule.Taclet;
import de.uka.ilkd.key.rule.TacletApp; import de.uka.ilkd.key.rule.TacletApp;
import edu.kit.iti.formal.psdbg.interpreter.MatcherApi; import edu.kit.iti.formal.psdbg.interpreter.MatcherApi;
import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode; import edu.kit.iti.formal.psdbg.interpreter.data.*;
import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.data.SortType;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import edu.kit.iti.formal.psdbg.parser.ast.Signature; import edu.kit.iti.formal.psdbg.parser.ast.Signature;
import edu.kit.iti.formal.psdbg.parser.data.Value; import edu.kit.iti.formal.psdbg.parser.data.Value;
import edu.kit.iti.formal.psdbg.parser.types.SimpleType; import edu.kit.iti.formal.psdbg.parser.types.SimpleType;
import edu.kit.iti.formal.psdbg.parser.types.TermType; import edu.kit.iti.formal.psdbg.parser.types.TermType;
import edu.kit.iti.formal.psdbg.parser.types.TypeFacade;
import lombok.Getter; import lombok.Getter;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
...@@ -54,12 +54,25 @@ public class KeYMatcher implements MatcherApi<KeyData> { ...@@ -54,12 +54,25 @@ public class KeYMatcher implements MatcherApi<KeyData> {
} }
/** /**
* @param proof *
* @param kd
* @param term
* @return null if the term is not derivable or the new state * @return null if the term is not derivable or the new state
*/ */
public static GoalNode<KeyData> isDerivable(Proof proof, GoalNode<KeyData> kd, Term term) { public GoalNode<KeyData> isDerivable(GoalNode<KeyData> kd, Value pattern) {
Proof proof = kd.getData().getProof();
TermValue tv = (TermValue) pattern.getData();
Term term = tv.getTerm();
if(term == null) {
Services services = kd.getData().getProof().getServices();
try {
term = new TermBuilder(services.getTermFactory(), services).parseTerm(tv.getTermRepr());
} catch (ParserException e) {
throw new RuntimeException(e);
}
}
Taclet cut = proof.getEnv().getInitConfigForEnvironment().lookupActiveTaclet(CUT_TACLET_NAME); Taclet cut = proof.getEnv().getInitConfigForEnvironment().lookupActiveTaclet(CUT_TACLET_NAME);
TacletApp app = NoPosTacletApp.createNoPosTacletApp(cut); TacletApp app = NoPosTacletApp.createNoPosTacletApp(cut);
SchemaVariable sv = (SchemaVariable) app.uninstantiatedVars().iterator().next(); SchemaVariable sv = (SchemaVariable) app.uninstantiatedVars().iterator().next();
...@@ -82,7 +95,14 @@ public class KeYMatcher implements MatcherApi<KeyData> { ...@@ -82,7 +95,14 @@ public class KeYMatcher implements MatcherApi<KeyData> {
boolean isDerivable = proof.getSubtreeGoals(toShow.node()).size() == 0; boolean isDerivable = proof.getSubtreeGoals(toShow.node()).size() == 0;
if (isDerivable) { if (isDerivable) {
KeyData kdataNew = new KeyData(kd.getData(), goalList.head()); //find the open goal node
Goal toSet= null;
if(goalList.head().node().isClosed()){
toSet = goalList.tail().head();
} else{
toSet = goalList.head();
}
KeyData kdataNew = new KeyData(kd.getData(), toSet);
GoalNode<KeyData> newGoalNode = new GoalNode<KeyData>(kd, kdataNew, kdataNew.isClosedNode()); GoalNode<KeyData> newGoalNode = new GoalNode<KeyData>(kd, kdataNew, kdataNew.isClosedNode());
return newGoalNode; return newGoalNode;
} else { } else {
......
...@@ -29,12 +29,12 @@ public class KeyMatcherDerivableTest { ...@@ -29,12 +29,12 @@ public class KeyMatcherDerivableTest {
Term termQ = new TermBuilder(f.getEnvironment().getServices().getTermFactory(), Term termQ = new TermBuilder(f.getEnvironment().getServices().getTermFactory(),
f.getEnvironment().getServices()).parseTerm("q"); f.getEnvironment().getServices()).parseTerm("q");
System.out.println(termQ); System.out.println(termQ);
GoalNode<KeyData> a = KeYMatcher.isDerivable(proof, gn, termQ); //GoalNode<KeyData> a = KeYMatcher.isDerivable(proof, gn, termQ);
System.out.println(proof); System.out.println(proof);
Assert.assertNotNull(a); // Assert.assertNotNull(a);
Assert.assertEquals(1, proof.getSubtreeGoals(proof.root()).size()); Assert.assertEquals(1, proof.getSubtreeGoals(proof.root()).size());
} }
......
...@@ -47,6 +47,9 @@ public class KeyMatcherFacadeTest { ...@@ -47,6 +47,9 @@ public class KeyMatcherFacadeTest {
*/ */
@Test @Test
public void matchTerms() throws Exception { public void matchTerms() throws Exception {
System.out.println(shouldMatchT("f(a)", "...f(a)..."));
System.out.println(shouldMatchT("h(a,a)", "...h(?X,?Y)..."));
System.out.println(shouldMatchT("f(a)", "?")); System.out.println(shouldMatchT("f(a)", "?"));
System.out.println(shouldMatchT("f(a)", "f(a)")); System.out.println(shouldMatchT("f(a)", "f(a)"));
...@@ -59,6 +62,9 @@ public class KeyMatcherFacadeTest { ...@@ -59,6 +62,9 @@ public class KeyMatcherFacadeTest {
@Test @Test
public void matchSeq() throws Exception { public void matchSeq() throws Exception {
//atm missing is catching the toplevel formula //atm missing is catching the toplevel formula
shouldMatch("pred(a), pred(b), a=b, a=c ==> pred(c)", "pred(?X), ?X=?Y ==> ", "[?X=a, ?Y=b}, {?X=a, ?Y=c}]");
shouldMatch("pred(a), pred(b), a=b, a=c ==> pred(c)", "pred(?X), ?X=?Y ==> pred(?Y)", "[{?X=a, ?Y=c}]");
shouldMatch("!q==>p,!p","!q ==> p", "[{}]"); shouldMatch("!q==>p,!p","!q ==> p", "[{}]");
shouldMatch("!p ,p ==> q", "!p ==> q", "[{}]"); shouldMatch("!p ,p ==> q", "!p ==> q", "[{}]");
shouldMatch("!q ,p ==> q", "!p ==> q", "{NOMATCH}"); shouldMatch("!q ,p ==> q", "!p ==> q", "{NOMATCH}");
......
...@@ -12,7 +12,9 @@ import edu.kit.iti.formal.psdbg.parser.Visitor; ...@@ -12,7 +12,9 @@ import edu.kit.iti.formal.psdbg.parser.Visitor;
import edu.kit.iti.formal.psdbg.parser.ast.*; import edu.kit.iti.formal.psdbg.parser.ast.*;
import edu.kit.iti.formal.psdbg.parser.data.Value;