Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
sarah.grebing
ProofScriptParser
Commits
feec8b4b
Commit
feec8b4b
authored
May 24, 2017
by
Sarah Grebing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Matching bugs!
parent
53a01a49
Pipeline
#10732
failed with stage
in 1 minute and 29 seconds
Changes
13
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
132 additions
and
144 deletions
+132
-144
src/main/java/edu/kit/formal/dbg/Debugger.java
src/main/java/edu/kit/formal/dbg/Debugger.java
+30
-17
src/main/java/edu/kit/formal/interpreter/Evaluator.java
src/main/java/edu/kit/formal/interpreter/Evaluator.java
+5
-9
src/main/java/edu/kit/formal/interpreter/GoalNode.java
src/main/java/edu/kit/formal/interpreter/GoalNode.java
+1
-0
src/main/java/edu/kit/formal/interpreter/Interpreter.java
src/main/java/edu/kit/formal/interpreter/Interpreter.java
+28
-47
src/main/java/edu/kit/formal/interpreter/Main.java
src/main/java/edu/kit/formal/interpreter/Main.java
+8
-10
src/main/java/edu/kit/formal/interpreter/MatchEvaluator.java
src/main/java/edu/kit/formal/interpreter/MatchEvaluator.java
+33
-27
src/main/java/edu/kit/formal/interpreter/MatcherApi.java
src/main/java/edu/kit/formal/interpreter/MatcherApi.java
+4
-1
src/main/java/edu/kit/formal/interpreter/Value.java
src/main/java/edu/kit/formal/interpreter/Value.java
+9
-8
src/main/java/edu/kit/formal/interpreter/VariableAssignment.java
...n/java/edu/kit/formal/interpreter/VariableAssignment.java
+1
-0
src/main/java/edu/kit/formal/proofscriptparser/ast/TermLiteral.java
...ava/edu/kit/formal/proofscriptparser/ast/TermLiteral.java
+2
-0
src/test/java/edu/kit/formal/interpreter/InterpreterTest.java
...test/java/edu/kit/formal/interpreter/InterpreterTest.java
+4
-0
src/test/java/edu/kit/formal/interpreter/MatchEvaluatorTest.java
...t/java/edu/kit/formal/interpreter/MatchEvaluatorTest.java
+3
-24
src/test/resources/edu/kit/formal/interpreter/simple1.txt
src/test/resources/edu/kit/formal/interpreter/simple1.txt
+4
-1
No files found.
src/main/java/edu/kit/formal/dbg/Debugger.java
View file @
feec8b4b
...
...
@@ -18,6 +18,7 @@ import java.io.InputStreamReader;
import
java.math.BigInteger
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.BiConsumer
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
...
...
@@ -190,6 +191,35 @@ public class Debugger {
}
public
static
class
PseudoMatcher
implements
MatcherApi
{
@Override
public
List
<
VariableAssignment
>
matchLabel
(
GoalNode
currentState
,
String
label
)
{
Pattern
p
=
Pattern
.
compile
(
label
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
m
=
p
.
matcher
(
currentState
.
getSequent
());
return
m
.
matches
()
?
Collections
.
singletonList
(
new
VariableAssignment
())
:
Collections
.
emptyList
();
}
@Override
public
List
<
VariableAssignment
>
matchSeq
(
GoalNode
currentState
,
String
data
,
Signature
sig
)
{
Pattern
p
=
Pattern
.
compile
(
data
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
m
=
p
.
matcher
(
currentState
.
getSequent
());
p
.
pattern
();
if
(!
m
.
matches
())
return
Collections
.
emptyList
();
VariableAssignment
va
=
new
VariableAssignment
();
for
(
Map
.
Entry
<
Variable
,
Type
>
s
:
sig
.
entrySet
())
{
va
.
addVarDecl
(
s
.
getKey
().
getIdentifier
(),
s
.
getValue
());
va
.
setVarValue
(
s
.
getKey
().
getIdentifier
(),
Value
.
from
(
m
.
group
(
s
.
getKey
().
getIdentifier
())));
}
return
Collections
.
singletonList
(
va
);
}
}
private
class
CommandLogger
extends
DefaultASTVisitor
<
Void
>
{
public
void
suffix
(
ASTNode
node
)
{
...
...
@@ -255,21 +285,4 @@ public class Debugger {
return
super
.
visit
(
repeatStatement
);
}
}
public
static
class
PseudoMatcher
implements
MatcherApi
{
@Override
public
List
<
VariableAssignment
>
matchLabel
(
GoalNode
currentState
,
String
label
)
{
Pattern
p
=
Pattern
.
compile
(
label
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
m
=
p
.
matcher
(
currentState
.
getSequent
());
return
m
.
matches
()
?
Collections
.
singletonList
(
new
VariableAssignment
())
:
Collections
.
emptyList
();
}
@Override
public
List
<
VariableAssignment
>
matchSeq
(
GoalNode
currentState
,
String
data
)
{
return
Collections
.
emptyList
();
}
}
}
src/main/java/edu/kit/formal/interpreter/Evaluator.java
View file @
feec8b4b
...
...
@@ -7,7 +7,6 @@ import lombok.Getter;
import
lombok.Setter
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
...
...
@@ -19,18 +18,15 @@ import java.util.List;
public
class
Evaluator
extends
DefaultASTVisitor
<
Value
>
implements
ScopeObservable
{
@Getter
private
final
List
<
VariableAssignment
>
matchedVariables
=
new
ArrayList
<>();
private
final
GoalNode
goal
;
private
final
VariableAssignment
state
;
@Getter
@Setter
private
MatcherApi
matcher
;
@Getter
private
List
<
Visitor
>
entryListeners
=
new
ArrayList
<>(),
exitListeners
=
new
ArrayList
<>();
private
final
GoalNode
goal
;
private
final
VariableAssignment
state
;
public
Evaluator
(
VariableAssignment
assignment
,
GoalNode
node
)
{
state
=
new
VariableAssignment
(
assignment
);
// unmodifiable version of assignment
goal
=
node
;
...
...
@@ -68,7 +64,7 @@ public class Evaluator extends DefaultASTVisitor<Value> implements ScopeObservab
if
(
pattern
.
getType
()
==
Type
.
STRING
)
{
va
=
matcher
.
matchLabel
(
goal
,
(
String
)
pattern
.
getData
());
}
else
if
(
pattern
.
getType
()
==
Type
.
TERM
)
{
va
=
matcher
.
matchSeq
(
goal
,
(
String
)
pattern
.
getData
());
va
=
matcher
.
matchSeq
(
goal
,
(
String
)
pattern
.
getData
()
,
match
.
getSignature
()
);
}
return
va
!=
null
&&
va
.
size
()
>
0
?
Value
.
TRUE
:
Value
.
FALSE
;
...
...
@@ -76,13 +72,13 @@ public class Evaluator extends DefaultASTVisitor<Value> implements ScopeObservab
/**
* TODO Connect with KeY
*
*
TODO remove return
* @param term
* @return
*/
@Override
public
Value
visit
(
TermLiteral
term
)
{
return
null
;
return
Value
.
from
(
term
)
;
}
@Override
...
...
src/main/java/edu/kit/formal/interpreter/GoalNode.java
View file @
feec8b4b
...
...
@@ -126,6 +126,7 @@ public class GoalNode {
return
assignments
;
}
public
VariableAssignment
exitNewVarScope
()
{
this
.
assignments
=
this
.
assignments
.
pop
();
return
assignments
;
...
...
src/main/java/edu/kit/formal/interpreter/Interpreter.java
View file @
feec8b4b
...
...
@@ -153,51 +153,28 @@ public class Interpreter extends DefaultASTVisitor<Void>
//global List after all Case Statements
List
<
GoalNode
>
goalsAfterCases
=
new
ArrayList
<>();
//copy the list of goal nodes for keeping track of goals
Set
<
GoalNode
>
copiedLis
t
=
new
HashSet
<>(
allGoalsBeforeCases
);
Set
<
GoalNode
>
remainingGoalsSe
t
=
new
HashSet
<>(
allGoalsBeforeCases
);
//handle cases
List
<
CaseStatement
>
cases
=
casesStatement
.
getCases
();
for
(
CaseStatement
aCase
:
cases
)
{
Map
<
GoalNode
,
VariableAssignment
>
matchedGoals
=
matchGoal
(
copiedLis
t
,
aCase
);
Map
<
GoalNode
,
VariableAssignment
>
matchedGoals
=
matchGoal
(
remainingGoalsSe
t
,
aCase
);
if
(
matchedGoals
!=
null
)
{
copiedLis
t
.
removeAll
(
matchedGoals
.
e
ntr
ySet
());
goalsAfterCases
.
addAll
(
executeCase
(
aCase
.
getBody
(),
matchedGoals
.
keySet
()
));
remainingGoalsSe
t
.
removeAll
(
matchedGoals
.
k
eySet
());
goalsAfterCases
.
addAll
(
executeCase
(
aCase
.
getBody
(),
matchedGoals
));
}
}
/* Iterator<CaseStatement> casesIter = cases.iterator();
while (casesIter.hasNext()) {
//get information for case
CaseStatement currentCase = casesIter.next();
Expression guard = currentCase.getGuard();
Statements body = currentCase.getBody();
Iterator<GoalNode> goalIter = copiedList.iterator();
Set<GoalNode> forCase = new HashSet<>();
//iterate over all available goals and select those that evaluate to true with the guard
//assumption, matchpattern handles varAssignments
while (goalIter.hasNext()) {
GoalNode g = goalIter.next();
Value eval = evaluate(g, guard);
if (eval.getData().equals(true)) {
forCase.add(g);
}
}
copiedList.removeAll(forCase);
goalsAfterCases.addAll(executeCase(body, forCase));
}
*/
//for all remaining goals execute default
if
(!
copiedList
.
isEmpty
())
{
if
(!
remainingGoalsSet
.
isEmpty
())
{
VariableAssignment
va
=
new
VariableAssignment
();
Statements
defaultCase
=
casesStatement
.
getDefaultCase
();
goalsAfterCases
.
addAll
(
executeCase
(
defaultCase
,
copiedList
));
for
(
GoalNode
goal
:
remainingGoalsSet
)
{
goalsAfterCases
.
addAll
(
executeBody
(
defaultCase
,
goal
,
va
).
getGoals
());
}
}
...
...
@@ -205,7 +182,7 @@ public class Interpreter extends DefaultASTVisitor<Void>
State
newStateAfterCases
;
if
(!
goalsAfterCases
.
isEmpty
())
{
goalsAfterCases
.
forEach
(
node
->
node
.
exitNewVarScope
());
//
goalsAfterCases.forEach(node -> node.exitNewVarScope());
if
(
goalsAfterCases
.
size
()
==
1
)
{
newStateAfterCases
=
new
State
(
goalsAfterCases
,
goalsAfterCases
.
get
(
0
));
...
...
@@ -226,7 +203,7 @@ public class Interpreter extends DefaultASTVisitor<Void>
* @param aCase
* @return
*/
private
Map
<
GoalNode
,
VariableAssignment
>
matchGoal
(
Set
<
GoalNode
>
allGoalsBeforeCases
,
CaseStatement
aCase
)
{
private
Map
<
GoalNode
,
VariableAssignment
>
matchGoal
(
Collection
<
GoalNode
>
allGoalsBeforeCases
,
CaseStatement
aCase
)
{
HashMap
<
GoalNode
,
VariableAssignment
>
matchedGoals
=
new
HashMap
<>();
Expression
matchExpression
=
aCase
.
getGuard
();
...
...
@@ -281,23 +258,18 @@ public class Interpreter extends DefaultASTVisitor<Void>
/**
* For each selected goal put a state onto the stack and visit the body of the case
*
* @param
* @param
* @param caseStmts
* @param goalsToApply @return
*/
private
List
<
GoalNode
>
executeCase
(
Statements
caseStmts
,
Set
<
GoalNode
>
goalsToApply
)
{
private
List
<
GoalNode
>
executeCase
(
Statements
caseStmts
,
Map
<
GoalNode
,
VariableAssignment
>
goalsToApply
)
{
enterScope
(
caseStmts
);
List
<
GoalNode
>
goalsAfterCases
=
new
ArrayList
<>();
for
(
GoalNode
next
:
goalsToApply
)
{
List
<
GoalNode
>
goalList
=
new
ArrayList
<>();
goalList
.
add
(
next
);
State
s
=
new
State
(
goalList
,
next
);
stateStack
.
push
(
s
);
caseStmts
.
accept
(
this
);
State
aftercase
=
(
State
)
stateStack
.
pop
();
goalsAfterCases
.
addAll
(
aftercase
.
getGoals
());
for
(
Map
.
Entry
<
GoalNode
,
VariableAssignment
>
next
:
goalsToApply
.
entrySet
())
{
AbstractState
s
=
executeBody
(
caseStmts
,
next
.
getKey
(),
next
.
getValue
());
goalsAfterCases
.
addAll
(
s
.
getGoals
());
}
exitScope
(
caseStmts
);
return
goalsAfterCases
;
...
...
@@ -305,6 +277,15 @@ public class Interpreter extends DefaultASTVisitor<Void>
}
private
AbstractState
executeBody
(
Statements
caseStmts
,
GoalNode
goalNode
,
VariableAssignment
va
)
{
goalNode
.
enterNewVarScope
(
va
);
AbstractState
s
=
newState
(
goalNode
);
caseStmts
.
accept
(
this
);
popState
(
s
);
return
s
;
}
/**
* @param caseStatement
* @return
...
...
src/main/java/edu/kit/formal/interpreter/Main.java
View file @
feec8b4b
package
edu.kit.formal.interpreter
;
import
de.uka.ilkd.key.api.*
;
import
de.uka.ilkd.key.macros.scripts.RuleCommand
;
import
de.uka.ilkd.key.proof.io.ProblemLoaderException
;
import
de.uka.ilkd.key.api.ProofManagementApi
;
import
edu.kit.formal.interpreter.funchdl.BuiltinCommands
;
import
edu.kit.formal.interpreter.funchdl.DefaultLookup
;
import
edu.kit.formal.proofscriptparser.Facade
;
...
...
@@ -10,9 +8,7 @@ import edu.kit.formal.proofscriptparser.ast.ProofScript;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* Test Main, will be replaced
...
...
@@ -24,13 +20,15 @@ public class Main {
private
static
File
testFile1
=
new
File
(
"/home/sarah/Documents/KIT_Mitarbeiter/ProofScriptingLanguage/src/test/resources/edu/kit/formal/proofscriptparser/scripts/contraposition.key"
);
public
static
void
main
(
String
[]
args
)
{
try
{
/*
try {
System.out.println(testFile1.exists());
api = KeYApi.loadFromKeyFile(testFile1);
ProofApi papi = api.getLoadedProof();
ScriptApi scrapi = papi.getScriptApi();
System
.
out
.
println
(
papi
.
getFirstOpenGoal
().
getSequent
().
toString
());
*/
/*System.out.println(papi.getFirstOpenGoal().getSequent().toString());
ProjectedNode openGoal = papi.getFirstOpenGoal();
RuleCommand rc = (RuleCommand) KeYApi.getScriptCommandApi().getScriptCommands("rule");
Map cArgs = new HashMap();
...
...
@@ -51,13 +49,13 @@ public class Main {
} else {
List<VariableAssignments> matches2 = scrapi.matchPattern("==> X -> Y", openGoal.getSequent(), va2);
}
}
catch
(
ProblemLoaderException
e
)
{
}
*/
/*
} catch (ProblemLoaderException e) {
System.out.println("Could not load file");
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
*/
//Erzeuge Parser
//lese P ein
//Erzeuge Interpreter
...
...
src/main/java/edu/kit/formal/interpreter/MatchEvaluator.java
View file @
feec8b4b
...
...
@@ -7,6 +7,7 @@ import edu.kit.formal.proofscriptparser.ast.*;
import
lombok.Getter
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
...
...
@@ -68,16 +69,43 @@ public class MatchEvaluator extends DefaultASTVisitor<List<VariableAssignment>>
return
evaluatedExpression
;
}
/**
* TODO rethink
*
* @param op
* @param v1
* @param v2
* @return
*/
private
List
<
VariableAssignment
>
evaluateExpression
(
Operator
op
,
List
<
VariableAssignment
>
v1
,
List
<
VariableAssignment
>
v2
)
{
switch
(
op
)
{
case
AND:
return
joinLists
(
v1
,
v2
);
case
OR:
return
orList
(
v1
,
v2
);
case
EQ:
return
joinLists
(
v1
,
v2
);
case
NEQ:
return
null
;
default
:
System
.
out
.
println
(
"Need to be i
nstall
ed"
);
System
.
out
.
println
(
"Need to be i
mplement
ed"
);
}
return
null
;
}
/**
* TODO rethink decision: atm. if the first list is true/not empty (but may contain amepty assignment) this is returned
* This decision also results that if a binary expression without a match is printed first, it is the winning assignment
* Importance of match is decreased with this decision
*
* @param v1
* @param v2
* @return
*/
private
List
<
VariableAssignment
>
orList
(
List
<
VariableAssignment
>
v1
,
List
<
VariableAssignment
>
v2
)
{
return
(
v1
.
isEmpty
())
?
v2
:
v1
;
}
/**
* If two matching results are conjunctively joined only variable assignments that are compatible with each other can be chosen.
*
...
...
@@ -121,30 +149,18 @@ public class MatchEvaluator extends DefaultASTVisitor<List<VariableAssignment>>
public
List
<
VariableAssignment
>
visit
(
MatchExpression
match
)
{
List
<
VariableAssignments
>
resultOfMatch
;
//TODO transform assignments
Value
pattern
=
(
Value
)
match
.
getPattern
().
accept
(
this
);
Value
pattern
=
(
Value
)
eval
.
eval
(
match
.
getPattern
());
// Value pattern = (Value) match.getPattern().accept(this);
List
<
VariableAssignment
>
va
=
null
;
if
(
pattern
.
getType
()
==
Type
.
STRING
)
{
va
=
getMatcher
().
matchLabel
(
goal
,
(
String
)
pattern
.
getData
());
}
else
if
(
pattern
.
getType
()
==
Type
.
TERM
)
{
va
=
getMatcher
().
matchSeq
(
goal
,
(
String
)
pattern
.
getData
());
va
=
getMatcher
().
matchSeq
(
goal
,
(
String
)
pattern
.
getData
()
,
match
.
getSignature
()
);
}
return
va
!=
null
?
va
:
new
Arra
yList
<>
();
return
va
!=
null
?
va
:
Collections
.
empt
yList
();
}
/**
* @param
* @return
*/
/* @Override
public List<VariableAssignment> visit(TermLiteral term) {
return null;
}*/
/* @Override
public List<VariableAssignment> visit(StringLiteral string) {
return Value.from(string);
}*/
@Override
public
List
<
VariableAssignment
>
visit
(
Variable
variable
)
{
//get variable value
...
...
@@ -159,17 +175,7 @@ public class MatchEvaluator extends DefaultASTVisitor<List<VariableAssignment>>
}
/* @Override
public List<VariableAssignment> visit(BooleanLiteral bool) {
return bool.isValue() ? Value.TRUE : Value.FALSE;
}
@Override
public List<VariableAssignment> visit(IntegerLiteral integer) {
return Value.from(integer);
}
*/
@Override
public
List
<
VariableAssignment
>
visit
(
UnaryExpression
e
)
{
Operator
op
=
e
.
getOperator
();
...
...
src/main/java/edu/kit/formal/interpreter/MatcherApi.java
View file @
feec8b4b
package
edu.kit.formal.interpreter
;
import
edu.kit.formal.proofscriptparser.ast.Signature
;
import
java.util.List
;
/**
...
...
@@ -8,5 +10,6 @@ import java.util.List;
*/
public
interface
MatcherApi
{
List
<
VariableAssignment
>
matchLabel
(
GoalNode
currentState
,
String
label
);
List
<
VariableAssignment
>
matchSeq
(
GoalNode
currentState
,
String
data
);
List
<
VariableAssignment
>
matchSeq
(
GoalNode
currentState
,
String
data
,
Signature
sig
);
}
src/main/java/edu/kit/formal/interpreter/Value.java
View file @
feec8b4b
package
edu.kit.formal.interpreter
;
import
edu.kit.formal.proofscriptparser.ast.BooleanLiteral
;
import
edu.kit.formal.proofscriptparser.ast.IntegerLiteral
;
import
edu.kit.formal.proofscriptparser.ast.StringLiteral
;
import
edu.kit.formal.proofscriptparser.ast.Type
;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
...
...
@@ -51,6 +48,14 @@ public class Value<T> {
return
new
Value
<>(
Type
.
INT
,
apply
);
}
public
static
Value
<
String
>
from
(
String
s
)
{
return
new
Value
<>(
Type
.
STRING
,
s
);
}
public
static
Value
<
String
>
from
(
TermLiteral
term
)
{
return
new
Value
<>(
Type
.
TERM
,
term
.
getText
());
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
...
...
@@ -73,8 +78,4 @@ public class Value<T> {
public
String
toString
()
{
return
data
+
":"
+
type
;
}
public
static
Value
<
String
>
from
(
String
s
)
{
return
new
Value
<>(
Type
.
STRING
,
s
);
}
}
src/main/java/edu/kit/formal/interpreter/VariableAssignment.java
View file @
feec8b4b
...
...
@@ -184,6 +184,7 @@ public class VariableAssignment {
VariableAssignment
nva
=
push
();
nva
.
types
.
putAll
(
va
.
types
);
nva
.
values
.
putAll
(
va
.
values
);
return
nva
;
}
}
src/main/java/edu/kit/formal/proofscriptparser/ast/TermLiteral.java
View file @
feec8b4b
...
...
@@ -39,6 +39,8 @@ public class TermLiteral extends Literal {
public
TermLiteral
(
String
text
)
{
if
(
text
.
charAt
(
0
)
==
'`'
)
text
=
text
.
substring
(
1
);
if
(
text
.
charAt
(
text
.
length
()
-
1
)
==
'`'
)
//remove last backtick
text
=
text
.
substring
(
0
,
text
.
length
()
-
1
);
if
(
text
.
charAt
(
0
)
==
'`'
)
text
=
text
.
substring
(
0
,
text
.
length
()
-
2
);
this
.
text
=
text
;
...
...
src/test/java/edu/kit/formal/interpreter/InterpreterTest.java
View file @
feec8b4b
...
...
@@ -29,7 +29,9 @@ public class InterpreterTest {
Interpreter
i
=
new
Interpreter
(
createTestLookup
(
scripts
));
i
.
setMatcherApi
(
new
Debugger
.
PseudoMatcher
());
//i.getEntryListeners().add(new ScopeLogger("scope:"));
i
.
interpret
(
scripts
,
"abc"
);
return
i
;
}
...
...
@@ -118,4 +120,6 @@ public class InterpreterTest {
return
null
;
}
}
}
src/test/java/edu/kit/formal/interpreter/MatchEvaluatorTest.java
View file @
feec8b4b
package
edu.kit.formal.interpreter
;
import
edu.kit.formal.dbg.Debugger
;
import
edu.kit.formal.proofscriptparser.ast.Type
;
import
org.junit.Before
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* Created by sarah on 5/23/17.
*/
...
...
@@ -31,25 +27,8 @@ public class MatchEvaluatorTest {
va
.
setVarValue
(
"a"
,
Value
.
from
(
1
));
va
.
setVarValue
(
"b"
,
Value
.
from
(
1
));
GoalNode
selected
=
new
GoalNode
(
parent
,
"selg"
);
mEval
=
new
MatchEvaluator
(
va
,
selected
,
new
PseudoMatcher
());
//eval = new Evaluator(selected.getAssignments(), selected);
//eval.setMatcher(new PseudoMatcher());
}
mEval
=
new
MatchEvaluator
(
va
,
selected
,
new
Debugger
.
PseudoMatcher
());
static
class
PseudoMatcher
implements
MatcherApi
{
@Override
public
List
<
VariableAssignment
>
matchLabel
(
GoalNode
currentState
,
String
label
)
{
Pattern
p
=
Pattern
.
compile
(
label
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
m
=
p
.
matcher
(
currentState
.
getSequent
());
return
m
.
matches
()
?
Collections
.
singletonList
(
new
VariableAssignment
())
:
Collections
.
emptyList
();
}
@Override
public
List
<
VariableAssignment
>
matchSeq
(
GoalNode
currentState
,
String
data
)
{
return
Collections
.
emptyList
();
}
}
}
src/test/resources/edu/kit/formal/interpreter/simple1.txt
View file @
feec8b4b
...
...
@@ -10,15 +10,18 @@ script Simple1(i:int, j:int) {
assertEq i 4;
assert (i=4) & j=8;
split;
print_state;
foreach {
assert (i=4) & j=8;
split 5;
print_state;
}
print_state;
cases {
case match '.*a' {
case match `(?<X>.*).b.a` using [X : string] {
assertEq X 'abc' msg='bla bla';
print_state;
}
...
...
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