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
2b5b35ae
Commit
2b5b35ae
authored
Aug 15, 2017
by
Alexander Weigl
Browse files
Implemented Subst and rework on types
now Term<KeyType> ist possible!
parent
4efda617
Changes
42
Hide whitespace changes
Inline
Side-by-side
src/main/antlr4/edu/kit/formal/proofscriptparser/ScriptLanguage.g4
View file @
2b5b35ae
...
@@ -49,19 +49,19 @@ assignment
...
@@ -49,19 +49,19 @@ assignment
expression
expression
:
:
MINUS expression #exprNegate
expression MUL expression #exprMultiplication
| NOT expression #exprNot
| <assoc=right> expression DIV expression #exprDivision
| expression '[' substExpressionList ']' #exprSubst
| expression op=(PLUS|MINUS) expression #exprLineOperators
| expression MUL expression #exprMultiplication
| expression op=(LE|GE|LEQ|GEQ) expression #exprComparison
| <assoc=right> expression DIV expression #exprDivision
| expression op=(NEQ|EQ) expression #exprEquality
| expression op=(PLUS|MINUS) expression #exprLineOperators
| expression AND expression #exprAnd
| expression op=(LE|GE|LEQ|GEQ) expression #exprComparison
| expression OR expression #exprOr
| expression op=(NEQ|EQ) expression #exprEquality
| expression IMP expression #exprIMP
| expression AND expression #exprAnd
| expression OR expression #exprOr
| expression IMP expression #exprIMP
//| expression EQUIV expression already covered by EQ/NEQ
//| expression EQUIV expression already covered by EQ/NEQ
| '(' expression ')' #exprParen
| expression LBRACKET substExpressionList RBRACKET #exprSubst
| MINUS expression #exprNegate
| NOT expression #exprNot
| '(' expression ')' #exprParen
| literals #exprLiterals
| literals #exprLiterals
| matchPattern #exprMatch
| matchPattern #exprMatch
;
;
...
@@ -69,7 +69,9 @@ expression
...
@@ -69,7 +69,9 @@ expression
substExpressionList
substExpressionList
:
:
scriptVar '/' expression (',' substExpressionList)*
(scriptVar '/' expression
(',' scriptVar '/' expression)*
)?
;
;
literals :
literals :
...
@@ -205,4 +207,4 @@ EXE_MARKER: '\u2316' -> channel(HIDDEN);
...
@@ -205,4 +207,4 @@ EXE_MARKER: '\u2316' -> channel(HIDDEN);
DIGITS : DIGIT+ ;
DIGITS : DIGIT+ ;
fragment DIGIT : [0-9] ;
fragment DIGIT : [0-9] ;
ID : [a-zA-Z] ([_a-zA-Z0-9] | '.' | '\\'
| '[]' | '-'
)*
;
ID : [a-zA-Z] ([_a-zA-Z0-9] | '.' | '\\')*;
\ No newline at end of file
src/main/java/edu/kit/formal/interpreter/Evaluator.java
View file @
2b5b35ae
...
@@ -6,11 +6,16 @@ import edu.kit.formal.interpreter.data.VariableAssignment;
...
@@ -6,11 +6,16 @@ import edu.kit.formal.interpreter.data.VariableAssignment;
import
edu.kit.formal.proofscriptparser.DefaultASTVisitor
;
import
edu.kit.formal.proofscriptparser.DefaultASTVisitor
;
import
edu.kit.formal.proofscriptparser.Visitor
;
import
edu.kit.formal.proofscriptparser.Visitor
;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.types.SimpleType
;
import
edu.kit.formal.proofscriptparser.types.TermType
;
import
edu.kit.formal.proofscriptparser.types.TypeFacade
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
/**
* Class handling evaluation of expressions (visitor for expressions)
* Class handling evaluation of expressions (visitor for expressions)
...
@@ -68,9 +73,9 @@ public class Evaluator<T> extends DefaultASTVisitor<Value> implements ScopeObser
...
@@ -68,9 +73,9 @@ public class Evaluator<T> extends DefaultASTVisitor<Value> implements ScopeObser
Value
pattern
=
(
Value
)
match
.
getPattern
().
accept
(
this
);
Value
pattern
=
(
Value
)
match
.
getPattern
().
accept
(
this
);
if
(
match
.
isDerivable
())
{
if
(
match
.
isDerivable
())
{
}
else
{
}
else
{
if
(
pattern
.
getType
()
==
Type
.
STRING
)
{
if
(
pattern
.
getType
()
==
Simple
Type
.
STRING
)
{
va
=
matcher
.
matchLabel
(
goal
,
(
String
)
pattern
.
getData
());
va
=
matcher
.
matchLabel
(
goal
,
(
String
)
pattern
.
getData
());
}
else
if
(
pattern
.
getType
()
==
Type
.
TERM
)
{
}
else
if
(
TypeFacade
.
isTerm
(
pattern
.
getType
()
)
)
{
va
=
matcher
.
matchSeq
(
goal
,
(
String
)
pattern
.
getData
(),
match
.
getSignature
());
va
=
matcher
.
matchSeq
(
goal
,
(
String
)
pattern
.
getData
(),
match
.
getSignature
());
}
}
}
}
...
@@ -127,5 +132,29 @@ public class Evaluator<T> extends DefaultASTVisitor<Value> implements ScopeObser
...
@@ -127,5 +132,29 @@ public class Evaluator<T> extends DefaultASTVisitor<Value> implements ScopeObser
return
op
.
evaluate
(
exValue
);
return
op
.
evaluate
(
exValue
);
}
}
public
Value
visit
(
SubstituteExpression
expr
)
{
Value
term
=
(
Value
)
expr
.
getSub
().
accept
(
this
);
if
(
term
.
getType
()
instanceof
TermType
)
{
Pattern
pattern
=
Pattern
.
compile
(
"\\?[a-zA-Z_]+"
);
String
termstr
=
term
.
getData
().
toString
();
Matcher
m
=
pattern
.
matcher
(
termstr
);
StringBuffer
newTerm
=
new
StringBuffer
();
while
(
m
.
find
())
{
String
name
=
m
.
group
().
substring
(
1
);
// remove trailing '?'
Expression
t
=
expr
.
getSubstitution
().
get
(
m
.
group
());
//either evalute the substitent or find ?X in the
String
newVal
=
""
;
if
(
t
!=
null
)
newVal
=
((
Value
)
t
.
accept
(
this
)).
getData
().
toString
();
else
newVal
=
state
.
getValue
(
new
Variable
(
name
)).
getData
().
toString
();
m
.
appendReplacement
(
newTerm
,
newVal
);
}
m
.
appendTail
(
newTerm
);
return
new
Value
<>(
TypeFacade
.
ANY_TERM
,
newTerm
.
toString
());
}
else
{
throw
new
IllegalStateException
(
"Try to apply substitute on a non-term value."
);
}
}
}
}
src/main/java/edu/kit/formal/interpreter/Interpreter.java
View file @
2b5b35ae
...
@@ -14,6 +14,8 @@ import edu.kit.formal.interpreter.funchdl.CommandLookup;
...
@@ -14,6 +14,8 @@ import edu.kit.formal.interpreter.funchdl.CommandLookup;
import
edu.kit.formal.proofscriptparser.DefaultASTVisitor
;
import
edu.kit.formal.proofscriptparser.DefaultASTVisitor
;
import
edu.kit.formal.proofscriptparser.Visitor
;
import
edu.kit.formal.proofscriptparser.Visitor
;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.types.SimpleType
;
import
edu.kit.formal.proofscriptparser.types.Type
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
import
org.key_project.util.collection.ImmutableList
;
import
org.key_project.util.collection.ImmutableList
;
...
@@ -33,15 +35,15 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
...
@@ -33,15 +35,15 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
implements
ScopeObservable
{
implements
ScopeObservable
{
private
static
final
int
MAX_ITERATIONS
=
5
;
private
static
final
int
MAX_ITERATIONS
=
5
;
@Getter
@Getter
private
static
final
BiMap
<
Type
,
VariableAssignments
.
VarType
>
typeConversionBiMap
=
private
static
final
BiMap
<
Simple
Type
,
VariableAssignments
.
VarType
>
typeConversionBiMap
=
new
ImmutableBiMap
.
Builder
<
Type
,
VariableAssignments
.
VarType
>()
new
ImmutableBiMap
.
Builder
<
Simple
Type
,
VariableAssignments
.
VarType
>()
.
put
(
Type
.
ANY
,
VariableAssignments
.
VarType
.
ANY
)
.
put
(
Simple
Type
.
ANY
,
VariableAssignments
.
VarType
.
ANY
)
.
put
(
Type
.
BOOL
,
VariableAssignments
.
VarType
.
BOOL
)
.
put
(
Simple
Type
.
BOOL
,
VariableAssignments
.
VarType
.
BOOL
)
.
put
(
Type
.
TERM
,
VariableAssignments
.
VarType
.
FORMULA
)
//TODO: parametrisierte Terms
//
.put(
Simple
Type.TERM, VariableAssignments.VarType.FORMULA) //TODO: parametrisierte Terms
.
put
(
Type
.
INT
,
VariableAssignments
.
VarType
.
INT
)
.
put
(
Simple
Type
.
INT
,
VariableAssignments
.
VarType
.
INT
)
.
put
(
Type
.
STRING
,
VariableAssignments
.
VarType
.
OBJECT
)
.
put
(
Simple
Type
.
STRING
,
VariableAssignments
.
VarType
.
OBJECT
)
.
put
(
Type
.
INT_ARRAY
,
VariableAssignments
.
VarType
.
INT_ARRAY
)
.
put
(
Simple
Type
.
INT_ARRAY
,
VariableAssignments
.
VarType
.
INT_ARRAY
)
.
put
(
Type
.
SEQ
,
VariableAssignments
.
VarType
.
SEQ
)
.
put
(
Simple
Type
.
SEQ
,
VariableAssignments
.
VarType
.
SEQ
)
.
build
();
.
build
();
private
static
Logger
logger
=
Logger
.
getLogger
(
"interpreter"
);
private
static
Logger
logger
=
Logger
.
getLogger
(
"interpreter"
);
//TODO later also include information about source line for each state (for debugging purposes and rewind purposes)
//TODO later also include information about source line for each state (for debugging purposes and rewind purposes)
...
@@ -114,7 +116,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
...
@@ -114,7 +116,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
if
(
expr
!=
null
)
{
if
(
expr
!=
null
)
{
Type
type
=
node
.
getVariableType
(
var
);
Type
type
=
node
.
getVariableType
(
var
);
if
(
type
==
null
)
{
if
(
type
==
null
)
{
throw
new
RuntimeException
(
"Type of Variable "
+
var
+
" is not declared yet"
);
throw
new
RuntimeException
(
"
Simple
Type of Variable "
+
var
+
" is not declared yet"
);
}
else
{
}
else
{
Value
v
=
evaluate
(
expr
);
Value
v
=
evaluate
(
expr
);
node
.
setVariableValue
(
var
,
v
);
node
.
setVariableValue
(
var
,
v
);
...
...
src/main/java/edu/kit/formal/interpreter/KeYMatcher.java
View file @
2b5b35ae
...
@@ -18,8 +18,9 @@ import edu.kit.formal.interpreter.data.Value;
...
@@ -18,8 +18,9 @@ import edu.kit.formal.interpreter.data.Value;
import
edu.kit.formal.interpreter.data.VariableAssignment
;
import
edu.kit.formal.interpreter.data.VariableAssignment
;
import
edu.kit.formal.proofscriptparser.ast.Signature
;
import
edu.kit.formal.proofscriptparser.ast.Signature
;
import
edu.kit.formal.proofscriptparser.ast.TermLiteral
;
import
edu.kit.formal.proofscriptparser.ast.TermLiteral
;
import
edu.kit.formal.proofscriptparser.
ast.
Type
;
import
edu.kit.formal.proofscriptparser.
types.Simple
Type
;
import
edu.kit.formal.proofscriptparser.ast.Variable
;
import
edu.kit.formal.proofscriptparser.ast.Variable
;
import
edu.kit.formal.proofscriptparser.types.Type
;
import
org.key_project.util.collection.ImmutableList
;
import
org.key_project.util.collection.ImmutableList
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -114,7 +115,7 @@ public class KeYMatcher implements MatcherApi<KeyData> {
...
@@ -114,7 +115,7 @@ public class KeYMatcher implements MatcherApi<KeyData> {
if
(
branchLabelMatcher
.
matches
())
{
if
(
branchLabelMatcher
.
matches
())
{
VariableAssignment
va
=
new
VariableAssignment
(
null
);
VariableAssignment
va
=
new
VariableAssignment
(
null
);
va
.
declare
(
"$$branchLabel_"
,
Type
.
STRING
);
va
.
declare
(
"$$branchLabel_"
,
Simple
Type
.
STRING
);
va
.
assign
(
"$$branchLabel_"
,
Value
.
from
(
branchLabelMatcher
.
group
()));
va
.
assign
(
"$$branchLabel_"
,
Value
.
from
(
branchLabelMatcher
.
group
()));
assignments
.
add
(
va
);
assignments
.
add
(
va
);
resultsFromLabelMatch
.
add
(
branchLabelMatcher
.
toMatchResult
());
resultsFromLabelMatch
.
add
(
branchLabelMatcher
.
toMatchResult
());
...
@@ -124,7 +125,7 @@ public class KeYMatcher implements MatcherApi<KeyData> {
...
@@ -124,7 +125,7 @@ public class KeYMatcher implements MatcherApi<KeyData> {
Matcher
linesMatcher
=
regexpForLabel
.
matcher
(
controlFlowLines
);
Matcher
linesMatcher
=
regexpForLabel
.
matcher
(
controlFlowLines
);
if
(
linesMatcher
.
matches
())
{
if
(
linesMatcher
.
matches
())
{
VariableAssignment
va
=
new
VariableAssignment
(
null
);
VariableAssignment
va
=
new
VariableAssignment
(
null
);
va
.
declare
(
"$$CtrlLinesLabel_"
,
Type
.
STRING
);
va
.
declare
(
"$$CtrlLinesLabel_"
,
Simple
Type
.
STRING
);
va
.
assign
(
"$$CtrlLinesLabel_"
,
Value
.
from
(
linesMatcher
.
group
()));
va
.
assign
(
"$$CtrlLinesLabel_"
,
Value
.
from
(
linesMatcher
.
group
()));
assignments
.
add
(
va
);
assignments
.
add
(
va
);
resultsFromLabelMatch
.
add
(
linesMatcher
.
toMatchResult
());
resultsFromLabelMatch
.
add
(
linesMatcher
.
toMatchResult
());
...
@@ -134,7 +135,7 @@ public class KeYMatcher implements MatcherApi<KeyData> {
...
@@ -134,7 +135,7 @@ public class KeYMatcher implements MatcherApi<KeyData> {
Matcher
flowStmtsMatcher
=
regexpForLabel
.
matcher
(
controlFlowLines
);
Matcher
flowStmtsMatcher
=
regexpForLabel
.
matcher
(
controlFlowLines
);
if
(
flowStmtsMatcher
.
matches
())
{
if
(
flowStmtsMatcher
.
matches
())
{
VariableAssignment
va
=
new
VariableAssignment
(
null
);
VariableAssignment
va
=
new
VariableAssignment
(
null
);
va
.
declare
(
"$$FlowStmtsLabel_"
,
Type
.
STRING
);
va
.
declare
(
"$$FlowStmtsLabel_"
,
Simple
Type
.
STRING
);
va
.
assign
(
"$$FlowStmtsLabel_"
,
Value
.
from
(
flowStmtsMatcher
.
group
()));
va
.
assign
(
"$$FlowStmtsLabel_"
,
Value
.
from
(
flowStmtsMatcher
.
group
()));
assignments
.
add
(
va
);
assignments
.
add
(
va
);
resultsFromLabelMatch
.
add
(
flowStmtsMatcher
.
toMatchResult
());
resultsFromLabelMatch
.
add
(
flowStmtsMatcher
.
toMatchResult
());
...
@@ -144,7 +145,7 @@ public class KeYMatcher implements MatcherApi<KeyData> {
...
@@ -144,7 +145,7 @@ public class KeYMatcher implements MatcherApi<KeyData> {
Matcher
ruleMatcher
=
regexpForLabel
.
matcher
(
ruleLabel
);
Matcher
ruleMatcher
=
regexpForLabel
.
matcher
(
ruleLabel
);
if
(
ruleMatcher
.
matches
())
{
if
(
ruleMatcher
.
matches
())
{
VariableAssignment
va
=
new
VariableAssignment
(
null
);
VariableAssignment
va
=
new
VariableAssignment
(
null
);
va
.
declare
(
"$$RuleLabel_"
,
Type
.
STRING
);
va
.
declare
(
"$$RuleLabel_"
,
Simple
Type
.
STRING
);
va
.
assign
(
"$$RuleLabel_"
,
Value
.
from
(
ruleMatcher
.
group
()));
va
.
assign
(
"$$RuleLabel_"
,
Value
.
from
(
ruleMatcher
.
group
()));
assignments
.
add
(
va
);
assignments
.
add
(
va
);
resultsFromLabelMatch
.
add
(
ruleMatcher
.
toMatchResult
());
resultsFromLabelMatch
.
add
(
ruleMatcher
.
toMatchResult
());
...
...
src/main/java/edu/kit/formal/interpreter/MatchEvaluator.java
View file @
2b5b35ae
...
@@ -6,6 +6,8 @@ import edu.kit.formal.interpreter.data.VariableAssignment;
...
@@ -6,6 +6,8 @@ import edu.kit.formal.interpreter.data.VariableAssignment;
import
edu.kit.formal.proofscriptparser.DefaultASTVisitor
;
import
edu.kit.formal.proofscriptparser.DefaultASTVisitor
;
import
edu.kit.formal.proofscriptparser.Visitor
;
import
edu.kit.formal.proofscriptparser.Visitor
;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.types.SimpleType
;
import
edu.kit.formal.proofscriptparser.types.TypeFacade
;
import
lombok.Getter
;
import
lombok.Getter
;
import
org.apache.commons.lang.NotImplementedException
;
import
org.apache.commons.lang.NotImplementedException
;
...
@@ -156,10 +158,10 @@ public class MatchEvaluator extends DefaultASTVisitor<List<VariableAssignment>>
...
@@ -156,10 +158,10 @@ public class MatchEvaluator extends DefaultASTVisitor<List<VariableAssignment>>
// Value pattern = (Value) match.getPattern().accept(this);
// Value pattern = (Value) match.getPattern().accept(this);
List
<
VariableAssignment
>
va
=
null
;
List
<
VariableAssignment
>
va
=
null
;
if
(
pattern
.
getType
()
==
Type
.
STRING
)
{
if
(
pattern
.
getType
()
==
Simple
Type
.
STRING
)
{
va
=
getMatcher
().
matchLabel
(
goal
,
(
String
)
pattern
.
getData
());
va
=
getMatcher
().
matchLabel
(
goal
,
(
String
)
pattern
.
getData
());
//TODO extract the results form the matcher in order to retrieve the selection results
//TODO extract the results form the matcher in order to retrieve the selection results
}
else
if
(
pattern
.
getType
()
==
Type
.
TERM
)
{
}
else
if
(
TypeFacade
.
isTerm
(
pattern
.
getType
()
)
)
{
va
=
getMatcher
().
matchSeq
(
goal
,
(
String
)
pattern
.
getData
(),
sig
);
va
=
getMatcher
().
matchSeq
(
goal
,
(
String
)
pattern
.
getData
(),
sig
);
}
}
return
va
!=
null
?
va
:
Collections
.
emptyList
();
return
va
!=
null
?
va
:
Collections
.
emptyList
();
...
@@ -203,7 +205,7 @@ public class MatchEvaluator extends DefaultASTVisitor<List<VariableAssignment>>
...
@@ -203,7 +205,7 @@ public class MatchEvaluator extends DefaultASTVisitor<List<VariableAssignment>>
*/
*/
public
List
<
VariableAssignment
>
transformTruthValue
(
Value
v
)
{
public
List
<
VariableAssignment
>
transformTruthValue
(
Value
v
)
{
if
(
v
.
getType
().
equals
(
Type
.
BOOL
))
{
if
(
v
.
getType
().
equals
(
Simple
Type
.
BOOL
))
{
List
<
VariableAssignment
>
transformedValue
=
new
ArrayList
<>();
List
<
VariableAssignment
>
transformedValue
=
new
ArrayList
<>();
if
(
v
.
getData
().
equals
(
Value
.
TRUE
))
{
if
(
v
.
getData
().
equals
(
Value
.
TRUE
))
{
transformedValue
.
add
(
new
VariableAssignment
(
null
));
transformedValue
.
add
(
new
VariableAssignment
(
null
));
...
...
src/main/java/edu/kit/formal/interpreter/data/GoalNode.java
View file @
2b5b35ae
package
edu.kit.formal.interpreter.data
;
package
edu.kit.formal.interpreter.data
;
import
edu.kit.formal.proofscriptparser.
ast.
Type
;
import
edu.kit.formal.proofscriptparser.
types.Simple
Type
;
import
edu.kit.formal.proofscriptparser.ast.Variable
;
import
edu.kit.formal.proofscriptparser.ast.Variable
;
import
edu.kit.formal.proofscriptparser.types.Type
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.ToString
;
import
lombok.ToString
;
...
...
src/main/java/edu/kit/formal/interpreter/data/Value.java
View file @
2b5b35ae
package
edu.kit.formal.interpreter.data
;
package
edu.kit.formal.interpreter.data
;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.types.SimpleType
;
import
edu.kit.formal.proofscriptparser.types.Type
;
import
edu.kit.formal.proofscriptparser.types.TypeFacade
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
...
@@ -15,8 +18,8 @@ import java.math.BigInteger;
...
@@ -15,8 +18,8 @@ import java.math.BigInteger;
*/
*/
@RequiredArgsConstructor
@RequiredArgsConstructor
public
class
Value
<
T
>
{
public
class
Value
<
T
>
{
public
static
final
Value
TRUE
=
new
Value
<>(
Type
.
BOOL
,
true
);
public
static
final
Value
TRUE
=
new
Value
<>(
Simple
Type
.
BOOL
,
true
);
public
static
final
Value
FALSE
=
new
Value
<>(
Type
.
BOOL
,
false
);
public
static
final
Value
FALSE
=
new
Value
<>(
Simple
Type
.
BOOL
,
false
);
@Getter
@Getter
private
final
Type
type
;
private
final
Type
type
;
...
@@ -25,35 +28,35 @@ public class Value<T> {
...
@@ -25,35 +28,35 @@ public class Value<T> {
public
static
Value
<
BigInteger
>
from
(
IntegerLiteral
i
)
{
public
static
Value
<
BigInteger
>
from
(
IntegerLiteral
i
)
{
return
new
Value
<>(
Type
.
INT
,
i
.
getValue
());
return
new
Value
<>(
Simple
Type
.
INT
,
i
.
getValue
());
}
}
public
static
Value
<
BigInteger
>
from
(
Integer
i
)
{
public
static
Value
<
BigInteger
>
from
(
Integer
i
)
{
return
new
Value
<>(
Type
.
INT
,
BigInteger
.
valueOf
(
i
));
return
new
Value
<>(
Simple
Type
.
INT
,
BigInteger
.
valueOf
(
i
));
}
}
public
static
Value
<
String
>
from
(
StringLiteral
s
)
{
public
static
Value
<
String
>
from
(
StringLiteral
s
)
{
return
new
Value
<>(
Type
.
STRING
,
s
.
getText
());
return
new
Value
<>(
Simple
Type
.
STRING
,
s
.
getText
());
}
}
public
static
Value
<
Boolean
>
from
(
BooleanLiteral
b
)
{
public
static
Value
<
Boolean
>
from
(
BooleanLiteral
b
)
{
return
new
Value
(
Type
.
BOOL
,
b
.
isValue
());
return
new
Value
<>(
Simple
Type
.
BOOL
,
b
.
isValue
());
}
}
public
static
Value
<
Boolean
>
from
(
boolean
equals
)
{
public
static
Value
<
Boolean
>
from
(
boolean
equals
)
{
return
new
Value
(
Type
.
BOOL
,
equals
);
return
new
Value
<>(
Simple
Type
.
BOOL
,
equals
);
}
}
public
static
Value
<
BigInteger
>
from
(
BigInteger
apply
)
{
public
static
Value
<
BigInteger
>
from
(
BigInteger
apply
)
{
return
new
Value
<>(
Type
.
INT
,
apply
);
return
new
Value
<>(
Simple
Type
.
INT
,
apply
);
}
}
public
static
Value
<
String
>
from
(
String
s
)
{
public
static
Value
<
String
>
from
(
String
s
)
{
return
new
Value
<>(
Type
.
STRING
,
s
);
return
new
Value
<>(
Simple
Type
.
STRING
,
s
);
}
}
public
static
Value
<
String
>
from
(
TermLiteral
term
)
{
public
static
Value
<
String
>
from
(
TermLiteral
term
)
{
return
new
Value
<>(
Type
.
TERM
,
term
.
getText
());
return
new
Value
<>(
Type
Facade
.
ANY_
TERM
,
term
.
getText
());
}
}
@Override
@Override
...
...
src/main/java/edu/kit/formal/interpreter/data/VariableAssignment.java
View file @
2b5b35ae
package
edu.kit.formal.interpreter.data
;
package
edu.kit.formal.interpreter.data
;
import
edu.kit.formal.interpreter.exceptions.VariableNotDefinedException
;
import
edu.kit.formal.interpreter.exceptions.VariableNotDefinedException
;
import
edu.kit.formal.proofscriptparser.
ast.
Type
;
import
edu.kit.formal.proofscriptparser.
types.Simple
Type
;
import
edu.kit.formal.proofscriptparser.ast.Variable
;
import
edu.kit.formal.proofscriptparser.ast.Variable
;
import
edu.kit.formal.proofscriptparser.types.Type
;
import
lombok.ToString
;
import
lombok.ToString
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
...
src/main/java/edu/kit/formal/interpreter/dbg/PseudoMatcher.java
View file @
2b5b35ae
...
@@ -5,8 +5,9 @@ import edu.kit.formal.interpreter.data.GoalNode;
...
@@ -5,8 +5,9 @@ import edu.kit.formal.interpreter.data.GoalNode;
import
edu.kit.formal.interpreter.data.Value
;
import
edu.kit.formal.interpreter.data.Value
;
import
edu.kit.formal.interpreter.data.VariableAssignment
;
import
edu.kit.formal.interpreter.data.VariableAssignment
;
import
edu.kit.formal.proofscriptparser.ast.Signature
;
import
edu.kit.formal.proofscriptparser.ast.Signature
;
import
edu.kit.formal.proofscriptparser.
ast.
Type
;
import
edu.kit.formal.proofscriptparser.
types.Simple
Type
;
import
edu.kit.formal.proofscriptparser.ast.Variable
;
import
edu.kit.formal.proofscriptparser.ast.Variable
;
import
edu.kit.formal.proofscriptparser.types.Type
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
...
...
src/main/java/edu/kit/formal/interpreter/funchdl/MacroCommandHandler.java
View file @
2b5b35ae
...
@@ -5,6 +5,7 @@ import edu.kit.formal.interpreter.Interpreter;
...
@@ -5,6 +5,7 @@ import edu.kit.formal.interpreter.Interpreter;
import
edu.kit.formal.interpreter.data.Value
;
import
edu.kit.formal.interpreter.data.Value
;
import
edu.kit.formal.interpreter.data.VariableAssignment
;
import
edu.kit.formal.interpreter.data.VariableAssignment
;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.types.SimpleType
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
...
@@ -39,7 +40,7 @@ public class MacroCommandHandler implements CommandHandler {
...
@@ -39,7 +40,7 @@ public class MacroCommandHandler implements CommandHandler {
CallStatement
macroCall
=
new
CallStatement
(
"macro"
,
p
);
CallStatement
macroCall
=
new
CallStatement
(
"macro"
,
p
);
macroCall
.
setRuleContext
(
call
.
getRuleContext
());
macroCall
.
setRuleContext
(
call
.
getRuleContext
());
VariableAssignment
newParam
=
new
VariableAssignment
(
null
);
VariableAssignment
newParam
=
new
VariableAssignment
(
null
);
newParam
.
declare
(
"#2"
,
Type
.
STRING
);
newParam
.
declare
(
"#2"
,
Simple
Type
.
STRING
);
newParam
.
assign
(
"#2"
,
Value
.
from
(
call
.
getCommand
()));
newParam
.
assign
(
"#2"
,
Value
.
from
(
call
.
getCommand
()));
//macro proofscript command
//macro proofscript command
interpreter
.
getFunctionLookup
().
callCommand
(
interpreter
,
macroCall
,
newParam
);
interpreter
.
getFunctionLookup
().
callCommand
(
interpreter
,
macroCall
,
newParam
);
...
...
src/main/java/edu/kit/formal/interpreter/graphs/EdgeTypes.java
View file @
2b5b35ae
package
edu.kit.formal.interpreter.graphs
;
package
edu.kit.formal.interpreter.graphs
;
/**
/**
* Edge Type
s
a state graph and control flow graph may have
* Edge Type a state graph and control flow graph may have
*/
*/
public
enum
EdgeTypes
{
public
enum
EdgeTypes
{
STEP_INTO
,
STEP_OVER
,
STEP_BACK
,
STEP_RETURN
,
STEP_OVER_COND
,
STATE_FLOW
;
STEP_INTO
,
STEP_OVER
,
STEP_BACK
,
STEP_RETURN
,
STEP_OVER_COND
,
STATE_FLOW
;
...
...
src/main/java/edu/kit/formal/proofscriptparser/ASTChanger.java
View file @
2b5b35ae
...
@@ -24,6 +24,8 @@ package edu.kit.formal.proofscriptparser;
...
@@ -24,6 +24,8 @@ package edu.kit.formal.proofscriptparser;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.types.SimpleType
;
import
edu.kit.formal.proofscriptparser.types.Type
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Map
;
import
java.util.Map
;
...
...
src/main/java/edu/kit/formal/proofscriptparser/ASTTraversal.java
View file @
2b5b35ae
...
@@ -24,6 +24,7 @@ package edu.kit.formal.proofscriptparser;
...
@@ -24,6 +24,7 @@ package edu.kit.formal.proofscriptparser;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.ast.*
;
import
edu.kit.formal.proofscriptparser.types.Type
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -146,7 +147,7 @@ public interface ASTTraversal<T> extends Visitor<T> {
...
@@ -146,7 +147,7 @@ public interface ASTTraversal<T> extends Visitor<T> {
@Override
@Override
default
T
visit
(
Parameters
parameters
)
{
default
T
visit
(
Parameters
parameters
)
{
for
(
Map
.
Entry
<
Variable
,
Expression
>
e
:
for
(
Map
.
Entry
<
Variable
,
Expression
>
e
:
parameters
.
entrySet
())
{
parameters
.
entrySet
())
{
e
.
getKey
().
accept
(
this
);
e
.
getKey
().
accept
(
this
);
e
.
getValue
().
accept
(
this
);
e
.
getValue
().
accept
(
this
);
}
}
...
@@ -171,4 +172,13 @@ public interface ASTTraversal<T> extends Visitor<T> {
...
@@ -171,4 +172,13 @@ public interface ASTTraversal<T> extends Visitor<T> {
simpleCaseStatement
.
getBody
().
accept
(
this
);
simpleCaseStatement
.
getBody
().
accept
(
this
);
return
null
;
return
null
;
}
}
@Override
default
T
visit
(
SubstituteExpression
subst
)
{
subst
.
getSub
().
accept
(
this
);
for
(
Expression
e
:
subst
.
getSubstitution
().
values
())
{
e
.
accept
(
this
);
}
return
null
;
}
}
}
src/main/java/edu/kit/formal/proofscriptparser/DefaultASTVisitor.java
View file @
2b5b35ae
...
@@ -94,6 +94,11 @@ public class DefaultASTVisitor<T> implements Visitor<T> {
...
@@ -94,6 +94,11 @@ public class DefaultASTVisitor<T> implements Visitor<T> {
return
defaultVisit
(
caseStatement
);
return
defaultVisit
(
caseStatement
);
}
}
@Override
public
T
visit
(
SubstituteExpression
subst
)
{
return
defaultVisit
(
subst
);
}
@Override
@Override
public
T
visit
(
CallStatement
call
)
{
public
T
visit
(
CallStatement
call
)
{
return
defaultVisit
(
call
);
return
defaultVisit
(
call
);
...
@@ -138,5 +143,6 @@ public class DefaultASTVisitor<T> implements Visitor<T> {
...
@@ -138,5 +143,6 @@ public class DefaultASTVisitor<T> implements Visitor<T> {
public
T
visit
(
SimpleCaseStatement
simpleCaseStatement
)
{
public
T
visit
(
SimpleCaseStatement
simpleCaseStatement
)
{
return
defaultVisit
(
simpleCaseStatement
);