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
5bd02453
Commit
5bd02453
authored
Nov 01, 2017
by
Alexander Weigl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing StateWrapper and Exception in handling calls
parent
9cbd801f
Pipeline
#15079
failed with stage
in 1 minute and 48 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
22 deletions
+78
-22
lang/src/main/java/edu/kit/iti/formal/psdbg/ShortCommandPrinter.java
...in/java/edu/kit/iti/formal/psdbg/ShortCommandPrinter.java
+5
-0
lang/src/main/java/edu/kit/iti/formal/psdbg/parser/ast/ASTNode.java
...ain/java/edu/kit/iti/formal/psdbg/parser/ast/ASTNode.java
+10
-0
rt/src/main/java/edu/kit/iti/formal/psdbg/interpreter/Interpreter.java
...ava/edu/kit/iti/formal/psdbg/interpreter/Interpreter.java
+5
-3
rt/src/main/java/edu/kit/iti/formal/psdbg/interpreter/dbg/Blocker.java
...ava/edu/kit/iti/formal/psdbg/interpreter/dbg/Blocker.java
+13
-0
rt/src/main/java/edu/kit/iti/formal/psdbg/interpreter/dbg/StateWrapper.java
...du/kit/iti/formal/psdbg/interpreter/dbg/StateWrapper.java
+23
-4
rt/src/main/java/edu/kit/iti/formal/psdbg/interpreter/dbg/StepOverCommand.java
...kit/iti/formal/psdbg/interpreter/dbg/StepOverCommand.java
+6
-3
ui/src/main/java/edu/kit/iti/formal/psdbg/gui/controls/ScriptController.java
...u/kit/iti/formal/psdbg/gui/controls/ScriptController.java
+16
-12
No files found.
lang/src/main/java/edu/kit/iti/formal/psdbg/ShortCommandPrinter.java
View file @
5bd02453
...
...
@@ -16,6 +16,11 @@ public class ShortCommandPrinter extends DefaultASTVisitor<String> {
return
(
Facade
.
prettyPrint
(
node
));
}
@Override
public
String
visit
(
Statements
statements
)
{
return
"{ ... "
+
statements
.
size
()
+
" ... }"
;
}
@Override
public
String
visit
(
ProofScript
proofScript
)
{
return
String
.
format
(
"script %s (%s) {%n"
,
...
...
lang/src/main/java/edu/kit/iti/formal/psdbg/parser/ast/ASTNode.java
View file @
5bd02453
...
...
@@ -129,4 +129,14 @@ public abstract class ASTNode<T extends ParserRuleContext>
public
boolean
eq
(
ASTNode
other
)
{
return
equals
(
other
);
}
public
int
getDepth
()
{
int
depth
=
0
;
ASTNode
n
=
this
;
do
{
n
=
n
.
getParent
();
depth
++;
}
while
(
n
!=
null
);
return
depth
;
}
}
rt/src/main/java/edu/kit/iti/formal/psdbg/interpreter/Interpreter.java
View file @
5bd02453
...
...
@@ -531,9 +531,11 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
//newErrorState.setErrorState(true);
//pushState(newErrorState);
}
g
.
exitScope
();
// System.out.println(stateStack.peek().hashCode());
exitScope
(
call
);
finally
{
g
.
exitScope
();
// System.out.println(stateStack.peek().hashCode());
exitScope
(
call
);
}
return
null
;
}
...
...
rt/src/main/java/edu/kit/iti/formal/psdbg/interpreter/dbg/Blocker.java
View file @
5bd02453
...
...
@@ -13,6 +13,7 @@ import java.util.HashSet;
import
java.util.Set
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.function.Predicate
;
import
java.util.function.Supplier
;
public
abstract
class
Blocker
{
public
interface
BlockPredicate
extends
Predicate
<
ASTNode
>
{
...
...
@@ -100,6 +101,18 @@ public abstract class Blocker {
}
}
@RequiredArgsConstructor
public
static
class
SmallerContext
implements
BlockPredicate
{
private
final
int
depth
;
private
final
Supplier
<
Integer
>
currenDepth
;
@Override
public
boolean
test
(
ASTNode
astNode
)
{
return
currenDepth
.
get
()
<=
depth
;
}
}
@RequiredArgsConstructor
public
static
class
ParentInContext
implements
BlockPredicate
{
...
...
rt/src/main/java/edu/kit/iti/formal/psdbg/interpreter/dbg/StateWrapper.java
View file @
5bd02453
package
edu.kit.iti.formal.psdbg.interpreter.dbg
;
import
edu.kit.iti.formal.psdbg.ShortCommandPrinter
;
import
edu.kit.iti.formal.psdbg.interpreter.Interpreter
;
import
edu.kit.iti.formal.psdbg.interpreter.data.State
;
import
edu.kit.iti.formal.psdbg.parser.DefaultASTVisitor
;
...
...
@@ -7,6 +8,7 @@ import edu.kit.iti.formal.psdbg.parser.Visitor;
import
edu.kit.iti.formal.psdbg.parser.ast.ASTNode
;
import
edu.kit.iti.formal.psdbg.parser.ast.ProofScript
;
import
edu.kit.iti.formal.psdbg.parser.ast.Statement
;
import
edu.kit.iti.formal.psdbg.parser.ast.Statements
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.apache.logging.log4j.LogManager
;
...
...
@@ -87,6 +89,11 @@ public class StateWrapper<T> implements InterpreterObserver<T> {
lastNode
.
setStateAfterStmt
(
getInterpreterStateCopy
());
if
(
node
.
equals
(
peekContext
()))
{
popContext
();
}
else
{
LOGGER
.
error
(
"Context mismatched, got {}, expected {}"
,
node
.
accept
(
new
ShortCommandPrinter
()),
peekContext
().
accept
(
new
ShortCommandPrinter
())
);
}
}
...
...
@@ -105,13 +112,19 @@ public class StateWrapper<T> implements InterpreterObserver<T> {
@Override
public
Void
defaultVisit
(
ASTNode
node
)
{
if
(
node
instanceof
Statement
)
createNormalNode
(
node
);
LOGGER
.
error
(
"enter {}"
,
node
.
accept
(
new
ShortCommandPrinter
()));
createNormalNode
(
node
);
return
null
;
}
@Override
public
Void
visit
(
Statements
statements
)
{
return
null
;
}
@Override
public
Void
visit
(
ProofScript
proofScript
)
{
LOGGER
.
error
(
"enter {}"
,
proofScript
.
accept
(
new
ShortCommandPrinter
()));
if
(
root
)
{
createRoot
(
proofScript
);
root
=
false
;
...
...
@@ -125,9 +138,15 @@ public class StateWrapper<T> implements InterpreterObserver<T> {
private
class
ExitListener
extends
DefaultASTVisitor
<
Void
>
{
@Override
public
Void
defaultVisit
(
ASTNode
node
)
{
if
(
node
instanceof
Statement
)
completeLastNode
(
node
);
LOGGER
.
error
(
"exit {}"
,
node
.
accept
(
new
ShortCommandPrinter
()));
completeLastNode
(
node
);
return
null
;
}
@Override
public
Void
visit
(
Statements
statements
)
{
return
null
;
}
}
}
rt/src/main/java/edu/kit/iti/formal/psdbg/interpreter/dbg/StepOverCommand.java
View file @
5bd02453
package
edu.kit.iti.formal.psdbg.interpreter.dbg
;
import
edu.kit.iti.formal.psdbg.parser.ast.ASTNode
;
import
edu.kit.iti.formal.psdbg.parser.ast.ProofScript
;
import
java.util.Arrays
;
import
java.util.function.Supplier
;
public
class
StepOverCommand
<
T
>
extends
DebuggerCommand
<
T
>
{
@Override
...
...
@@ -19,12 +19,15 @@ public class StepOverCommand<T> extends DebuggerCommand<T> {
ASTNode
[]
ctx
=
statePointer
.
getContext
();
//statePointer stands on the main script, we add the script itself to the context
if
(
statePointer
.
getContext
().
length
==
0
)
{
ctx
=
Arrays
.
copyOf
(
ctx
,
ctx
.
length
+
1
);
ctx
=
Arrays
.
copyOf
(
ctx
,
ctx
.
length
+
1
);
ctx
[
ctx
.
length
-
1
]
=
statePointer
.
getStatement
();
}
Supplier
<
Integer
>
currenDepth
=
()
->
dbg
.
getStatePointer
().
getContext
().
length
;
Blocker
.
BlockPredicate
predicate
=
new
Blocker
.
ParentInContext
(
ctx
);
//Blocker.BlockPredicate predicate = new Blocker.ParentInContext(ctx);
Blocker
.
SmallerContext
predicate
=
new
Blocker
.
SmallerContext
(
currenDepth
.
get
(),
currenDepth
);
dbg
.
releaseUntil
(
predicate
);
}
else
{
...
...
ui/src/main/java/edu/kit/iti/formal/psdbg/gui/controls/ScriptController.java
View file @
5bd02453
...
...
@@ -15,8 +15,6 @@ import javafx.beans.value.ChangeListener;
import
javafx.beans.value.ObservableValue
;
import
javafx.collections.FXCollections
;
import
javafx.collections.ObservableMap
;
import
javafx.geometry.Point2D
;
import
javafx.scene.Cursor
;
import
org.antlr.v4.runtime.CharStream
;
import
org.antlr.v4.runtime.CharStreams
;
import
org.apache.commons.io.FileUtils
;
...
...
@@ -81,8 +79,11 @@ public class ScriptController {
}
private
ScriptArea
findEditor
(
ASTNode
node
)
{
File
f
=
new
File
(
node
.
getOrigin
());
return
findEditor
(
f
);
if
(
node
.
getOrigin
()
!=
null
)
{
File
f
=
new
File
(
node
.
getOrigin
());
return
findEditor
(
f
);
}
return
null
;
}
/**
...
...
@@ -297,16 +298,19 @@ public class ScriptController {
logger
.
debug
(
"Region for highlighting: {}"
,
r
);
ScriptArea
area
=
findEditor
(
node
);
double
scrollY
=
area
.
getEstimatedScrollY
();
area
.
getMarkedRegions
().
add
(
r
);
if
(
area
!=
null
)
{
area
.
getMarkedRegions
().
add
(
r
);
getDockNode
(
area
).
focus
();
area
.
requestFocus
();
//area.scrollBy(new Point2D(0, scrollY));
area
.
selectRange
(
0
,
r
.
start
,
0
,
r
.
stop
);
getDockNode
(
area
).
focus
();
area
.
requestFocus
();
//area.scrollBy(new Point2D(0, scrollY));
area
.
selectRange
(
0
,
r
.
start
,
0
,
r
.
stop
);
lastScriptArea
=
area
;
lastRegion
=
r
;
lastScriptArea
=
area
;
lastRegion
=
r
;
}
else
{
logger
.
error
(
"Could not find editor for: "
+
node
.
getOrigin
());
}
}
public
void
remove
()
{
...
...
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