| summaryrefslogtreecommitdiff |
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2017-07-17 15:22:19 +0200 |
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2017-07-17 15:22:19 +0200 |
| commit | d48380bd87dcef4b095b2a4e578d4461e68df73c (patch) | |
| tree | 0ddbcbdd54d329b5130041d7a5fd25a8c1ca3875 /cfg-to-paths/src/ControlFlow.java | |
| parent | 0f0af24525c614ebef7e7f8130ffced38d2da59a (diff) | |
Working on a way to CTL over DAG in Kodkod.
Diffstat (limited to 'cfg-to-paths/src/ControlFlow.java')
| -rw-r--r-- | cfg-to-paths/src/ControlFlow.java | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/cfg-to-paths/src/ControlFlow.java b/cfg-to-paths/src/ControlFlow.java new file mode 100644 index 0000000..629ac49 --- /dev/null +++ b/cfg-to-paths/src/ControlFlow.java @@ -0,0 +1,121 @@ +import java.io.*; + +public class ControlFlow +{ + public static boolean load_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 (input[0].equals("add_element")) + { + success = handle_add_element(input); + } + else if (input[0].equals("connect_to")) + { + success = handle_add_connect_to(input); + } + else + { + continue; + } + + if (!success) + { + 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 handle_add_element + ( + final String[] input + ) + { + if (input.length != 3) + { + return false; + } + + if (input[1] != "node") + { + return true; + } + + Node.handle_add_node(input[2]); + + return true; + } + + private static boolean handle_add_connect_to + ( + final String[] input + ) + { + if ((input.length != 3)) + { + return false; + } + + return Node.handle_connect_to(input[1], input[2]); + } +} |


