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
2c4d4929
Commit
2c4d4929
authored
May 22, 2018
by
Alexander Weigl
Browse files
Removal of using clause in match expressions.
parent
ef3ebf59
Changes
12
Hide whitespace changes
Inline
Side-by-side
lang/src/main/java/edu/kit/iti/formal/psdbg/parser/ASTChanger.java
View file @
2c4d4929
...
...
@@ -59,10 +59,6 @@ public class ASTChanger extends DefaultASTVisitor<ASTNode> {
@Override
public
MatchExpression
visit
(
MatchExpression
match
)
{
if
(
match
.
getSignature
()
!=
null
)
match
.
setSignature
((
Signature
)
match
.
getSignature
().
accept
(
this
));
match
.
setPattern
((
Expression
)
match
.
getPattern
().
accept
(
this
));
return
match
;
}
...
...
lint/src/main/java/edu/kit/iti/formal/psdbg/lint/checkers/NegatedMatchWithUsing.java
View file @
2c4d4929
...
...
@@ -22,9 +22,9 @@ public class NegatedMatchWithUsing extends AbstractLintRule {
public
Void
visit
(
UnaryExpression
ue
)
{
if
(
ue
.
getExpression
()
instanceof
MatchExpression
)
{
MatchExpression
me
=
(
MatchExpression
)
ue
.
getExpression
();
if
(
me
.
getSignature
()
!=
null
&&
me
.
getSignature
().
size
()
>
0
)
{
/*
if (me.getSignature() != null && me.getSignature().size() > 0) {
problem(ISSUE, ue, me);
}
}
*/
}
return
super
.
visit
(
ue
);
}
...
...
rt-key/src/main/java/edu/kit/iti/formal/psdbg/interpreter/functions/FindInSequence.java
View file @
2c4d4929
package
edu.kit.iti.formal.psdbg.interpreter.functions
;
import
edu.kit.iti.formal.psdbg.interpreter.Evaluator
;
import
edu.kit.iti.formal.psdbg.interpreter.matcher.KeYMatcher
;
import
edu.kit.iti.formal.psdbg.interpreter.data.KeyData
;
import
edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment
;
import
edu.kit.iti.formal.psdbg.interpreter.matcher.KeYMatcher
;
import
edu.kit.iti.formal.psdbg.parser.NotWelldefinedException
;
import
edu.kit.iti.formal.psdbg.parser.Visitor
;
import
edu.kit.iti.formal.psdbg.parser.ast.FunctionCall
;
import
edu.kit.iti.formal.psdbg.parser.ast.MatchExpression
;
import
edu.kit.iti.formal.psdbg.parser.ast.Signature
;
import
edu.kit.iti.formal.psdbg.parser.ast.Variable
;
import
edu.kit.iti.formal.psdbg.parser.data.Value
;
import
edu.kit.iti.formal.psdbg.parser.function.ScriptFunction
;
...
...
@@ -52,12 +51,11 @@ public class FindInSequence implements ScriptFunction {
Evaluator
<
KeyData
>
e
=
(
Evaluator
<
KeyData
>)
val
;
try
{
MatchExpression
match
=
(
MatchExpression
)
call
.
getArguments
().
get
(
0
);
Signature
sig
=
match
.
getSignature
();
//
Signature sig = match.getSignature();
Value
pattern
=
e
.
eval
(
match
.
getPattern
());
KeYMatcher
matcher
=
(
KeYMatcher
)
e
.
getMatcher
();
if
(
TypeFacade
.
isTerm
(
pattern
.
getType
()))
{
List
<
VariableAssignment
>
va
=
matcher
.
matchSeq
(
e
.
getGoal
(),
(
String
)
pattern
.
getData
(),
sig
);
List
<
VariableAssignment
>
va
=
matcher
.
matchSeq
(
e
.
getGoal
(),
(
String
)
pattern
.
getData
());
if
(
va
.
isEmpty
())
{
throw
new
IllegalArgumentException
(
"No match found for "
+
match
.
getPattern
());
}
else
{
...
...
rt-key/src/main/java/edu/kit/iti/formal/psdbg/interpreter/matcher/KeYMatcher.java
View file @
2c4d4929
...
...
@@ -182,11 +182,11 @@ public class KeYMatcher implements MatcherApi<KeyData> {
}
@Override
public
List
<
VariableAssignment
>
matchSeq
(
GoalNode
<
KeyData
>
currentState
,
String
pattern
,
Signature
sig
)
{
public
List
<
VariableAssignment
>
matchSeq
(
GoalNode
<
KeyData
>
currentState
,
String
pattern
)
{
KeyMatcherFacade
kmf
=
new
KeyMatcherFacade
(
currentState
.
getData
().
getEnv
(),
currentState
.
getData
().
getNode
().
sequent
());
//System.out.println("State that will be matched " + currentState.getData().getNode().sequent() + " with pattern " + pattern);
//System.out.println("Signature " + sig.toString());
Matchings
m
=
kmf
.
matches
(
pattern
,
sig
);
Matchings
m
=
kmf
.
matches
(
pattern
);
if
(
m
.
isNoMatch
())
{
LOGGER
.
debug
(
"currentState has no match= "
+
currentState
.
getData
().
getNode
().
sequent
());
...
...
rt-key/src/main/java/edu/kit/iti/formal/psdbg/interpreter/matcher/KeyMatcherFacade.java
View file @
2c4d4929
...
...
@@ -30,16 +30,16 @@ public class KeyMatcherFacade {
private
final
Sequent
sequent
;
public
Matchings
matches
(
String
pattern
,
Signature
sig
)
{
public
Matchings
matches
(
String
pattern
)
{
if
(
pattern
.
contains
(
"==>"
))
{
return
matchesSequent
(
pattern
,
sig
);
return
matchesSequent
(
pattern
);
}
else
{
return
matchesTerm
(
pattern
,
sig
);
return
matchesTerm
(
pattern
);
}
}
private
Matchings
matchesTerm
(
String
pattern
,
Signature
sig
)
{
private
Matchings
matchesTerm
(
String
pattern
)
{
List
<
Term
>
positions
=
new
ArrayList
<>();
for
(
String
patternTerm
:
hasToplevelComma
(
pattern
))
{
try
{
...
...
@@ -76,7 +76,7 @@ public class KeyMatcherFacade {
return
rt
;
}
private
Matchings
matchesSequent
(
String
pattern
,
Signature
sig
)
{
private
Matchings
matchesSequent
(
String
pattern
)
{
Sequent
seq
=
null
;
try
{
...
...
rt/src/main/java/edu/kit/iti/formal/psdbg/interpreter/Evaluator.java
View file @
2c4d4929
...
...
@@ -71,9 +71,6 @@ public class Evaluator<T> extends DefaultASTVisitor<Value> implements ScopeObser
@Override
public
Value
visit
(
MatchExpression
match
)
{
enterScope
(
match
);
if
(
match
.
getSignature
()
!=
null
&&
!
match
.
getSignature
().
isEmpty
())
{
throw
new
IllegalStateException
(
"not supported"
);
}
List
<
VariableAssignment
>
va
=
null
;
Value
pattern
=
(
Value
)
match
.
getPattern
().
accept
(
this
);
if
(
match
.
isDerivable
())
{
...
...
@@ -81,7 +78,7 @@ public class Evaluator<T> extends DefaultASTVisitor<Value> implements ScopeObser
if
(
pattern
.
getType
()
==
SimpleType
.
STRING
)
{
va
=
matcher
.
matchLabel
(
goal
,
(
String
)
pattern
.
getData
());
}
else
if
(
TypeFacade
.
isTerm
(
pattern
.
getType
()))
{
va
=
matcher
.
matchSeq
(
goal
,
(
String
)
pattern
.
getData
()
,
match
.
getSignature
()
);
va
=
matcher
.
matchSeq
(
goal
,
(
String
)
pattern
.
getData
());
}
}
...
...
rt/src/main/java/edu/kit/iti/formal/psdbg/interpreter/MatchEvaluator.java
View file @
2c4d4929
...
...
@@ -157,8 +157,7 @@ public class MatchEvaluator extends DefaultASTVisitor<List<VariableAssignment>>
*/
@Override
public
List
<
VariableAssignment
>
visit
(
MatchExpression
match
)
{
Signature
sig
=
match
.
getSignature
();
//Signature sig = match.getSignature();
Value
pattern
=
eval
.
eval
(
match
.
getPattern
());
// Value pattern = (Value) match.getPattern().accept(this);
...
...
@@ -167,7 +166,7 @@ public class MatchEvaluator extends DefaultASTVisitor<List<VariableAssignment>>
va
=
getMatcher
().
matchLabel
(
goal
,
(
String
)
pattern
.
getData
());
//TODO extract the results form the matcher in order to retrieve the selection results
}
else
if
(
TypeFacade
.
isTerm
(
pattern
.
getType
()))
{
va
=
getMatcher
().
matchSeq
(
goal
,
(
String
)
pattern
.
getData
()
,
sig
);
va
=
getMatcher
().
matchSeq
(
goal
,
(
String
)
pattern
.
getData
());
// System.out.println("va = " + va);
}
return
va
!=
null
?
va
:
Collections
.
emptyList
();
...
...
rt/src/main/java/edu/kit/iti/formal/psdbg/interpreter/MatcherApi.java
View file @
2c4d4929
...
...
@@ -12,6 +12,6 @@ import java.util.List;
*/
public
interface
MatcherApi
<
T
>
{
List
<
VariableAssignment
>
matchLabel
(
GoalNode
<
T
>
currentState
,
String
label
);
List
<
VariableAssignment
>
matchSeq
(
GoalNode
<
T
>
currentState
,
String
data
,
Signature
sig
);
List
<
VariableAssignment
>
matchSeq
(
GoalNode
<
T
>
currentState
,
String
data
);
}
rt/src/main/java/edu/kit/iti/formal/psdbg/interpreter/dbg/PseudoMatcher.java
View file @
2c4d4929
...
...
@@ -25,19 +25,13 @@ public class PseudoMatcher implements MatcherApi<String> {
}
@Override
public
List
<
VariableAssignment
>
matchSeq
(
GoalNode
<
String
>
currentState
,
String
data
,
Signature
sig
)
{
public
List
<
VariableAssignment
>
matchSeq
(
GoalNode
<
String
>
currentState
,
String
data
)
{
Pattern
p
=
Pattern
.
compile
(
data
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
m
=
p
.
matcher
(
currentState
.
getData
());
if
(!
m
.
matches
())
return
Collections
.
emptyList
();
VariableAssignment
va
=
new
VariableAssignment
();
for
(
Map
.
Entry
<
Variable
,
Type
>
s
:
sig
.
entrySet
())
{
va
.
declare
(
s
.
getKey
(),
s
.
getValue
());
va
.
assign
(
s
.
getKey
(),
Value
.
from
(
m
.
group
(
s
.
getKey
().
getIdentifier
())));
}
return
Collections
.
singletonList
(
va
);
}
}
ui/src/main/java/edu/kit/iti/formal/psdbg/gui/controls/FindNearestASTNode.java
View file @
2c4d4929
...
...
@@ -66,7 +66,7 @@ public class FindNearestASTNode implements ASTTraversal<ASTNode> {
@Override
public
ASTNode
visit
(
MatchExpression
match
)
{
return
childOrMe
(
match
,
match
.
getSignature
(),
match
.
getDerivableTerm
(),
match
.
getPattern
());
return
childOrMe
(
match
,
match
.
getDerivableTerm
(),
match
.
getPattern
());
}
@Override
...
...
ui/src/main/java/edu/kit/iti/formal/psdbg/gui/controls/SequentMatcher.java
View file @
2c4d4929
...
...
@@ -127,7 +127,7 @@ public class SequentMatcher extends BorderPane {
public
void
startMatch
()
{
sequentView
.
clearHighlight
();
KeyMatcherFacade
kmf
=
KeyMatcherFacade
.
builder
().
environment
(
getSelectedGoalNodeToShow
().
getData
().
getEnv
()).
sequent
(
getSelectedGoalNodeToShow
().
getData
().
getNode
().
sequent
()).
build
();
Matchings
matchings
=
kmf
.
matches
(
matchpattern
.
getText
()
,
null
);
Matchings
matchings
=
kmf
.
matches
(
matchpattern
.
getText
());
//MatcherFacade.matches(matchpattern.getText(), getSelectedGoalNodeToShow().getData().getNode().sequent(), true,
//services);
...
...
ui/src/main/java/edu/kit/iti/formal/psdbg/gui/controls/SequentView.java
View file @
2c4d4929
...
...
@@ -209,7 +209,7 @@ public class SequentView extends CodeArea {
if
(
node
.
get
().
sequent
()
!=
null
)
{
KeyMatcherFacade
kmf
=
KeyMatcherFacade
.
builder
().
environment
(
this
.
getKeYProofFacade
().
getEnvironment
())
.
sequent
(
node
.
get
().
sequent
()).
build
();
Matchings
m
=
kmf
.
matches
(
pattern
,
null
);
Matchings
m
=
kmf
.
matches
(
pattern
);
// Matchings m =
//MatcherFacade.matches(pattern, node.get().sequent(), true, services);
...
...
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