From 23c5a3b1bd89e7a394a4cc4881e0764d601632c7 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Sun, 30 Aug 2020 16:15:36 +0200 Subject: Adds user prompts for String and Integer. I think so are seen frequently enough to warrant an addition. --- .../tonkadur/jsonexport/InstructionCompiler.java | 53 ++++++++++++++++++++-- 1 file changed, 49 insertions(+), 4 deletions(-) (limited to 'src/json-export') diff --git a/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java b/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java index 8376be4..01b8e76 100644 --- a/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java +++ b/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java @@ -15,19 +15,16 @@ public class InstructionCompiler implements InstructionVisitor public void visit_add_choice (final AddChoice n) throws Throwable { - final ComputationCompiler label_cc, address_cc; + final ComputationCompiler label_cc; label_cc = new ComputationCompiler(); - address_cc = new ComputationCompiler(); n.get_label().get_visited_by(label_cc); - n.get_address().get_visited_by(address_cc); result = new JSONObject(); result.put("category", "add_choice"); result.put("label", label_cc.get_result()); - result.put("address", address_cc.get_result()); } public void visit_assert (final Assert n) @@ -152,6 +149,54 @@ public class InstructionCompiler implements InstructionVisitor result.put("value", val_cc.get_result()); } + public void visit_prompt_integer (final PromptInteger n) + throws Throwable + { + final ComputationCompiler target_cc, min_cc, max_cc, label_cc; + + target_cc = new ComputationCompiler(); + min_cc = new ComputationCompiler(); + max_cc = new ComputationCompiler(); + label_cc = new ComputationCompiler(); + + n.get_target().get_visited_by(target_cc); + n.get_min().get_visited_by(min_cc); + n.get_max().get_visited_by(max_cc); + n.get_label().get_visited_by(label_cc); + + result = new JSONObject(); + + result.put("category", "prompt_integer"); + result.put("target", target_cc.get_result()); + result.put("min", min_cc.get_result()); + result.put("max", max_cc.get_result()); + result.put("label", label_cc.get_result()); + } + + public void visit_prompt_string (final PromptString n) + throws Throwable + { + final ComputationCompiler target_cc, min_cc, max_cc, label_cc; + + target_cc = new ComputationCompiler(); + min_cc = new ComputationCompiler(); + max_cc = new ComputationCompiler(); + label_cc = new ComputationCompiler(); + + n.get_target().get_visited_by(target_cc); + n.get_min().get_visited_by(min_cc); + n.get_max().get_visited_by(max_cc); + n.get_label().get_visited_by(label_cc); + + result = new JSONObject(); + + result.put("category", "prompt_string"); + result.put("target", target_cc.get_result()); + result.put("min", min_cc.get_result()); + result.put("max", max_cc.get_result()); + result.put("label", label_cc.get_result()); + } + public JSONObject get_result () { return result; -- cgit v1.2.3-70-g09d2