Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
sarah.grebing
ProofScriptParser
Commits
74bb5b37
Commit
74bb5b37
authored
May 19, 2017
by
Sarah Grebing
Browse files
fixed own introduced bug
parent
c6f8d090
Pipeline
#10613
passed with stage
in 1 minute and 59 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/edu/kit/formal/interpreter/Interpreter.java
View file @
74bb5b37
...
@@ -146,24 +146,30 @@ public class Interpreter<T> extends DefaultASTVisitor<T> {
...
@@ -146,24 +146,30 @@ public class Interpreter<T> extends DefaultASTVisitor<T> {
List
<
CaseStatement
>
cases
=
casesStatement
.
getCases
();
List
<
CaseStatement
>
cases
=
casesStatement
.
getCases
();
Iterator
<
CaseStatement
>
casesIter
=
cases
.
iterator
();
Iterator
<
CaseStatement
>
casesIter
=
cases
.
iterator
();
while
(
casesIter
.
hasNext
())
{
while
(
casesIter
.
hasNext
())
{
//get information for case
CaseStatement
currentCase
=
casesIter
.
next
();
CaseStatement
currentCase
=
casesIter
.
next
();
Expression
guard
=
currentCase
.
getGuard
();
Expression
guard
=
currentCase
.
getGuard
();
Statements
body
=
currentCase
.
getBody
();
Statements
body
=
currentCase
.
getBody
();
Iterator
<
GoalNode
>
goalIter
=
copiedList
.
iterator
();
Iterator
<
GoalNode
>
goalIter
=
copiedList
.
iterator
();
Set
<
GoalNode
>
forCase
=
new
HashSet
<>();
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
())
{
while
(
goalIter
.
hasNext
())
{
GoalNode
g
=
goalIter
.
next
();
GoalNode
g
=
goalIter
.
next
();
Evaluator
goalEval
=
new
Evaluator
(
g
);
Evaluator
goalEval
=
new
Evaluator
(
g
);
Value
eval
=
goalEval
.
eval
(
guard
);
Value
eval
=
goalEval
.
eval
(
guard
);
if
(
eval
.
getData
().
equals
(
Value
.
TRUE
))
{
System
.
out
.
println
();
if
(
eval
.
getData
().
equals
(
true
))
{
// if (eval.getData().equals(Value.TRUE)) {
forCase
.
add
(
g
);
forCase
.
add
(
g
);
//copiedList.remove(g);
}
}
}
}
copiedList
.
removeAll
(
forCase
);
copiedList
.
removeAll
(
forCase
);
//for each selected goal put a state onto tze stack and visit the body of the case
Iterator
<
GoalNode
>
caseGoals
=
forCase
.
iterator
();
Iterator
<
GoalNode
>
caseGoals
=
forCase
.
iterator
();
while
(
caseGoals
.
hasNext
())
{
while
(
caseGoals
.
hasNext
())
{
GoalNode
current
=
caseGoals
.
next
();
GoalNode
current
=
caseGoals
.
next
();
...
@@ -172,16 +178,19 @@ public class Interpreter<T> extends DefaultASTVisitor<T> {
...
@@ -172,16 +178,19 @@ public class Interpreter<T> extends DefaultASTVisitor<T> {
State
s
=
new
State
(
goalList
,
current
);
State
s
=
new
State
(
goalList
,
current
);
stateStack
.
push
(
s
);
stateStack
.
push
(
s
);
visit
(
body
);
visit
(
body
);
//after executing the body collect the newly created goals form the stack and remove the state
State
aftercase
=
(
State
)
stateStack
.
pop
();
State
aftercase
=
(
State
)
stateStack
.
pop
();
goalsAfterCases
.
addAll
(
aftercase
.
getGoals
());
goalsAfterCases
.
addAll
(
aftercase
.
getGoals
());
}
}
//jetzt body auswerten mit der Liste der Ziele
}
}
casesStatement
.
getDefaultCase
();
//for all remaining goals execute default
if
(!
copiedList
.
isEmpty
())
{
Statements
defaultCase
=
casesStatement
.
getDefaultCase
();
}
//exit scope
//exit scope
and create a new state using the union of all newly created goals
State
newStateAfterCases
;
State
newStateAfterCases
;
if
(!
goalsAfterCases
.
isEmpty
())
{
if
(!
goalsAfterCases
.
isEmpty
())
{
...
...
src/main/java/edu/kit/formal/interpreter/Value.java
View file @
74bb5b37
...
@@ -40,11 +40,11 @@ public class Value<T> {
...
@@ -40,11 +40,11 @@ public class Value<T> {
}
}
public
static
Value
<
Boolean
>
from
(
BooleanLiteral
b
)
{
public
static
Value
<
Boolean
>
from
(
BooleanLiteral
b
)
{
return
new
Value
(
Type
.
BOOL
,
(
b
.
isValue
()
?
Value
.
TRUE
:
Value
.
FALSE
)
);
return
new
Value
(
Type
.
BOOL
,
b
.
isValue
());
}
}
public
static
Value
<
Boolean
>
from
(
boolean
equals
)
{
public
static
Value
<
Boolean
>
from
(
boolean
equals
)
{
return
new
Value
(
Type
.
BOOL
,
(
equals
?
Value
.
TRUE
:
Value
.
FALSE
)
);
return
new
Value
(
Type
.
BOOL
,
equals
);
}
}
public
static
Value
<
BigInteger
>
from
(
BigInteger
apply
)
{
public
static
Value
<
BigInteger
>
from
(
BigInteger
apply
)
{
...
...
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