Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tla2bAST
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
tla2bAST
Commits
08736cf6
Commit
08736cf6
authored
5 months ago
by
Jan Gruteser
Browse files
Options
Downloads
Patches
Plain Diff
adapt translation of SubSeq
parent
6f14b439
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#148723
failed
5 months ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/de/tla2bAst/BAstCreator.java
+37
-29
37 additions, 29 deletions
src/main/java/de/tla2bAst/BAstCreator.java
src/test/java/de/tla2b/prettyprintb/standardmodules/SequencesTest.java
+3
-1
3 additions, 1 deletion
.../de/tla2b/prettyprintb/standardmodules/SequencesTest.java
with
40 additions
and
30 deletions
src/main/java/de/tla2bAst/BAstCreator.java
+
37
−
29
View file @
08736cf6
...
@@ -953,36 +953,44 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals, BBuil
...
@@ -953,36 +953,44 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals, BBuil
break
;
break
;
case
B_OPCODE_subseq:
{
// SubSeq(s,a,b)
case
B_OPCODE_subseq:
{
// SubSeq(s,a,b)
// %p.(p : 1..(b-a+1)| s(p+a-1))
// new translation: (s /|\ b) \|/ a-1 (this saves us a new identifier name)
ALambdaExpression
lambda
=
new
ALambdaExpression
();
returnNode
=
new
ARestrictTailExpression
(
lambda
.
setIdentifiers
(
createIdentifierList
(
"t_"
));
new
ARestrictFrontExpression
(
AMemberPredicate
member
=
new
AMemberPredicate
();
visitExprOrOpArgNodeExpression
(
opApplNode
.
getArgs
()[
0
]),
// s
member
.
setLeft
(
createIdentifierNode
(
"t_"
));
visitExprOrOpArgNodeExpression
(
opApplNode
.
getArgs
()[
2
])
// b
AIntervalExpression
interval
=
new
AIntervalExpression
();
),
interval
.
setLeftBorder
(
new
AIntegerExpression
(
new
TIntegerLiteral
(
"1"
)));
new
AMinusOrSetSubtractExpression
(
AMinusOrSetSubtractExpression
minus
=
new
AMinusOrSetSubtractExpression
();
visitExprOrOpArgNodeExpression
(
opApplNode
.
getArgs
()[
1
]),
// a
minus
.
setLeft
(
visitExprOrOpArgNodeExpression
(
opApplNode
.
getArgs
()[
2
]));
createIntegerNode
(
"1"
)
minus
.
setRight
(
visitExprOrOpArgNodeExpression
(
opApplNode
.
getArgs
()[
1
]));
)
AAddExpression
add
=
new
AAddExpression
();
);
add
.
setLeft
(
minus
);
add
.
setRight
(
new
AIntegerExpression
(
new
TIntegerLiteral
(
"1"
)));
interval
.
setRightBorder
(
add
);
member
.
setRight
(
interval
);
lambda
.
setPredicate
(
member
);
AAddExpression
add2
=
new
AAddExpression
();
add2
.
setLeft
(
createIdentifierNode
(
"t_"
));
add2
.
setRight
(
visitExprOrOpArgNodeExpression
(
opApplNode
.
getArgs
()[
1
]));
AMinusOrSetSubtractExpression
minus2
=
new
AMinusOrSetSubtractExpression
();
minus2
.
setLeft
(
add2
);
minus2
.
setRight
(
new
AIntegerExpression
(
new
TIntegerLiteral
(
"1"
)));
ArrayList
<
PExpression
>
params
=
new
ArrayList
<>();
params
.
add
(
minus2
);
AFunctionExpression
func
=
new
AFunctionExpression
();
func
.
setIdentifier
(
visitExprOrOpArgNodeExpression
(
opApplNode
.
getArgs
()[
0
]));
func
.
setParameters
(
params
);
lambda
.
setExpression
(
func
);
returnNode
=
lambda
;
break
;
break
;
// previous translation: %t_.(t_ : 1..(b-a+1)| s(t_+a-1))
/*PExpression a = visitExprOrOpArgNodeExpression(opApplNode.getArgs()[1]);
PExpression b = visitExprOrOpArgNodeExpression(opApplNode.getArgs()[2]);
returnNode = new ALambdaExpression( // %t_.(t_ : 1..(b-a+1)| s(t_+a-1))
createIdentifierList("t_"),
new AMemberPredicate( // t_ : 1..(b-a+1)
createIdentifierNode("t_"),
new AIntervalExpression(
createIntegerNode("1"),
new AAddExpression(
new AMinusOrSetSubtractExpression(b, a),
createIntegerNode("1")
)
)
),
new AFunctionExpression( // s(t_+a-1)
visitExprOrOpArgNodeExpression(opApplNode.getArgs()[0]), // s
Collections.singletonList(
new AMinusOrSetSubtractExpression(
new AAddExpression(createIdentifierNode("t_"), a.clone()),
createIntegerNode("1")
)
)
)
);*/
}
}
case
B_OPCODE_assert:
{
case
B_OPCODE_assert:
{
...
...
This diff is collapsed.
Click to expand it.
src/test/java/de/tla2b/prettyprintb/standardmodules/SequencesTest.java
+
3
−
1
View file @
08736cf6
...
@@ -86,7 +86,9 @@ public class SequencesTest {
...
@@ -86,7 +86,9 @@ public class SequencesTest {
+
"ASSUME SubSeq(<<1,2,3,4,5>>, 2, 3) = <<2,3>> \n"
+
"ASSUME SubSeq(<<1,2,3,4,5>>, 2, 3) = <<2,3>> \n"
+
"================================="
;
+
"================================="
;
final
String
expected
=
"MACHINE Testing\n"
final
String
expected
=
"MACHINE Testing\n"
+
"PROPERTIES %(t_).(t_ : 1 .. (3 - 2) + 1 | [1,2,3,4,5](((t_ + 2) - 1))) = [2,3] \n"
// + "PROPERTIES %(t_).(t_ : 1 .. (3 - 2) + 1 | [1,2,3,4,5](((t_ + 2) - 1))) = [2,3] \n"
// new translation:
+
"PROPERTIES ([1,2,3,4,5] /|\\ 3) \\|/ (2 - 1) = [2,3] \n"
+
"END"
;
+
"END"
;
compare
(
expected
,
module
);
compare
(
expected
,
module
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment