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
6dc3d9ec
Commit
6dc3d9ec
authored
10 years ago
by
hansen
Browse files
Options
Downloads
Patches
Plain Diff
added a static test method
parent
e418d4b7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/tla2bAst/Translator.java
+50
-21
50 additions, 21 deletions
src/main/java/de/tla2bAst/Translator.java
with
50 additions
and
21 deletions
src/main/java/de/tla2bAst/Translator.java
+
50
−
21
View file @
6dc3d9ec
...
...
@@ -93,46 +93,74 @@ public class Translator implements TranslationGlobals {
}
}
// Used for Testing
// used to for external use
public
static
String
translateModuleString
(
String
moduleName
,
String
moduleString
,
String
configString
)
throws
TLA2BException
{
Translator
translator
=
new
Translator
(
moduleName
,
moduleString
,
configString
);
Start
bAST
=
translator
.
getBAST
();
Renamer
renamer
=
new
Renamer
(
bAST
);
ASTPrettyPrinter
aP
=
new
ASTPrettyPrinter
(
bAST
,
renamer
);
bAST
.
apply
(
aP
);
return
aP
.
getResultString
();
}
public
Translator
(
String
moduleName
,
String
moduleString
,
String
configString
)
throws
TLA2BException
{
createTLATempFile
(
moduleString
,
moduleName
);
createCfgFile
(
configString
,
moduleName
);
parse
();
translate
();
}
// Used for Testing in tla2bAST project
public
Translator
(
String
moduleString
,
String
configString
)
throws
FrontEndException
{
String
moduleName
=
"Testing"
;
File
dir
=
new
File
(
"temp/"
);
dir
.
mkdirs
();
createTLATempFile
(
moduleString
,
moduleName
);
createCfgFile
(
configString
,
moduleName
);
parse
();
}
private
void
createCfgFile
(
String
configString
,
String
moduleName
)
{
modelConfig
=
null
;
if
(
configString
!=
null
)
{
configFile
=
new
File
(
"temp/"
+
moduleName
+
".cfg"
);
try
{
moduleFile
=
new
File
(
"temp/"
+
moduleName
+
".tla"
);
moduleFile
.
createNewFile
();
configFile
.
createNewFile
();
BufferedWriter
out
=
new
BufferedWriter
(
new
OutputStreamWriter
(
new
FileOutputStream
(
module
File
),
"UTF-8"
));
new
FileOutputStream
(
config
File
),
"UTF-8"
));
try
{
out
.
write
(
module
String
);
out
.
write
(
config
String
);
}
finally
{
out
.
close
();
}
moduleFileName
=
moduleFile
.
getAbsolutePath
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
modelConfig
=
null
;
if
(
configString
!=
null
)
{
configFile
=
new
File
(
"temp/"
+
moduleName
+
".cfg"
);
}
}
private
void
createTLATempFile
(
String
moduleString
,
String
moduleName
)
{
File
dir
=
new
File
(
"temp/"
);
dir
.
mkdirs
();
dir
.
deleteOnExit
();
try
{
configFile
.
createNewFile
();
moduleFile
=
new
File
(
"temp/"
+
moduleName
+
".tla"
);
moduleFile
.
createNewFile
();
BufferedWriter
out
=
new
BufferedWriter
(
new
OutputStreamWriter
(
new
FileOutputStream
(
config
File
),
"UTF-8"
));
new
FileOutputStream
(
module
File
),
"UTF-8"
));
try
{
out
.
write
(
config
String
);
out
.
write
(
module
String
);
}
finally
{
out
.
close
();
}
moduleFileName
=
moduleFile
.
getAbsolutePath
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
dir
.
deleteOnExit
();
parse
();
}
public
ModuleNode
parseModule
()
throws
de
.
tla2b
.
exceptions
.
FrontEndException
{
...
...
@@ -263,7 +291,8 @@ public class Translator implements TranslationGlobals {
PrologPrinter
prologPrinter
=
new
PrologPrinter
(
rml
,
bParser
,
moduleFile
,
moduleName
,
typeTable
);
// prologPrinter.printAsProlog(new PrintWriter(probFile), false);
prologPrinter
.
printAsProlog
(
new
PrintWriter
(
probFile
,
"UTF-8"
),
false
);
prologPrinter
.
printAsProlog
(
new
PrintWriter
(
probFile
,
"UTF-8"
),
false
);
System
.
out
.
println
(
probFile
.
getAbsolutePath
()
+
" created."
);
// prologPrinter.printAsProlog(new PrintWriter(System.out), false);
...
...
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