Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
ProofScriptParser
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
24
Issues
24
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sarah.grebing
ProofScriptParser
Commits
11f21a84
Commit
11f21a84
authored
Jul 18, 2017
by
Sarah Grebing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parser-Erweiterung closable and derivable
parent
f6054373
Pipeline
#12191
failed with stage
in 1 minute and 38 seconds
Changes
17
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
240 additions
and
39 deletions
+240
-39
src/main/antlr4/edu/kit/formal/proofscriptparser/ScriptLanguage.g4
...antlr4/edu/kit/formal/proofscriptparser/ScriptLanguage.g4
+17
-6
src/main/java/edu/kit/formal/gui/controls/WelcomePane.java
src/main/java/edu/kit/formal/gui/controls/WelcomePane.java
+1
-1
src/main/java/edu/kit/formal/interpreter/Evaluator.java
src/main/java/edu/kit/formal/interpreter/Evaluator.java
+10
-8
src/main/java/edu/kit/formal/interpreter/Interpreter.java
src/main/java/edu/kit/formal/interpreter/Interpreter.java
+12
-7
src/main/java/edu/kit/formal/interpreter/MatcherApi.java
src/main/java/edu/kit/formal/interpreter/MatcherApi.java
+1
-0
src/main/java/edu/kit/formal/interpreter/dbg/Debugger.java
src/main/java/edu/kit/formal/interpreter/dbg/Debugger.java
+1
-1
src/main/java/edu/kit/formal/proofscriptparser/ASTChanger.java
...ain/java/edu/kit/formal/proofscriptparser/ASTChanger.java
+17
-2
src/main/java/edu/kit/formal/proofscriptparser/ASTTraversal.java
...n/java/edu/kit/formal/proofscriptparser/ASTTraversal.java
+15
-2
src/main/java/edu/kit/formal/proofscriptparser/DefaultASTVisitor.java
...a/edu/kit/formal/proofscriptparser/DefaultASTVisitor.java
+10
-0
src/main/java/edu/kit/formal/proofscriptparser/PrettyPrinter.java
.../java/edu/kit/formal/proofscriptparser/PrettyPrinter.java
+2
-4
src/main/java/edu/kit/formal/proofscriptparser/TransformAst.java
...n/java/edu/kit/formal/proofscriptparser/TransformAst.java
+45
-4
src/main/java/edu/kit/formal/proofscriptparser/Visitor.java
src/main/java/edu/kit/formal/proofscriptparser/Visitor.java
+6
-1
src/main/java/edu/kit/formal/proofscriptparser/ast/CaseStatement.java
...a/edu/kit/formal/proofscriptparser/ast/CaseStatement.java
+3
-3
src/main/java/edu/kit/formal/proofscriptparser/ast/IsClosableCase.java
.../edu/kit/formal/proofscriptparser/ast/IsClosableCase.java
+34
-0
src/main/java/edu/kit/formal/proofscriptparser/ast/MatchExpression.java
...edu/kit/formal/proofscriptparser/ast/MatchExpression.java
+8
-0
src/main/java/edu/kit/formal/proofscriptparser/ast/SimpleCaseStatement.java
...kit/formal/proofscriptparser/ast/SimpleCaseStatement.java
+40
-0
src/test/resources/edu/kit/formal/interpreter/contraposition/isClosable.kps
.../edu/kit/formal/interpreter/contraposition/isClosable.kps
+18
-0
No files found.
src/main/antlr4/edu/kit/formal/proofscriptparser/ScriptLanguage.g4
View file @
11f21a84
...
@@ -76,8 +76,11 @@ literals :
...
@@ -76,8 +76,11 @@ literals :
</pre>*/
</pre>*/
matchPattern
matchPattern
: MATCH (pattern=expression
:
(USING LBRACKET argList RBRACKET)?) | DERIVABLE TERM_LITERAL | IFCLOSED
MATCH (
derivable=DERIVABLE derivableExpression=expression
| (pattern=expression (USING LBRACKET argList RBRACKET)?)
)
;
;
scriptVar
scriptVar
...
@@ -98,9 +101,17 @@ casesStmt
...
@@ -98,9 +101,17 @@ casesStmt
;
;
casesList
casesList
: CASE expression COLON? INDENT stmtList DEDENT
// : simpleCase
// | closableCase
: CASE (MATCH ISCLOSED | expression) COLON? INDENT stmtList DEDENT
;
;
/*simpleCase
: CASE expression COLON? INDENT stmtList DEDENT
;
closableCase
: CASE MATCH ISCLOSED COLON? INDENT stmtList DEDENT
;
*/
forEachStmt
forEachStmt
: FOREACH INDENT stmtList DEDENT
: FOREACH INDENT stmtList DEDENT
;
;
...
@@ -131,6 +142,8 @@ MULTI_LINE_COMMENT : '/*' (MULTI_LINE_COMMENT|.)*? '*/' -> channel(HIDDEN);
...
@@ -131,6 +142,8 @@ MULTI_LINE_COMMENT : '/*' (MULTI_LINE_COMMENT|.)*? '*/' -> channel(HIDDEN);
CASES: 'cases';
CASES: 'cases';
CASE: 'case';
CASE: 'case';
ISCLOSED: 'isCloseable';
DERIVABLE : 'derivable';
DEFAULT: 'default';
DEFAULT: 'default';
ASSIGN : ':=';
ASSIGN : ':=';
LBRACKET: '[';
LBRACKET: '[';
...
@@ -147,8 +160,6 @@ BOOL: 'bool' ;
...
@@ -147,8 +160,6 @@ BOOL: 'bool' ;
TERMTYPE : 'term' ;*/
TERMTYPE : 'term' ;*/
FOREACH : 'foreach' ;
FOREACH : 'foreach' ;
THEONLY : 'theonly' ;
THEONLY : 'theonly' ;
ISCLOSED: 'isClosable';
DERIVABLE : 'derivable';
INDENT : '{' ;
INDENT : '{' ;
DEDENT : '}' ;
DEDENT : '}' ;
SEMICOLON : ';' ;
SEMICOLON : ';' ;
...
...
src/main/java/edu/kit/formal/gui/controls/WelcomePane.java
View file @
11f21a84
...
@@ -21,7 +21,7 @@ public class WelcomePane extends AnchorPane {
...
@@ -21,7 +21,7 @@ public class WelcomePane extends AnchorPane {
proofScriptDebugger
.
getWelcomePaneDock
().
close
();
proofScriptDebugger
.
getWelcomePaneDock
().
close
();
proofScriptDebugger
.
showActiveInspector
(
null
);
proofScriptDebugger
.
showActiveInspector
(
null
);
proofScriptDebugger
.
openScript
(
proofScriptDebugger
.
openScript
(
new
File
(
"src/test/resources/edu/kit/formal/interpreter/contraposition/w
o
_branching.kps"
)
new
File
(
"src/test/resources/edu/kit/formal/interpreter/contraposition/w_branching.kps"
)
);
);
proofScriptDebugger
.
openKeyFile
(
proofScriptDebugger
.
openKeyFile
(
...
...
src/main/java/edu/kit/formal/interpreter/Evaluator.java
View file @
11f21a84
...
@@ -54,7 +54,7 @@ public class Evaluator<T> extends DefaultASTVisitor<Value> implements ScopeObser
...
@@ -54,7 +54,7 @@ public class Evaluator<T> extends DefaultASTVisitor<Value> implements ScopeObser
}
}
/**
/**
*
TODO Connect with KeY
*
Visit a match expression and evaluate expression using matcher
*
*
* @param match
* @param match
* @return
* @return
...
@@ -64,16 +64,18 @@ public class Evaluator<T> extends DefaultASTVisitor<Value> implements ScopeObser
...
@@ -64,16 +64,18 @@ public class Evaluator<T> extends DefaultASTVisitor<Value> implements ScopeObser
if
(
match
.
getSignature
()
!=
null
&&
!
match
.
getSignature
().
isEmpty
())
{
if
(
match
.
getSignature
()
!=
null
&&
!
match
.
getSignature
().
isEmpty
())
{
throw
new
IllegalStateException
(
"not supported"
);
throw
new
IllegalStateException
(
"not supported"
);
}
}
Value
pattern
=
(
Value
)
match
.
getPattern
().
accept
(
this
);
List
<
VariableAssignment
>
va
=
null
;
List
<
VariableAssignment
>
va
=
null
;
if
(
pattern
.
getType
()
==
Type
.
STRING
)
{
Value
pattern
=
(
Value
)
match
.
getPattern
().
accept
(
this
);
va
=
matcher
.
matchLabel
(
goal
,
(
String
)
pattern
.
getData
());
if
(
match
.
isDerivable
())
{
}
else
if
(
pattern
.
getType
()
==
Type
.
TERM
)
{
}
else
{
va
=
matcher
.
matchSeq
(
goal
,
(
String
)
pattern
.
getData
(),
match
.
getSignature
());
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
(),
match
.
getSignature
());
}
}
}
return
va
!=
null
&&
va
.
size
()
>
0
?
Value
.
TRUE
:
Value
.
FALSE
;
return
va
!=
null
&&
va
.
size
()
>
0
?
Value
.
TRUE
:
Value
.
FALSE
;
}
}
...
...
src/main/java/edu/kit/formal/interpreter/Interpreter.java
View file @
11f21a84
...
@@ -168,15 +168,19 @@ public class Interpreter<T> extends DefaultASTVisitor<Void>
...
@@ -168,15 +168,19 @@ public class Interpreter<T> extends DefaultASTVisitor<Void>
List
<
GoalNode
<
T
>>
goalsAfterCases
=
new
ArrayList
<>();
List
<
GoalNode
<
T
>>
goalsAfterCases
=
new
ArrayList
<>();
//copy the list of goal nodes for keeping track of goals
//copy the list of goal nodes for keeping track of goals
Set
<
GoalNode
<
T
>>
remainingGoalsSet
=
new
HashSet
<>(
allGoalsBeforeCases
);
Set
<
GoalNode
<
T
>>
remainingGoalsSet
=
new
HashSet
<>(
allGoalsBeforeCases
);
//TODO
//handle cases
//handle cases
List
<
CaseStatement
>
cases
=
casesStatement
.
getCases
();
List
<
CaseStatement
>
cases
=
casesStatement
.
getCases
();
for
(
CaseStatement
aCase
:
cases
)
{
for
(
CaseStatement
aCase
:
cases
)
{
Map
<
GoalNode
<
T
>,
VariableAssignment
>
matchedGoals
=
if
(
aCase
.
isClosedStmt
)
{
matchGoal
(
remainingGoalsSet
,
aCase
);
System
.
out
.
println
(
"IsClosableStmt not implemented yet"
);
if
(
matchedGoals
!=
null
)
{
}
else
{
remainingGoalsSet
.
removeAll
(
matchedGoals
.
keySet
());
Map
<
GoalNode
<
T
>,
VariableAssignment
>
matchedGoals
=
goalsAfterCases
.
addAll
(
executeCase
(
aCase
.
getBody
(),
matchedGoals
));
matchGoal
(
remainingGoalsSet
,
(
SimpleCaseStatement
)
aCase
);
if
(
matchedGoals
!=
null
)
{
remainingGoalsSet
.
removeAll
(
matchedGoals
.
keySet
());
goalsAfterCases
.
addAll
(
executeCase
(
aCase
.
getBody
(),
matchedGoals
));
}
}
}
}
}
...
@@ -219,11 +223,12 @@ public class Interpreter<T> extends DefaultASTVisitor<Void>
...
@@ -219,11 +223,12 @@ public class Interpreter<T> extends DefaultASTVisitor<Void>
* @param aCase
* @param aCase
* @return
* @return
*/
*/
private
Map
<
GoalNode
<
T
>,
VariableAssignment
>
matchGoal
(
Set
<
GoalNode
<
T
>>
allGoalsBeforeCases
,
CaseStatement
aCase
)
{
private
Map
<
GoalNode
<
T
>,
VariableAssignment
>
matchGoal
(
Set
<
GoalNode
<
T
>>
allGoalsBeforeCases
,
Simple
CaseStatement
aCase
)
{
HashMap
<
GoalNode
<
T
>,
VariableAssignment
>
matchedGoals
=
new
HashMap
<>();
HashMap
<
GoalNode
<
T
>,
VariableAssignment
>
matchedGoals
=
new
HashMap
<>();
Expression
matchExpression
=
aCase
.
getGuard
();
Expression
matchExpression
=
aCase
.
getGuard
();
for
(
GoalNode
<
T
>
goal
:
allGoalsBeforeCases
)
{
for
(
GoalNode
<
T
>
goal
:
allGoalsBeforeCases
)
{
VariableAssignment
va
=
evaluateMatchInGoal
(
matchExpression
,
goal
);
VariableAssignment
va
=
evaluateMatchInGoal
(
matchExpression
,
goal
);
if
(
va
!=
null
)
{
if
(
va
!=
null
)
{
...
...
src/main/java/edu/kit/formal/interpreter/MatcherApi.java
View file @
11f21a84
...
@@ -13,4 +13,5 @@ import java.util.List;
...
@@ -13,4 +13,5 @@ import java.util.List;
public
interface
MatcherApi
<
T
>
{
public
interface
MatcherApi
<
T
>
{
List
<
VariableAssignment
>
matchLabel
(
GoalNode
<
T
>
currentState
,
String
label
);
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
,
Signature
sig
);
}
}
src/main/java/edu/kit/formal/interpreter/dbg/Debugger.java
View file @
11f21a84
...
@@ -221,7 +221,7 @@ public class Debugger {
...
@@ -221,7 +221,7 @@ public class Debugger {
}
}
@Override
@Override
public
Void
visit
(
CaseStatement
caseStatement
)
{
public
Void
visit
(
Simple
CaseStatement
caseStatement
)
{
suffix
(
caseStatement
);
suffix
(
caseStatement
);
System
.
out
.
println
(
"case "
+
Facade
.
prettyPrint
(
caseStatement
.
getGuard
()));
System
.
out
.
println
(
"case "
+
Facade
.
prettyPrint
(
caseStatement
.
getGuard
()));
return
super
.
visit
(
caseStatement
);
return
super
.
visit
(
caseStatement
);
...
...
src/main/java/edu/kit/formal/proofscriptparser/ASTChanger.java
View file @
11f21a84
...
@@ -110,11 +110,26 @@ public class ASTChanger extends DefaultASTVisitor<ASTNode> {
...
@@ -110,11 +110,26 @@ public class ASTChanger extends DefaultASTVisitor<ASTNode> {
return
casesStatement
;
return
casesStatement
;
}
}
@Override
public
IsClosableCase
visit
(
IsClosableCase
isClosableCase
)
{
isClosableCase
.
getBody
().
accept
(
this
);
return
isClosableCase
;
}
@Override
public
SimpleCaseStatement
visit
(
SimpleCaseStatement
simpleCaseStatement
)
{
simpleCaseStatement
.
getGuard
().
accept
(
this
);
simpleCaseStatement
.
getBody
().
accept
(
this
);
return
simpleCaseStatement
;
}
@Override
@Override
public
CaseStatement
visit
(
CaseStatement
caseStatement
)
{
public
CaseStatement
visit
(
CaseStatement
caseStatement
)
{
caseStatement
.
getGuard
().
accept
(
this
);
//caseStatement.getGuard().accept(this);
caseStatement
.
getBody
().
accept
(
this
);
//caseStatement.getBody().accept(this);
caseStatement
.
accept
(
this
);
return
caseStatement
;
return
caseStatement
;
}
}
@Override
@Override
...
...
src/main/java/edu/kit/formal/proofscriptparser/ASTTraversal.java
View file @
11f21a84
...
@@ -104,8 +104,8 @@ public interface ASTTraversal<T> extends Visitor<T> {
...
@@ -104,8 +104,8 @@ public interface ASTTraversal<T> extends Visitor<T> {
@Override
@Override
default
T
visit
(
CaseStatement
caseStatement
)
{
default
T
visit
(
CaseStatement
caseStatement
)
{
caseStatement
.
getGuard
().
accept
(
this
);
//caseStatement.getBody
().accept(this);
caseStatement
.
getBody
().
accept
(
this
);
caseStatement
.
accept
(
this
);
return
null
;
return
null
;
}
}
...
@@ -158,4 +158,17 @@ public interface ASTTraversal<T> extends Visitor<T> {
...
@@ -158,4 +158,17 @@ public interface ASTTraversal<T> extends Visitor<T> {
e
.
getExpression
().
accept
(
this
);
e
.
getExpression
().
accept
(
this
);
return
null
;
return
null
;
}
}
@Override
default
T
visit
(
IsClosableCase
isClosableCase
)
{
isClosableCase
.
getBody
().
accept
(
this
);
return
null
;
}
@Override
default
T
visit
(
SimpleCaseStatement
simpleCaseStatement
)
{
simpleCaseStatement
.
getGuard
().
accept
(
this
);
simpleCaseStatement
.
getBody
().
accept
(
this
);
return
null
;
}
}
}
src/main/java/edu/kit/formal/proofscriptparser/DefaultASTVisitor.java
View file @
11f21a84
...
@@ -128,5 +128,15 @@ public class DefaultASTVisitor<T> implements Visitor<T> {
...
@@ -128,5 +128,15 @@ public class DefaultASTVisitor<T> implements Visitor<T> {
public
T
visit
(
UnaryExpression
unaryExpression
)
{
public
T
visit
(
UnaryExpression
unaryExpression
)
{
return
defaultVisit
(
unaryExpression
);
return
defaultVisit
(
unaryExpression
);
}
}
@Override
public
T
visit
(
IsClosableCase
isClosableCase
)
{
return
defaultVisit
(
isClosableCase
);
}
@Override
public
T
visit
(
SimpleCaseStatement
simpleCaseStatement
)
{
return
defaultVisit
(
simpleCaseStatement
);
}
}
}
src/main/java/edu/kit/formal/proofscriptparser/PrettyPrinter.java
View file @
11f21a84
...
@@ -38,15 +38,13 @@ import java.util.Map;
...
@@ -38,15 +38,13 @@ import java.util.Map;
*/
*/
public
class
PrettyPrinter
extends
DefaultASTVisitor
<
Void
>
{
public
class
PrettyPrinter
extends
DefaultASTVisitor
<
Void
>
{
private
final
StringBuilder
s
=
new
StringBuilder
();
@Getter
@Getter
@Setter
@Setter
private
int
maxWidth
=
80
;
private
int
maxWidth
=
80
;
@Getter
@Getter
@Setter
@Setter
private
boolean
unicode
=
true
;
private
boolean
unicode
=
true
;
private
final
StringBuilder
s
=
new
StringBuilder
();
private
int
indentation
=
0
;
private
int
indentation
=
0
;
@Override
@Override
...
@@ -168,7 +166,7 @@ public class PrettyPrinter extends DefaultASTVisitor<Void> {
...
@@ -168,7 +166,7 @@ public class PrettyPrinter extends DefaultASTVisitor<Void> {
}
}
@Override
@Override
public
Void
visit
(
CaseStatement
caseStatement
)
{
public
Void
visit
(
Simple
CaseStatement
caseStatement
)
{
s
.
append
(
"case "
);
s
.
append
(
"case "
);
caseStatement
.
getGuard
().
accept
(
this
);
caseStatement
.
getGuard
().
accept
(
this
);
s
.
append
(
" {"
);
s
.
append
(
" {"
);
...
...
src/main/java/edu/kit/formal/proofscriptparser/TransformAst.java
View file @
11f21a84
...
@@ -249,9 +249,16 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
...
@@ -249,9 +249,16 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
public
Object
visitMatchPattern
(
ScriptLanguageParser
.
MatchPatternContext
ctx
)
{
public
Object
visitMatchPattern
(
ScriptLanguageParser
.
MatchPatternContext
ctx
)
{
MatchExpression
match
=
new
MatchExpression
();
MatchExpression
match
=
new
MatchExpression
();
match
.
setRuleContext
(
ctx
);
match
.
setRuleContext
(
ctx
);
if
(
ctx
.
argList
()
!=
null
)
match
.
setSignature
((
Signature
)
ctx
.
argList
().
accept
(
this
));
if
(
ctx
.
derivable
!=
null
)
{
match
.
setPattern
((
Expression
)
ctx
.
pattern
.
accept
(
this
));
match
.
setDerivable
(
true
);
match
.
setDerivableTerm
((
Expression
)
ctx
.
derivableExpression
.
accept
(
this
));
}
else
{
if
(
ctx
.
argList
()
!=
null
)
match
.
setSignature
((
Signature
)
ctx
.
argList
().
accept
(
this
));
match
.
setPattern
((
Expression
)
ctx
.
pattern
.
accept
(
this
));
}
return
match
;
return
match
;
}
}
...
@@ -283,12 +290,46 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
...
@@ -283,12 +290,46 @@ public class TransformAst implements ScriptLanguageVisitor<Object> {
@Override
@Override
public
Object
visitCasesList
(
ScriptLanguageParser
.
CasesListContext
ctx
)
{
public
Object
visitCasesList
(
ScriptLanguageParser
.
CasesListContext
ctx
)
{
CaseStatement
caseStatement
=
new
CaseStatement
();
if
(
ctx
.
ISCLOSED
()
!=
null
)
{
IsClosableCase
isClosableCase
=
new
IsClosableCase
();
isClosableCase
.
setRuleContext
(
ctx
);
isClosableCase
.
setBody
((
Statements
)
ctx
.
stmtList
().
accept
(
this
));
return
isClosableCase
;
}
else
{
SimpleCaseStatement
caseStatement
=
new
SimpleCaseStatement
();
caseStatement
.
setRuleContext
(
ctx
);
caseStatement
.
setGuard
((
Expression
)
ctx
.
expression
().
accept
(
this
));
caseStatement
.
setBody
((
Statements
)
ctx
.
stmtList
().
accept
(
this
));
return
caseStatement
;
}
/* CaseStatement caseStatement = new CaseStatement();
caseStatement.setRuleContext(ctx);
caseStatement.setGuard((Expression) ctx.expression().accept(this));
caseStatement.setBody((Statements) ctx.stmtList().accept(this));
return caseStatement;*/
}
/*
@Override
public Object visitSimpleCase(ScriptLanguageParser.SimpleCaseContext ctx) {
SimpleCaseStatement caseStatement = new SimpleCaseStatement();
caseStatement.setRuleContext(ctx);
caseStatement.setRuleContext(ctx);
caseStatement.setGuard((Expression) ctx.expression().accept(this));
caseStatement.setGuard((Expression) ctx.expression().accept(this));
caseStatement.setBody((Statements) ctx.stmtList().accept(this));
caseStatement.setBody((Statements) ctx.stmtList().accept(this));
return caseStatement;
return caseStatement;
}
@Override
public Object visitClosableCase(ScriptLanguageParser.ClosableCaseContext ctx) {
IsClosableCase isClosableCase = new IsClosableCase();
isClosableCase.setRuleContext(ctx);
isClosableCase.setBody((Statements) ctx.stmtList().accept(this));
return isClosableCase;
}
}
*/
@Override
@Override
public
Object
visitForEachStmt
(
ScriptLanguageParser
.
ForEachStmtContext
ctx
)
{
public
Object
visitForEachStmt
(
ScriptLanguageParser
.
ForEachStmtContext
ctx
)
{
...
...
src/main/java/edu/kit/formal/proofscriptparser/Visitor.java
View file @
11f21a84
...
@@ -53,7 +53,7 @@ public interface Visitor<T> {
...
@@ -53,7 +53,7 @@ public interface Visitor<T> {
T
visit
(
CasesStatement
cases
);
T
visit
(
CasesStatement
cases
);
T
visit
(
CaseStatement
case_
);
//
T visit(CaseStatement case_);
T
visit
(
CallStatement
call
);
T
visit
(
CallStatement
call
);
...
@@ -70,4 +70,9 @@ public interface Visitor<T> {
...
@@ -70,4 +70,9 @@ public interface Visitor<T> {
T
visit
(
UnaryExpression
e
);
T
visit
(
UnaryExpression
e
);
T
visit
(
IsClosableCase
isClosableCase
);
T
visit
(
SimpleCaseStatement
simpleCaseStatement
);
T
visit
(
CaseStatement
caseStatement
);
}
}
src/main/java/edu/kit/formal/proofscriptparser/ast/CaseStatement.java
View file @
11f21a84
...
@@ -38,8 +38,8 @@ import lombok.NoArgsConstructor;
...
@@ -38,8 +38,8 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@NoArgsConstructor
@AllArgsConstructor
@AllArgsConstructor
public
class
CaseStatement
extends
Statement
<
ScriptLanguageParser
.
CasesListContext
>
{
public
class
CaseStatement
extends
Statement
<
ScriptLanguageParser
.
CasesListContext
>
{
p
rivate
Expression
guard
;
p
ublic
boolean
isClosedStmt
;
pr
ivate
Statements
body
;
pr
otected
Statements
body
;
/**
/**
* {@inheritDoc}
* {@inheritDoc}
...
@@ -52,6 +52,6 @@ public class CaseStatement extends Statement<ScriptLanguageParser.CasesListConte
...
@@ -52,6 +52,6 @@ public class CaseStatement extends Statement<ScriptLanguageParser.CasesListConte
* {@inheritDoc}
* {@inheritDoc}
*/
*/
@Override
public
CaseStatement
copy
()
{
@Override
public
CaseStatement
copy
()
{
return
new
CaseStatement
(
guard
.
copy
(),
body
.
copy
()
);
return
new
CaseStatement
(
body
.
copy
(),
isClosedStmt
);
}
}
}
}
src/main/java/edu/kit/formal/proofscriptparser/ast/IsClosableCase.java
0 → 100644
View file @
11f21a84
package
edu.kit.formal.proofscriptparser.ast
;
import
edu.kit.formal.proofscriptparser.Visitor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* Object representing a "match isClosable{ Commands}" block
*/
@Data
@NoArgsConstructor
public
class
IsClosableCase
extends
CaseStatement
{
private
boolean
isClosedStmt
=
true
;
public
IsClosableCase
(
Statements
body
)
{
this
.
body
=
body
;
}
/**
* {@inheritDoc}
*/
@Override
public
<
T
>
T
accept
(
Visitor
<
T
>
visitor
)
{
return
visitor
.
visit
(
this
);
}
/**
* {@inheritDoc}
*/
@Override
public
IsClosableCase
copy
()
{
return
new
IsClosableCase
(
body
.
copy
());
}
}
src/main/java/edu/kit/formal/proofscriptparser/ast/MatchExpression.java
View file @
11f21a84
...
@@ -27,6 +27,8 @@ import edu.kit.formal.proofscriptparser.NotWelldefinedException;
...
@@ -27,6 +27,8 @@ import edu.kit.formal.proofscriptparser.NotWelldefinedException;
import
edu.kit.formal.proofscriptparser.ScriptLanguageParser
;
import
edu.kit.formal.proofscriptparser.ScriptLanguageParser
;
import
edu.kit.formal.proofscriptparser.Visitor
;
import
edu.kit.formal.proofscriptparser.Visitor
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
/**
* A match expression contains an argument and a uses clause.
* A match expression contains an argument and a uses clause.
...
@@ -38,6 +40,12 @@ import lombok.Data;
...
@@ -38,6 +40,12 @@ import lombok.Data;
public
class
MatchExpression
extends
Expression
<
ScriptLanguageParser
.
MatchPatternContext
>
{
public
class
MatchExpression
extends
Expression
<
ScriptLanguageParser
.
MatchPatternContext
>
{
private
Signature
signature
=
new
Signature
();
private
Signature
signature
=
new
Signature
();
private
Expression
pattern
;
private
Expression
pattern
;
@Getter
@Setter
private
boolean
isDerivable
;
@Getter
@Setter
private
Expression
derivableTerm
;
/**
/**
* {@inheritDoc}
* {@inheritDoc}
...
...
src/main/java/edu/kit/formal/proofscriptparser/ast/SimpleCaseStatement.java
0 → 100644
View file @
11f21a84
package
edu.kit.formal.proofscriptparser.ast
;
import
edu.kit.formal.proofscriptparser.Visitor
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* Created by sarah on 7/17/17.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
SimpleCaseStatement
extends
CaseStatement
{
private
Expression
guard
;
private
boolean
isClosedStmt
=
false
;
public
SimpleCaseStatement
(
Expression
guard
,
Statements
body
)
{
this
.
guard
=
guard
;
this
.
body
=
body
;
}
/**
* {@inheritDoc}
*/
@Override
public
<
T
>
T
accept
(
Visitor
<
T
>
visitor
)
{
return
visitor
.
visit
(
this
);
}
/**
* {@inheritDoc}
*/
@Override
public
SimpleCaseStatement
copy
()
{
return
new
SimpleCaseStatement
(
guard
.
copy
(),
body
.
copy
());
}
}
src/test/resources/edu/kit/formal/interpreter/contraposition/isClosable.kps
0 → 100644
View file @
11f21a84
script test(){
impRight;
impRight;
cases{
case match isCloseable:{
notLeft;
notRight;
replace_known_left occ='2';
concrete_impl_1;
close;
}
default:{
auto;
}
}