Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
ProofScriptParser
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
24
Issues
24
List
Boards
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sarah.grebing
ProofScriptParser
Commits
427e4177
Commit
427e4177
authored
Aug 21, 2017
by
Sarah Grebing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix for emptyMatch on sequent
parent
c8626559
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
24 deletions
+47
-24
src/main/java/edu/kit/formal/psdb/termmatcher/MatcherImpl.java
...ain/java/edu/kit/formal/psdb/termmatcher/MatcherImpl.java
+35
-18
src/test/java/edu/kit/formal/psdb/termmatcher/MatcherFacadeTest.java
...va/edu/kit/formal/psdb/termmatcher/MatcherFacadeTest.java
+12
-6
No files found.
src/main/java/edu/kit/formal/psdb/termmatcher/MatcherImpl.java
View file @
427e4177
...
...
@@ -3,6 +3,7 @@ package edu.kit.formal.psdb.termmatcher;
import
de.uka.ilkd.key.logic.SequentFormula
;
import
de.uka.ilkd.key.logic.Term
;
import
org.antlr.v4.runtime.Token
;
import
org.key_project.util.collection.ImmutableArray
;
import
java.util.*
;
import
java.util.stream.IntStream
;
...
...
@@ -57,29 +58,40 @@ class MatcherImpl extends MatchPatternDualVisitor<Matchings, Term> {
}
/**
* Visit '_'
*
* Visit a semisequent pattern f(x), f(y)
* @param ctx
* @param peek
* @return
*/
@Override
public
Matchings
visitDontCare
(
MatchPatternParser
.
DontCareContext
ctx
,
Term
peek
)
{
protected
Matchings
visitSemiSeqPattern
(
MatchPatternParser
.
SemiSeqPatternContext
ctx
,
Term
peek
)
{
return
null
;
}
/*@Override
protected Matchings visitStartDontCare(MatchPatternParser.StarDontCareContext ctx, Term peek) {
if (peek != null) {
return EMPTY_MATCH;
} else {
return NO_MATCH;
}
}
}
*/
/*@Override
protected Matchings visitStartDontCare(MatchPatternParser.StarDontCareContext ctx, Term peek) {
/**
* Visit '_'
*
* @param ctx
* @param peek
* @return
*/
@Override
public
Matchings
visitDontCare
(
MatchPatternParser
.
DontCareContext
ctx
,
Term
peek
)
{
if
(
peek
!=
null
)
{
return
EMPTY_MATCH
;
}
else
{
return
NO_MATCH
;
}
}
*/
}
/**
* Visit a Schema Variable
...
...
@@ -239,20 +251,25 @@ class MatcherImpl extends MatchPatternDualVisitor<Matchings, Term> {
return
NO_MATCH
;
}
/**
* Visit a semisequent pattern f(x), f(y)
* @param ctx
* @param peek
* @return
*/
@Override
protected
Matchings
visitSemiSeqPattern
(
MatchPatternParser
.
SemiSeqPatternContext
ctx
,
Term
peek
)
{
return
null
;
protected
Matchings
visitNumber
(
MatchPatternParser
.
NumberContext
ctx
,
Term
peek
)
{
//we are at a natural number
if
(
peek
.
op
().
name
().
toString
().
equals
(
"Z"
))
{
ImmutableArray
<
Term
>
subs
=
peek
.
subs
();
int
transformedString
=
transformToNumber
(
peek
.
sub
(
0
));
return
EMPTY_MATCH
;
}
else
{
return
NO_MATCH
;
}
}
@Override
protected
Matchings
visitNumber
(
MatchPatternParser
.
NumberContext
ctx
,
Term
peek
)
{
return
null
;
private
int
transformToNumber
(
Term
sub
)
{
int
number
=
0
;
return
0
;
}
/**
...
...
src/test/java/edu/kit/formal/psdb/termmatcher/MatcherFacadeTest.java
View file @
427e4177
...
...
@@ -46,17 +46,16 @@ public class MatcherFacadeTest {
shouldMatch
(
"i+j"
,
"add(?X,?Y)"
,
"[{?X=i, ?Y=j}]"
);
shouldMatch
(
"i+j"
,
"?X+?Y"
,
"[{?X=i, ?Y=j}]"
);
shouldMatchForm
(
"p & q"
,
"p & ?X"
,
"[{?X=q}]"
);
//shouldMatchForm("p & q", "?X & q", "[{?X=p}]");
//shouldMatch("1*j", "add(1,?Y)", "[{?Y=j}]");
shouldMatchForm
(
"p & q"
,
"?X & q"
,
"[{?X=p}]"
);
System
.
out
.
println
(
parseKeyTerm
(
"12004"
));
shouldMatch
(
"1"
,
"1"
);
// shouldMatch("1*j", "1 + ?Y", "[]");
//shouldMatch("f(a) ==> f(a), f(b)" , "==> f(?X)", [{?X=a}]);
//shouldMatch("f(a) ==> f(a), f(b)" , "f(a) ==> f(?X)", [{?X=a}]);
//shouldNotMatch("f(a) ==> f(a), f(b)" , "f(?X) ==> f(?X), f(a)");
//shouldMatch("f(a) ==> f(a), f(b)" , "==>");
//shouldMatch("f(a) ==> f(a), f(b)" , "_ ==> _");
//shouldMatch("f(a) ==> f(a), f(b)" , " ==> _");
//shouldMatch("f(a) ==> f(a), f(b)" , "_ ==> ");
}
...
...
@@ -163,6 +162,13 @@ public class MatcherFacadeTest {
shouldMatchSeq
(
"==> pred(a)"
,
"==>"
,
"[{EMPTY_MATCH=null}]"
);
shouldMatchSeq
(
"pred(a) ==> "
,
"==>"
,
"[{EMPTY_MATCH=null}]"
);
shouldMatchSeq
(
"pred(a) ==> pred(a), pred(b)"
,
"==>"
,
"[{EMPTY_MATCH=null}]"
);
shouldMatchSeq
(
"pred(a) ==> pred(a), pred(b)"
,
"_ ==> "
,
"[{EMPTY_MATCH=null}]"
);
//these two need to be checked I think
shouldMatchSeq
(
"pred(a) ==> pred(a), pred(b)"
,
"_ ==> _"
,
"[{EMPTY_MATCH=null}, {EMPTY_MATCH=null}]"
);
shouldMatchSeq
(
"pred(a) ==> pred(a), pred(b)"
,
" ==> _"
,
"[{EMPTY_MATCH=null}, {EMPTY_MATCH=null}]"
);
}
private
void
shouldMatchSeq
(
String
seq
,
String
seqPattern
,
String
exp
)
throws
ParserException
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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