| summaryrefslogtreecommitdiff |
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2017-07-25 16:59:20 +0200 |
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2017-07-25 16:59:20 +0200 |
| commit | d7647dda4fe577a5a9d8569e0a9e0e28496c0744 (patch) | |
| tree | 83ddf15908b79b6f47ed8ee06a5e7a1d09c7e96d /instr-to-kodkod/src/Main.java | |
| parent | 54bb34b819c314f2274d560bb50cb1afaeedfa84 (diff) | |
Gets the strings seemingly working.
Diffstat (limited to 'instr-to-kodkod/src/Main.java')
| -rw-r--r-- | instr-to-kodkod/src/Main.java | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/instr-to-kodkod/src/Main.java b/instr-to-kodkod/src/Main.java index 5b0e9b5..b835c28 100644 --- a/instr-to-kodkod/src/Main.java +++ b/instr-to-kodkod/src/Main.java @@ -8,6 +8,7 @@ import kodkod.engine.satlab.*; import kodkod.instance.*; import java.io.IOException; +import java.io.FileNotFoundException; import java.util.Iterator; public class Main @@ -15,6 +16,7 @@ public class Main private static Parameters PARAMETERS; private static VHDLModel MODEL; private static VariableManager VARIABLE_MANAGER; + private static StringManager STRING_MANAGER; public static VHDLModel get_model () { @@ -26,6 +28,11 @@ public class Main return VARIABLE_MANAGER; } + public static StringManager get_string_manager () + { + return STRING_MANAGER; + } + private static boolean load_levels () { for (final String lvl: PARAMETERS.get_level_files()) @@ -113,6 +120,103 @@ public class Main return true; } + private static boolean load_mapping_file (final String filename) + throws FileNotFoundException + { + final QuickParser qp; + String[] input; + boolean success; + + qp = new QuickParser(filename); + + for (;;) + { + try + { + input = qp.parse_line(); + + if (input == null) + { + qp.finalize(); + + return false; + } + else if (input.length == 0) + { + qp.finalize(); + + break; + } + } + catch (final IOException e) + { + System.err.println + ( + "[E] IO error while parsing file \"" + + filename + + "\":" + /* FIXME: can be null */ + + e.getMessage() + ); + + return false; + } + + if + ( + (!STRING_MANAGER.handle_mapping_instruction(input)) + /* && (!_____.handle_mapping_instruction(input)) */ + /* Yeah, we don't handle those */ + && (!input[0].equals("xml->instr")) + ) + { + System.err.println + ( + "[E] An erroneous instruction was found in file \"" + + filename + + "\"." + ); + + try + { + qp.finalize(); + } + catch (final Exception e) + { + System.err.println("[E] Additionally:"); + e.printStackTrace(); + } + + return false; + } + } + + return true; + } + + private static boolean load_mappings () + { + try + { + for (final String file: PARAMETERS.get_mapping_files()) + { + if (!load_mapping_file(file)) + { + return false; + } + } + } + catch (final Exception e) + { + System.err.println("[F] Could not load mappings:"); + e.printStackTrace(); + + System.exit(-1); + } + + return true; + } + public static void main (final String... args) { /* @@ -147,6 +251,14 @@ public class Main return; } + /* 2/ Load Mappings (to allow references in the property). */ + STRING_MANAGER = new StringManager(); + + if (!load_mappings()) + { + return; + } + /* 2/ Load Properties (will change 'is_used()' on predicates) */ /* FIXME? Currently only one property, due to the 'is_used' */ property = load_property(); |


