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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
tla2bAST
Commits
2e7d2fca
Commit
2e7d2fca
authored
8 months ago
by
Jan Gruteser
Browse files
Options
Downloads
Patches
Plain Diff
simplify Translator
parent
b000185c
No related branches found
No related tags found
No related merge requests found
Pipeline
#144890
passed
8 months ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/tla2bAst/Translator.java
+8
-21
8 additions, 21 deletions
src/main/java/de/tla2bAst/Translator.java
with
8 additions
and
21 deletions
src/main/java/de/tla2bAst/Translator.java
+
8
−
21
View file @
2e7d2fca
...
...
@@ -39,15 +39,10 @@ import java.util.List;
import
java.util.stream.Collectors
;
public
class
Translator
implements
TranslationGlobals
{
private
String
moduleFileName
;
private
String
parentPath
;
private
File
moduleFile
;
private
File
configFile
;
private
List
<
File
>
moduleFiles
=
new
ArrayList
<>();
private
Start
BAst
;
private
Map
<
Node
,
TLAType
>
types
;
private
Definitions
bDefinitions
;
private
BAstCreator
bAstCreator
;
...
...
@@ -59,8 +54,6 @@ public class Translator implements TranslationGlobals {
private
TypeChecker
typechecker
;
public
Translator
(
String
moduleFileName
)
throws
TLA2BFrontEndException
{
this
.
moduleFileName
=
moduleFileName
;
this
.
moduleFile
=
new
File
(
moduleFileName
);
if
(!
moduleFile
.
exists
())
{
throw
new
RuntimeException
(
"Can not find module file: '"
+
moduleFileName
+
"'"
);
...
...
@@ -119,7 +112,6 @@ public class Translator implements TranslationGlobals {
try
(
BufferedWriter
out
=
new
BufferedWriter
(
new
OutputStreamWriter
(
Files
.
newOutputStream
(
moduleFile
.
toPath
()),
StandardCharsets
.
UTF_8
)))
{
out
.
write
(
moduleString
);
}
moduleFileName
=
moduleFile
.
getAbsolutePath
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -212,11 +204,9 @@ public class Translator implements TranslationGlobals {
new
BMacroHandler
(
specAnalyser
,
conEval
),
new
RecursiveFunctionHandler
(
specAnalyser
));
this
.
types
=
bAstCreator
.
getTypes
();
this
.
bDefinitions
=
bAstCreator
.
getBDefinitions
();
this
.
moduleFiles
=
bAstCreator
.
getFilesOrderedById
().
stream
()
.
map
(
file
->
new
File
(
parentPath
,
file
+
".tla"
)).
collect
(
Collectors
.
toList
());
return
this
.
BAst
=
bAstCreator
.
getStartNode
();
return
getBAST
();
}
public
void
createProbFile
()
{
...
...
@@ -249,15 +239,12 @@ public class Translator implements TranslationGlobals {
}
public
void
createMachineFile
()
{
String
bFile
=
FileUtils
.
removeExtension
(
moduleFile
.
getAbsolutePath
());
bFile
=
bFile
+
"_tla.txt"
;
String
bFile
=
FileUtils
.
removeExtension
(
moduleFile
.
getAbsolutePath
())
+
"_tla.txt"
;
File
machineFile
;
machineFile
=
new
File
(
bFile
);
File
machineFile
=
new
File
(
bFile
);
if
(
machineFile
.
exists
())
{
try
{
BufferedReader
in
;
in
=
new
BufferedReader
(
new
FileReader
(
machineFile
));
BufferedReader
in
=
new
BufferedReader
(
new
FileReader
(
machineFile
));
String
firstLine
=
in
.
readLine
();
in
.
close
();
if
(
firstLine
!=
null
&&
!
firstLine
.
startsWith
(
"/*@ generated by TLA2B "
))
{
...
...
@@ -280,7 +267,7 @@ public class Translator implements TranslationGlobals {
PrettyPrinter
pp
=
new
PrettyPrinter
();
pp
.
setRenaming
(
new
SuffixIdentifierRenaming
());
BAst
.
apply
(
pp
);
getBAST
()
.
apply
(
pp
);
String
result
=
"/*@ generated by TLA2B "
+
VERSION_NUMBER
+
" */\n"
+
pp
.
getPrettyPrint
();
try
{
...
...
@@ -336,7 +323,7 @@ public class Translator implements TranslationGlobals {
}
public
Definitions
getBDefinitions
()
{
return
bDefinitions
;
return
b
AstCreator
.
getB
Definitions
()
;
}
public
ModuleNode
getModuleNode
()
{
...
...
@@ -352,7 +339,7 @@ public class Translator implements TranslationGlobals {
}
public
Start
getBAST
()
{
return
B
Ast
;
return
b
Ast
Creator
.
getStartNode
()
;
}
public
File
getModuleFile
()
{
...
...
@@ -364,7 +351,7 @@ public class Translator implements TranslationGlobals {
}
public
Map
<
Node
,
TLAType
>
getTypes
()
{
return
this
.
t
ypes
;
return
bAstCreator
.
getT
ypes
()
;
}
}
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