summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-07-17 10:42:43 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-07-17 10:42:43 +0200
commit0f0af24525c614ebef7e7f8130ffced38d2da59a (patch)
tree31f6da3c0b70229740fbcfd2ec71fc965e28f1cd /instr-to-kodkod/src
parent3e019d57fab57afe7aad373385f32a23bd178941 (diff)
Improves parameters handling
Diffstat (limited to 'instr-to-kodkod/src')
-rw-r--r--instr-to-kodkod/src/Main.java19
-rw-r--r--instr-to-kodkod/src/Parameters.java55
2 files changed, 69 insertions, 5 deletions
diff --git a/instr-to-kodkod/src/Main.java b/instr-to-kodkod/src/Main.java
index d692ecd..ec55450 100644
--- a/instr-to-kodkod/src/Main.java
+++ b/instr-to-kodkod/src/Main.java
@@ -8,6 +8,8 @@ import kodkod.engine.satlab.*;
import kodkod.instance.*;
public class Main
{
+ private static Parameters PARAMETERS;
+
private static Formula get_formula (final VHDLModel model)
{
final Variable w;
@@ -32,10 +34,10 @@ public class Main
final Solver solver;
final Solution sol;
- if (args.length != 1)
- {
- System.out.println("Use: java Main <instructions_file>");
+ PARAMETERS = new Parameters(args);
+ if (!PARAMETERS.are_valid())
+ {
return;
}
@@ -43,7 +45,14 @@ public class Main
try
{
- VHDLLevel.add_to_model(model, "./structural_level.data");
+ VHDLLevel.add_to_model
+ (
+ model,
+ (
+ PARAMETERS.get_levels_directory()
+ + "/structural_level.data"
+ )
+ );
}
catch (final Exception e)
{
@@ -55,7 +64,7 @@ public class Main
try
{
- model.parse_file(args[0]);
+ model.parse_file(PARAMETERS.get_model_file());
}
catch (final Exception e)
{
diff --git a/instr-to-kodkod/src/Parameters.java b/instr-to-kodkod/src/Parameters.java
new file mode 100644
index 0000000..8d0331b
--- /dev/null
+++ b/instr-to-kodkod/src/Parameters.java
@@ -0,0 +1,55 @@
+public class Parameters
+{
+ private final String levels_dir;
+ private final String model_file;
+ private final boolean are_valid;
+
+ public static void print_usage ()
+ {
+ System.out.println
+ (
+ "Instr-to-kodkod\n"
+ + "USAGE:\n"
+ + "\tjava Main <LEVELS_DIR> <INSTRUCTIONS>\n"
+ + "PARAMETERS:\n"
+ + "\t<LEVELS_DIR>\tDirectory containing the level definitions.\n"
+ + "\t<INSTRUCTIONS>\tInstruction file describing the model.\n"
+ + "NOTES:\n"
+ + "\tThe properties to be verified still have to be hand coded in the"
+ + "source files (in Main.java)."
+ );
+ }
+
+ public Parameters (String... args)
+ {
+ if (args.length != 2)
+ {
+ print_usage();
+
+ levels_dir = new String();
+ model_file = new String();
+ are_valid = false;
+ }
+ else
+ {
+ levels_dir = args[0];
+ model_file = args[1];
+ are_valid = true;
+ }
+ }
+
+ public String get_levels_directory ()
+ {
+ return levels_dir;
+ }
+
+ public String get_model_file ()
+ {
+ return model_file;
+ }
+
+ public boolean are_valid ()
+ {
+ return are_valid;
+ }
+}