Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
sarah.grebing
ProofScriptParser
Commits
3934685e
Commit
3934685e
authored
Mar 16, 2018
by
Sarah Grebing
Browse files
Bugfix
parent
a7b1ed25
Pipeline
#19956
failed with stages
in 2 minutes and 13 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
rt-key/src/main/java/edu/kit/iti/formal/psdbg/interpreter/matcher/KeyTermMatcher.java
View file @
3934685e
...
...
@@ -19,7 +19,7 @@ public class KeyTermMatcher extends KeyTermBaseVisitor<Matchings, MatchPath> {
private
String
randomName
;
MatchPath
peek
;
//
MatchPath peek;
private
List
<
Integer
>
currentposition
=
new
ArrayList
<>();
...
...
@@ -42,18 +42,11 @@ public class KeyTermMatcher extends KeyTermBaseVisitor<Matchings, MatchPath> {
public
Matchings
matchesSequent
(
Sequent
sequent
,
Sequent
pattern
)
{
MatchPath
.
MPSequent
mps
=
MatchPathFacade
.
create
(
sequent
);
// MatchPath.MPSequent mps = new MatchPath.MPSequent(sequent);
Matchings
ms
=
matchesSemisequent
(
// new MatchPath.MPSemiSequent(mps, sequent.succedent(), false),
MatchPathFacade
.
createSuccedent
(
mps
),
pattern
.
succedent
());
//peek = new MatchPath.MPSemiSequent(mps, sequent.succedent(), true);
Matchings
ma
=
matchesSemisequent
(
MatchPathFacade
.
createAntecedent
(
mps
),
// new MatchPath.MPSemiSequent(mps, sequent.antecedent(), true),
pattern
.
antecedent
());
return
reduceConform
(
ms
,
ma
);
...
...
@@ -98,14 +91,6 @@ public class KeyTermMatcher extends KeyTermBaseVisitor<Matchings, MatchPath> {
return
ret
;
}
/* private MatchPath.MPTerm create(MatchPath.MPSequentFormula sf) {
return new MatchPath.MPTerm(sf, sf.getUnit().formula(), MatchPath.SEQUENT_FORMULA_ROOT);
}
private MatchPath.MPSequentFormula create(MatchPath.MPSemiSequent peek, int pos) {
return new MatchPath.MPSequentFormula(peek, peek.getUnit().get(pos), pos);
}
*/
/**
* Visit a '...'MatchPath'...' structure
...
...
@@ -116,7 +101,7 @@ public class KeyTermMatcher extends KeyTermBaseVisitor<Matchings, MatchPath> {
@DispatchOn
(
EllipsisOp
.
class
)
public
Matchings
visitEllipsisOp
(
Term
pattern
,
MatchPath
subject
)
{
Matchings
matchings
=
new
Matchings
();
subTerms
((
MatchPath
.
MPTerm
)
peek
).
forEach
(
sub
->
{
subTerms
((
MatchPath
.
MPTerm
)
subject
).
forEach
(
sub
->
{
Matchings
s
=
visit
(
pattern
.
sub
(
0
),
sub
);
matchings
.
addAll
(
s
);
});
...
...
@@ -236,7 +221,7 @@ public class KeyTermMatcher extends KeyTermBaseVisitor<Matchings, MatchPath> {
if
(
matchings
!=
NO_MATCH
)
{
String
name
=
pattern
.
sub
(
0
).
op
().
name
().
toString
();
for
(
Map
<
String
,
MatchPath
>
a
:
matchings
)
{
a
.
put
(
name
,
peek
);
a
.
put
(
name
,
subject
);
}
}
return
matchings
;
...
...
@@ -251,7 +236,8 @@ public class KeyTermMatcher extends KeyTermBaseVisitor<Matchings, MatchPath> {
if
(
subject
.
getUnit
().
subs
().
size
()
!=
pattern
.
subs
().
size
())
{
return
NO_MATCH
;
}
if
(
pattern
.
equals
(
subject1
.
getUnit
()))
return
EMPTY_MATCH
;
for
(
int
i
=
0
;
i
<
subject
.
getUnit
().
subs
().
size
();
i
++)
{
Term
tt
=
subject
.
getUnit
().
sub
(
i
);
Term
pt
=
pattern
.
sub
(
i
);
...
...
@@ -268,6 +254,7 @@ public class KeyTermMatcher extends KeyTermBaseVisitor<Matchings, MatchPath> {
//region helper
private
String
getBindingName
(
Name
name
)
{
if
(
name
.
toString
().
equals
(
"?"
))
return
getRandomName
();
return
name
.
toString
();
...
...
rt-key/src/test/java/edu/kit/iti/formal/psdbg/interpreter/matcher/KeyMatcherFacadeTest.java
View file @
3934685e
...
...
@@ -42,8 +42,8 @@ public class KeyMatcherFacadeTest {
@Test
public
void
matchSeq
()
throws
Exception
{
shouldMatch
(
"p ==>"
,
"p ==>"
);
shouldMatch
(
"==> pred(a), q"
,
"==> pred(?X:S), q"
);
shouldMatch
(
"==> p, q"
,
"==> ?X:Formula"
);
shouldMatch
(
"==> p, q"
,
"==> p, q"
);
shouldMatch
(
"==> p, q"
,
"==> q, p"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment