From b95d1790243c09901fa5175a9ec29fcdce0998a1 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Fri, 7 Aug 2020 11:18:18 +0200 Subject: ... --- data/examples/monster_battle/battle.fate | 2 +- data/tests/conditionals.fate | 222 +++++++++++++++++++++ data/tests/include/data_types.fate | 70 +++++++ data/tests/operators.fate | 154 ++++++++++++++ src/core/src/tonkadur/Main.java | 10 - .../tonkadur/fate/v1/lang/instruction/Assert.java | 16 +- .../fate/v1/lang/instruction/ReverseList.java | 101 ++++++++++ .../fate/v1/lang/meta/InstructionVisitor.java | 3 + src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 | 4 + src/core/src/tonkadur/fate/v1/parser/FateParser.g4 | 66 +++++- .../wyrd/v1/compiler/fate/v1/Compiler.java | 12 ++ .../v1/compiler/fate/v1/ComputationCompiler.java | 2 +- .../v1/compiler/fate/v1/InstructionCompiler.java | 203 ++++++++++++++++--- .../wyrd/v1/compiler/fate/v1/MacroManager.java | 28 ++- .../v1/compiler/util/AnonymousVariableManager.java | 15 ++ .../tonkadur/wyrd/v1/compiler/util/RemoveAt.java | 2 +- .../wyrd/v1/compiler/util/ReverseList.java | 152 ++++++++++++++ .../tonkadur/wyrd/v1/lang/instruction/Assert.java | 11 +- .../tonkadur/jsonexport/InstructionCompiler.java | 11 +- .../src/tonkadur/jsonexport/Translator.java | 3 - 20 files changed, 1033 insertions(+), 54 deletions(-) create mode 100644 data/tests/conditionals.fate create mode 100644 data/tests/include/data_types.fate create mode 100644 data/tests/operators.fate create mode 100644 src/core/src/tonkadur/wyrd/v1/compiler/util/ReverseList.java diff --git a/data/examples/monster_battle/battle.fate b/data/examples/monster_battle/battle.fate index cfdce39..9674b95 100644 --- a/data/examples/monster_battle/battle.fate +++ b/data/examples/monster_battle/battle.fate @@ -1,5 +1,5 @@ (fate_version 1) (define_sequence start_battle - nothing yet + (end) ) diff --git a/data/tests/conditionals.fate b/data/tests/conditionals.fate new file mode 100644 index 0000000..02730c6 --- /dev/null +++ b/data/tests/conditionals.fate @@ -0,0 +1,222 @@ +(fate_version 1) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; COMPUTATIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; COMPUTATION IF-ELSE +(assert (ifelse (true) (true) (false)) FAILED: computation if-else A) +(assert (ifelse (false) (false) (true)) FAILED: computation if-else B) +(assert (ifelse (false) (false) (ifelse (true) (true) (false))) FAILED: computation if-else C) + +;; COMPUTATION COND +(assert + (cond + ((true) (true)) + ) + FAILED: computation cond A +) +(assert + (cond + ((false) (false)) + ((true) (true)) + ) + FAILED: computation cond D +) +(assert + (cond + ((false) (false)) + ((true) (true)) + ((true) (false)) + ) + FAILED: computation cond E +) +(assert + (cond + ((false) (false)) + ((true) + (cond + ((false) (false)) + ((true) (true)) + ((true) (false)) + ) + ) + ((true) (false)) + ) + FAILED: computation cond D +) + +;; COMPUTATION SWITCH +;; TODO: re-enable. Currently not implemented in Wyrd compiler +;;(assert +;; (switch 3 +;; (0 (false)) +;; (1 (false)) +;; (3 (true)) +;; (2 (false)) +;; (false) +;; ) +;; FAILED: computation switch A +;;) +;;(assert +;; (switch 3 +;; (0 (false)) +;; (1 (false)) +;; (2 (false)) +;; (true) +;; ) +;; FAILED: computation switch B +;;) +;;(assert +;; (switch 3 +;; (0 (false)) +;; (1 (false)) +;; (2 (false)) +;; (switch 2 +;; (0 (false)) +;; (1 (false)) +;; (2 (true)) +;; (false) +;; ) +;; ) +;; FAILED: computation switch C +;;) +;;(assert +;; (switch 3 +;; (0 (false)) +;; (1 (false)) +;; (2 +;; (switch 1 +;; (0 (false)) +;; (2 (false)) +;; (1 (true)) +;; (false) +;; ) +;; ) +;; (false) +;; ) +;; FAILED: computation switch D +;;) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; INSTRUCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(declare_variable boolean test_var) +(set test_var (true)) + +(assert (var test_var) FAILED: setting test_var) + +;; INSTRUCTION IF +(if (false) + (assert (false) FAILED: instruction if A) +) + +(set test_var (false)) +(if (true) + (set test_var (true)) +) +(assert (var test_var) FAILED: instruction if B) + +(if (false) + (if (false) + (assert (false) FAILED: instruction if C) + ) +) +(if (true) + (if (false) + (assert (false) FAILED: instruction if D) + ) +) +(if (false) + (if (true) + (assert (false) FAILED: instruction if E) + ) +) + +(set test_var (false)) +(if (true) + (if (true) + (set test_var (true)) + ) +) +(assert (var test_var) FAILED: instruction if F) + +;; INSTRUCTION IF-ELSE +(set test_var (false)) +(ifelse (false) + (assert (false) FAILED: instruction ifelse A) + (set test_var (true)) +) +(assert (var test_var) FAILED: instruction ifelse B) + +(set test_var (false)) +(ifelse (true) + (set test_var (true)) + (assert (false) FAILED: instruction ifelse C) +) +(assert (var test_var) FAILED: instruction ifelse D) + +(set test_var (false)) +(ifelse (true) + (ifelse (false) + (assert (false) FAILED: instruction ifelse E) + (set test_var (true)) + ) + (assert (false) FAILED: instruction ifelse F) +) +(assert (var test_var) FAILED: instruction ifelse G) + +;; INSTRUCTION COND +(set test_var (false)) +(cond + ((false) (assert (false) FAILED: instruction cond A)) + ((true) (set test_var (true))) +) +(assert (var test_var) FAILED: instruction cond B) + +(set test_var (false)) +(cond + ((true) (set test_var (true))) + ((false) (assert (false) FAILED: instruction cond B)) +) +(assert (var test_var) FAILED: instruction cond C) + +(set test_var (false)) +(cond + ((true) (set test_var (true))) + ((true) (assert (false) FAILED: instruction cond D)) + ((false) (assert (false) FAILED: instruction cond E)) +) +(assert (var test_var) FAILED: instruction cond F) + +;; INSTRUCTION SWITCH +(set test_var (false)) +(switch 3 + (0 (assert (false) FAILED: instruction switch B)) + (1 (assert (false) FAILED: instruction switch C)) + (set test_var (true)) +) +(assert (var test_var) FAILED: instruction switch D) + +(set test_var (false)) +(switch 3 + (0 (assert (false) FAILED: instruction switch E)) + (1 (assert (false) FAILED: instruction switch F)) + (3 (set test_var (true))) + (2 (assert (false) FAILED: instruction switch G)) + (assert (false) FAILED: instruction switch H) +) +(assert (var test_var) FAILED: instruction switch I) + +(set test_var (false)) +(switch 3 + (0 (assert (false) FAILED: instruction switch J)) + (1 (assert (false) FAILED: instruction switch K)) + (3 (set test_var (true))) + (3 (assert (false) FAILED: instruction switch L)) + (2 (assert (false) FAILED: instruction switch M)) + (assert (false) FAILED: instruction switch N) +) +(assert (var test_var) FAILED: instruction switch O) + +(end) diff --git a/data/tests/include/data_types.fate b/data/tests/include/data_types.fate new file mode 100644 index 0000000..3205b69 --- /dev/null +++ b/data/tests/include/data_types.fate @@ -0,0 +1,70 @@ +(fate_version 1) + +(typedef boolean sub_boolean) +(typedef boolean alt_boolean) +(typedef sub_boolean sub_sub_boolean) +(typedef sub_boolean alt_sub_boolean) + +(typedef int sub_int) +(typedef int alt_int) +(typedef sub_int sub_sub_int) +(typedef sub_int alt_sub_int) + +(typedef float sub_float) +(typedef float alt_float) +(typedef sub_float sub_sub_float) +(typedef sub_float alt_sub_float) + +(typedef string sub_string) +(typedef string alt_string) +(typedef sub_string sub_sub_string) +(typedef sub_string alt_sub_string) + +(define_list_type boolean list_boolean) +(define_list_type sub_boolean list_sub_boolean) +(define_set_type boolean set_boolean) +(define_set_type sub_boolean set_sub_boolean) +(define_ref_type boolean ref_boolean) +(define_ref_type sub_boolean ref_sub_boolean) + +(define_list_type int list_int) +(define_list_type sub_int list_sub_int) +(define_set_type int set_int) +(define_set_type sub_int set_sub_int) +(define_ref_type int ref_int) +(define_ref_type sub_int ref_sub_int) + +(define_list_type float list_float) +(define_list_type sub_float list_sub_float) +(define_set_type float set_float) +(define_set_type sub_float set_sub_float) +(define_ref_type float ref_float) +(define_ref_type sub_float ref_sub_float) + +(define_list_type string list_int) +(define_list_type sub_string list_sub_int) +(define_set_type string set_int) +(define_set_type sub_string set_sub_int) +(define_ref_type string ref_int) +(define_ref_type sub_string ref_sub_int) + +(define_dict_type simple_dict + (boolean boolean) + (int int) + (float float) + (string string) +) + +(define_ref_type simple_dict simple_dict_ptr) +(define_list_type simple_dict_ptr simple_dict_ptr_list) +(define_set_type simple_dict_ptr simple_dict_ptr_set) + +(define_dict_type two_dict + (simple_dict dict_a) + (simple_dict dict_b) + (simple_dict_ptr dict_ptr) +) + +(define_ref_type two_dict two_dict_ptr) +(define_list_type two_dict_ptr two_dict_ptr_list) +(define_set_type two_dict_ptr two_dict_ptr_set) diff --git a/data/tests/operators.fate b/data/tests/operators.fate new file mode 100644 index 0000000..6598297 --- /dev/null +++ b/data/tests/operators.fate @@ -0,0 +1,154 @@ +(fate_version 1) + +;; EQUALITY +(assert (= 1 1) FAILED: int equality) +(assert (= 1.0 1.0) FAILED: float equality) +(assert (= test test) FAILED: string equality) +(assert (= (true) (true)) FAILED: boolean equality) + +(assert (= (= 1 2) (false)) FAILED: int inequality) +(assert (= (= 1.0 2.0) (false)) FAILED: float inequality) +(assert (= (= one two) (false)) FAILED: string inequality) +(assert (= (= (true) (false)) (false)) FAILED: boolean inequality) + +(assert (= 1 1 1 1 1) FAILED: int n>2 equality) +(assert (= 1.0 1.0 1.0 1.0 1.0) FAILED: float n>2 equality) +(assert (= test test test test test) FAILED: string n>2 equality) +(assert (= (true) (true) (true) (true)) FAILED: boolean n>2 equality) + + +;; ADDITION +(assert (= (+ 1 1) 2) FAILED: int addition) +(assert (= (+ 1 1 1 1) 4) FAILED: int n>2 addition) +(assert (= (+ 1.5 1.5) 3.0) FAILED: float addition) +(assert (= (+ 1.5 1.0 1.5 1.0) 5.0) FAILED: float n>2 addition) + +;; SUBTRACTION +(assert (= (- 1 1) 0) FAILED: int subtraction) +(assert (= (- 1 1 1 1) -2) FAILED: int n>2 subtraction) +(assert (= (- 1.5 1.5) 0.0) FAILED: float subtraction) +(assert (= (- 1.5 1.0 1.5 1.0) -2.0) FAILED: float n>2 subtraction) + +;; MULTIPLICATION +(assert (= (* 1 3) 3) FAILED: int multiplication) +(assert (= (* 1 1 3 2) 6) FAILED: int n>2 multiplication) +(assert (= (* 1.5 2.0) 3.0) FAILED: float multiplication) +(assert (= (* 1.5 1.0 3.0 1.0) 4.5) FAILED: float n>2 multiplication) + +;; DIVISION +(assert (= (/ 3 3) 1) FAILED: int division) +(assert (= (/ 4 3) 1) FAILED: int integer division) +(assert (= (/ 3.0 3.0) 1.0) FAILED: float division A) +(assert (= (/ 3.0 2.0) 1.5) FAILED: float division B) + +;; MODULO +(assert (= (% 3 3) 0) FAILED: modulo A) +(assert (= (% 2 3) 2) FAILED: modulo B) +(assert (= (% 4 3) 1) FAILED: modulo C) +(assert (= (% 9 3) 0) FAILED: modulo D) +(assert (= (% 10 3) 1) FAILED: modulo E) + +;; MIN +(assert (= (min 1 3) 1) FAILED: int min) +(assert (= (min 1 0 -3 9) -3) FAILED: int n>2 min) +(assert (= (min 1.5 2.0) 1.5) FAILED: float min) +(assert (= (min 1.5 1.0 3.0 -1.0) -1.0) FAILED: float n>2 min) + +;; MAX +(assert (= (max 3 1) 3) FAILED: int max) +(assert (= (max 1 0 -3 9) 9) FAILED: int n>2 max) +(assert (= (max 1.5 2.0) 2.0) FAILED: float max) +(assert (= (max 1.5 1.0 3.0 -1.0) 3.0) FAILED: float n>2 max) + +;; CLAMP +(assert (= (clamp 1 3 2) 2) FAILED: int clamp A) +(assert (= (clamp 1 3 4) 3) FAILED: int clamp B) +(assert (= (clamp 1 3 -1) 1) FAILED: int clamp C) +(assert (= (clamp 1 3 1) 1) FAILED: int clamp D) +(assert (= (clamp 1 3 3) 3) FAILED: int clamp E) +(assert (= (clamp 1.5 3.0 1.7) 1.7) FAILED: float clamp A) +(assert (= (clamp 1.5 3.0 4.7) 3.0) FAILED: float clamp B) +(assert (= (clamp 1.5 3.0 -1.7) 1.5) FAILED: float clamp C) +(assert (= (clamp 1.5 3.0 1.5) 1.5) FAILED: float clamp D) +(assert (= (clamp 1.5 3.0 3.0) 3.0) FAILED: float clamp E) + +;; ABS +(assert (= (abs 1) 1) FAILED: int abs A) +(assert (= (abs -1) 1) FAILED: int abs B) +(assert (= (abs -99) 99) FAILED: int abs C) +(assert (= (abs 0) 0) FAILED: int abs D) +(assert (= (abs 1.5) 1.5) FAILED: float abs A) +(assert (= (abs -1.5) 1.5) FAILED: float abs B) +(assert (= (abs -99.5) 99.5) FAILED: float abs C) +(assert (= (abs 0.5) 0.5) FAILED: float abs D) + +;; AND +(assert (= (and (true) (true)) (true)) FAILED: and A) +(assert (= (and (true) (false)) (false)) FAILED: and B) +(assert (= (and (false) (true)) (false)) FAILED: and C) +(assert (= (and (false) (false)) (false)) FAILED: and D) +(assert (= (and (true) (true) (true) (true) (true)) (true)) FAILED: and E) +(assert (= (and (false) (false) (false) (false) (false)) (false)) FAILED: and F) +(assert (= (and (true) (true) (false) (true) (true)) (false)) FAILED: and G) + +;; OR +(assert (= (or (true) (true)) (true)) FAILED: or A) +(assert (= (or (true) (false)) (true)) FAILED: or B) +(assert (= (or (false) (true)) (true)) FAILED: or C) +(assert (= (or (false) (false)) (false)) FAILED: or D) +(assert (= (or (true) (true) (true) (true) (true)) (true)) FAILED: or E) +(assert (= (and (false) (false) (false) (false) (false)) (false)) FAILED: or F) +(assert (= (or (true) (true) (false) (true) (true)) (true)) FAILED: or G) + +;; NOT +(assert (= (not (true)) (false)) FAILED: not A) +(assert (= (not (false)) (true)) FAILED: not B) + +;; IMPLIES +(assert (= (implies (true) (true)) (true)) FAILED: implies A) +(assert (= (implies (true) (false)) (false)) FAILED: implies B) +(assert (= (implies (false) (true)) (true)) FAILED: implies C) +(assert (= (implies (false) (false)) (true)) FAILED: implies D) + +;; ONE IN +(assert (= (one_in (true) (true)) (false)) FAILED: one_in A) +(assert (= (one_in (true) (false)) (true)) FAILED: one_in B) +(assert (= (one_in (false) (true)) (true)) FAILED: one_in C) +(assert (= (one_in (false) (false)) (false)) FAILED: one_in D) +(assert (= (one_in (false) (false) (false) (false)) (false)) FAILED: one_in E) +(assert (= (one_in (false) (true) (false) (false)) (true)) FAILED: one_in F) +(assert (= (one_in (false) (true) (false) (true)) (false)) FAILED: one_in F) + +;; LESS/LOWER THAN +(assert (= (< 1 3) (true)) FAILED: int LOWER/LESS THAN) +(assert (= (< 1 0) (false)) FAILED: int LOWER/LESS THAN) +(assert (= (< 1 1) (false)) FAILED: int LOWER/LESS THAN) +(assert (= (< 1.5 2.0) (true)) FAILED: float LOWER/LESS THAN) +(assert (= (< 1.5 1.0) (false)) FAILED: float LOWER/LESS THAN) +(assert (= (< 1.5 1.5) (false)) FAILED: float LOWER/LESS THAN) + +;; LESS/LOWER EQUAL THAN +(assert (= (=< 1 3) (true)) FAILED: int LOWER/LESS EQUAL THAN) +(assert (= (=< 1 0) (false)) FAILED: int LOWER/LESS EQUAL THAN) +(assert (= (=< 1 1) (true)) FAILED: int LOWER/LESS EQUAL THAN) +(assert (= (=< 1.5 2.0) (true)) FAILED: float LOWER/LESS EQUAL THAN) +(assert (= (=< 1.5 1.0) (false)) FAILED: float LOWER/LESS EQUAL THAN) +(assert (= (=< 1.5 1.5) (true)) FAILED: float LOWER/LESS EQUAL THAN) + +;; GREATER THAN +(assert (= (> 1 3) (false)) FAILED: int GREATER THAN) +(assert (= (> 1 0) (true)) FAILED: int GREATER THAN) +(assert (= (> 1 1) (false)) FAILED: int GREATER THAN) +(assert (= (> 1.5 2.0) (false)) FAILED: float GREATER THAN) +(assert (= (> 1.5 1.0) (true)) FAILED: float GREATER THAN) +(assert (= (> 1.5 1.5) (false)) FAILED: float GREATER THAN) + +;; GREATER EQUAL THAN +(assert (= (>= 1 3) (false)) FAILED: int GREATER EQUAL THAN) +(assert (= (>= 1 0) (true)) FAILED: int GREATER EQUAL THAN) +(assert (= (>= 1 1) (true)) FAILED: int GREATER EQUAL THAN) +(assert (= (>= 1.5 2.0) (false)) FAILED: float GREATER EQUAL THAN) +(assert (= (>= 1.5 1.0) (true)) FAILED: float GREATER EQUAL THAN) +(assert (= (>= 1.5 1.5) (true)) FAILED: float GREATER EQUAL THAN) + +(end) diff --git a/src/core/src/tonkadur/Main.java b/src/core/src/tonkadur/Main.java index cf8a8ae..ea02801 100644 --- a/src/core/src/tonkadur/Main.java +++ b/src/core/src/tonkadur/Main.java @@ -46,7 +46,6 @@ public class Main ); System.out.println("Parsing completed."); - System.out.println(fate_world.toString()); } catch (final Exception e) { @@ -88,15 +87,6 @@ public class Main tp.post_wyrd_compile(wyrd_world); } - for - ( - final tonkadur.wyrd.v1.lang.meta.Instruction line: - wyrd_world.get_code() - ) - { - System.out.println(line.toString()); - } - for (final TonkadurPlugin tp: plugins) { tp.finalize(); diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/Assert.java b/src/core/src/tonkadur/fate/v1/lang/instruction/Assert.java index 2770fa1..7869ab4 100644 --- a/src/core/src/tonkadur/fate/v1/lang/instruction/Assert.java +++ b/src/core/src/tonkadur/fate/v1/lang/instruction/Assert.java @@ -12,6 +12,7 @@ import tonkadur.fate.v1.lang.type.Type; import tonkadur.fate.v1.lang.meta.InstructionVisitor; import tonkadur.fate.v1.lang.meta.Instruction; +import tonkadur.fate.v1.lang.meta.RichTextNode; import tonkadur.fate.v1.lang.meta.Computation; public class Assert extends Instruction @@ -20,6 +21,7 @@ public class Assert extends Instruction /**** MEMBERS **************************************************************/ /***************************************************************************/ protected final Computation condition; + protected final RichTextNode message; /***************************************************************************/ /**** PROTECTED ************************************************************/ @@ -28,12 +30,14 @@ public class Assert extends Instruction protected Assert ( final Origin origin, - final Computation condition + final Computation condition, + final RichTextNode message ) { super(origin); this.condition = condition; + this.message = message; } /***************************************************************************/ @@ -43,7 +47,8 @@ public class Assert extends Instruction public static Assert build ( final Origin origin, - final Computation condition + final Computation condition, + final RichTextNode message ) throws InvalidTypeException { @@ -60,7 +65,7 @@ public class Assert extends Instruction ); } - return new Assert(origin, condition); + return new Assert(origin, condition, message); } /**** Accessors ************************************************************/ @@ -76,6 +81,11 @@ public class Assert extends Instruction return condition; } + public RichTextNode get_message () + { + return message; + } + /**** Misc. ****************************************************************/ @Override public String toString () diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/ReverseList.java b/src/core/src/tonkadur/fate/v1/lang/instruction/ReverseList.java index e69de29..59a68e6 100644 --- a/src/core/src/tonkadur/fate/v1/lang/instruction/ReverseList.java +++ b/src/core/src/tonkadur/fate/v1/lang/instruction/ReverseList.java @@ -0,0 +1,101 @@ +package tonkadur.fate.v1.lang.instruction; + +import java.util.Collections; + +import tonkadur.error.ErrorManager; + +import tonkadur.parser.Origin; + +import tonkadur.fate.v1.error.InvalidTypeException; + +import tonkadur.fate.v1.lang.type.CollectionType; +import tonkadur.fate.v1.lang.type.Type; + +import tonkadur.fate.v1.lang.meta.InstructionVisitor; +import tonkadur.fate.v1.lang.meta.Instruction; +import tonkadur.fate.v1.lang.meta.Computation; + +public class ReverseList extends Instruction +{ + /***************************************************************************/ + /**** MEMBERS **************************************************************/ + /***************************************************************************/ + protected final Computation collection; + + /***************************************************************************/ + /**** PROTECTED ************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + protected ReverseList + ( + final Origin origin, + final Computation collection + ) + { + super(origin); + + this.collection = collection; + } + + /***************************************************************************/ + /**** PUBLIC ***************************************************************/ + /***************************************************************************/ + /**** Constructors *********************************************************/ + public static ReverseList build + ( + final Origin origin, + final Computation collection + ) + throws InvalidTypeException + { + final Type t; + + t = collection.get_type(); + + if + ( + !(t instanceof CollectionType) + || ((CollectionType) t).is_set() + ) + { + ErrorManager.handle + ( + new InvalidTypeException + ( + collection.get_origin(), + collection.get_type(), + Collections.singleton(Type.LIST) + ) + ); + } + + return new ReverseList(origin, collection); + } + + /**** Accessors ************************************************************/ + @Override + public void get_visited_by (final InstructionVisitor iv) + throws Throwable + { + iv.visit_reverse_list(this); + } + + public Computation get_collection () + { + return collection; + } + + /**** Misc. ****************************************************************/ + @Override + public String toString () + { + final StringBuilder sb = new StringBuilder(); + + sb.append("(ReverseList "); + sb.append(collection.toString()); + + sb.append(")"); + + return sb.toString(); + } +} diff --git a/src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java b/src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java index 41167bb..3f4f973 100644 --- a/src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java +++ b/src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java @@ -38,6 +38,9 @@ public interface InstructionVisitor public void visit_clear (final Clear c) throws Throwable; + public void visit_reverse_list (final ReverseList n) + throws Throwable; + public void visit_cond_instruction (final CondInstruction ci) throws Throwable; diff --git a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 index ca10603..2759c92 100644 --- a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 +++ b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 @@ -14,6 +14,7 @@ L_PAREN: '('; R_PAREN: ')'; +ABS_KW: L_PAREN 'abs'('olute'?) SEP+; ACCESS_KW: L_PAREN 'access' SEP+; ADD_KW: L_PAREN 'add' SEP+; AND_KW: L_PAREN ('and'|'/\\') SEP+; @@ -63,6 +64,9 @@ IS_MEMBER_KW: L_PAREN ('is'US'member'|'contains'|'has') SEP+; LOWER_EQUAL_THAN_KW: L_PAREN ('lower'US'equal'US'than'|'=<'|'<='|'le') SEP+; LOWER_THAN_KW: L_PAREN ('lower'US'than'|'<'|'lt') SEP+; MINUS_KW: L_PAREN ('minus'|'-') SEP+; +MIN_KW: L_PAREN ('min'('imum'?)) SEP+; +MAX_KW: L_PAREN ('max'('imum'?)) SEP+; +CLAMP_KW: L_PAREN ('clamp') SEP+; MODULO_KW: L_PAREN ('modulo'|'%'|'mod') SEP+; NEWLINE_KW: L_PAREN 'newline)'; NEW_KW: L_PAREN ('new'|'reserve'|'create') SEP+; diff --git a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 index c8e42a6..ecf0c0d 100644 --- a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 +++ b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 @@ -847,6 +847,7 @@ returns [Instruction result] elem_type = Type.ANY; } + /* TODO: error if there is already a parameter with that name */ PARAMETERS.add ( CONTEXT.get_origin_at @@ -967,7 +968,7 @@ returns [Instruction result] $result = new SequenceCall(origin, sequence_name); } - | ASSERT_KW value WS* R_PAREN + | ASSERT_KW value WS+ paragraph WS* R_PAREN { $result = Assert.build @@ -977,7 +978,8 @@ returns [Instruction result] ($ASSERT_KW.getLine()), ($ASSERT_KW.getCharPositionInLine()) ), - ($value.result) + ($value.result), + ($paragraph.result) ); } @@ -1910,6 +1912,66 @@ returns [Computation result]: ); } + | MIN_KW value_list WS* R_PAREN + { + $result = + Operation.build + ( + CONTEXT.get_origin_at + ( + ($MIN_KW.getLine()), + ($MIN_KW.getCharPositionInLine()) + ), + Operator.MIN, + ($value_list.result) + ); + } + + | MAX_KW value_list WS* R_PAREN + { + $result = + Operation.build + ( + CONTEXT.get_origin_at + ( + ($MAX_KW.getLine()), + ($MAX_KW.getCharPositionInLine()) + ), + Operator.MAX, + ($value_list.result) + ); + } + + | CLAMP_KW value_list WS* R_PAREN + { + $result = + Operation.build + ( + CONTEXT.get_origin_at + ( + ($CLAMP_KW.getLine()), + ($CLAMP_KW.getCharPositionInLine()) + ), + Operator.CLAMP, + ($value_list.result) + ); + } + + | ABS_KW value_list WS* R_PAREN + { + $result = + Operation.build + ( + CONTEXT.get_origin_at + ( + ($ABS_KW.getLine()), + ($ABS_KW.getCharPositionInLine()) + ), + Operator.ABS, + ($value_list.result) + ); + } + | MODULO_KW value_list WS* R_PAREN { $result = diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/Compiler.java b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/Compiler.java index 4a315e1..037a705 100644 --- a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/Compiler.java +++ b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/Compiler.java @@ -3,6 +3,7 @@ package tonkadur.wyrd.v1.compiler.fate.v1; import tonkadur.wyrd.v1.compiler.util.AnonymousVariableManager; import tonkadur.wyrd.v1.compiler.util.InstructionManager; +import tonkadur.wyrd.v1.lang.Variable; import tonkadur.wyrd.v1.lang.World; public class Compiler @@ -32,6 +33,8 @@ public class Compiler compiler.compile_sequences(fate_world); + compiler.add_anonymous_variables(); + return compiler.wyrd_world; } @@ -116,6 +119,15 @@ public class Compiler ); } + protected void add_anonymous_variables () + throws Throwable + { + for (final Variable variable: anonymous_variables.get_all_variables()) + { + wyrd_world.add_variable(variable); + } + } + public World world () { return wyrd_world; diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java index f3e5ae1..c9740f8 100644 --- a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java +++ b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java @@ -858,7 +858,7 @@ implements tonkadur.fate.v1.lang.meta.ComputationVisitor { final Computation zero, minus_one; - if (operands.get(2).get_type().equals(Type.INT)) + if (operands.get(0).get_type().equals(Type.INT)) { zero = Constant.ZERO; minus_one = new Constant(Type.INT, "-1"); diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java index b4c0e38..d05a280 100644 --- a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java +++ b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java @@ -14,6 +14,7 @@ import tonkadur.wyrd.v1.lang.meta.Computation; import tonkadur.wyrd.v1.lang.meta.Instruction; import tonkadur.wyrd.v1.lang.type.Type; +import tonkadur.wyrd.v1.lang.type.MapType; import tonkadur.wyrd.v1.lang.computation.Cast; import tonkadur.wyrd.v1.lang.computation.Constant; @@ -44,6 +45,7 @@ import tonkadur.wyrd.v1.compiler.util.While; import tonkadur.wyrd.v1.compiler.util.Clear; import tonkadur.wyrd.v1.compiler.util.IterativeSearch; import tonkadur.wyrd.v1.compiler.util.RemoveAllOf; +import tonkadur.wyrd.v1.compiler.util.ReverseList; import tonkadur.wyrd.v1.compiler.util.RemoveAt; public class InstructionCompiler @@ -275,20 +277,31 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor * * Wyrd: (assert Computation) */ - final ComputationCompiler cc; + final ComputationCompiler cond_cc, msg_cc; - cc = new ComputationCompiler(compiler); + cond_cc = new ComputationCompiler(compiler); + msg_cc = new ComputationCompiler(compiler); - a.get_condition().get_visited_by(cc); + a.get_condition().get_visited_by(cond_cc); + a.get_message().get_visited_by(msg_cc); - if (cc.has_init()) + if (cond_cc.has_init()) { - result.add(cc.get_init()); + result.add(cond_cc.get_init()); } - result.add(new Assert(cc.get_computation())); + if (msg_cc.has_init()) + { + result.add(msg_cc.get_init()); + } - cc.release_variables(); + result.add + ( + new Assert(cond_cc.get_computation(), msg_cc.get_computation()) + ); + + cond_cc.release_variables(); + msg_cc.release_variables(); } @Override @@ -328,6 +341,45 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor reference_compiler.release_variables(); } + public void visit_reverse_list + ( + final tonkadur.fate.v1.lang.instruction.ReverseList n + ) + throws Throwable + { + /* + * Fate: (reverse_list collection) + * + * Wyrd: + */ + final ComputationCompiler reference_compiler; + final Ref collection_ref; + + reference_compiler = new ComputationCompiler(compiler); + + n.get_collection().get_visited_by(reference_compiler); + + collection_ref = reference_compiler.get_ref(); + + if (reference_compiler.has_init()) + { + result.add(reference_compiler.get_init()); + } + + result.add + ( + ReverseList.generate + ( + compiler.anonymous_variables(), + compiler.assembler(), + new Size(collection_ref), + collection_ref + ) + ); + + reference_compiler.release_variables(); + } + @Override public void visit_switch_instruction ( @@ -374,7 +426,9 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor Computation value_of_anon; List current_branch, previous_else_branch; - branches = new ArrayList(n.get_branches()); // shallow copy. + branches = new ArrayList<>(n.get_branches()); // shallow copy. + + Collections.reverse(branches); previous_else_branch = new ArrayList(); @@ -415,6 +469,7 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor cc = new ComputationCompiler(compiler); branch.get_car().get_visited_by(cc); + branch.get_cdr().get_visited_by(ic); if (cc.has_init()) { @@ -664,13 +719,17 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor { result.add ( - While.generate + compiler.assembler().mark_after ( - compiler.anonymous_variables(), - compiler.assembler(), - cc.get_init(), - cc.get_computation(), - compiler.assembler().merge(body) + While.generate + ( + compiler.anonymous_variables(), + compiler.assembler(), + cc.get_init(), + cc.get_computation(), + compiler.assembler().merge(body) + ), + end_of_loop_label ) ); } @@ -678,12 +737,16 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor { result.add ( - While.generate + compiler.assembler().mark_after ( - compiler.anonymous_variables(), - compiler.assembler(), - cc.get_computation(), - compiler.assembler().merge(body) + While.generate + ( + compiler.anonymous_variables(), + compiler.assembler(), + cc.get_computation(), + compiler.assembler().merge(body) + ), + end_of_loop_label ) ); } @@ -697,15 +760,107 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor throws Throwable { final String end_of_loop_label; + final ComputationCompiler cc; + final List new_body; + final Ref index, current_value, collection_size; + final Ref collection; + final Computation value_of_index; + final Type member_type; - end_of_loop_label = - compiler.assembler().generate_label(""); + cc = new ComputationCompiler(compiler); + new_body = new ArrayList(); + + index = compiler.anonymous_variables().reserve(Type.INT); + collection_size = compiler.anonymous_variables().reserve(Type.INT); + + result.add(new SetValue(index, Constant.ZERO)); + + n.get_collection().get_visited_by(cc); + + if (cc.has_init()) + { + result.add(cc.get_init()); + } + + collection = cc.get_ref(); + + result.add(new SetValue(collection_size, new Size(collection))); + + value_of_index = new ValueOf(index); + + member_type = ((MapType) collection.get_target_type()).get_member_type(); + + current_value = compiler.anonymous_variables().reserve(member_type); + + end_of_loop_label = compiler.assembler().generate_label(""); compiler.assembler().push_context_label("breakable", end_of_loop_label); + compiler.macros().add_wild_parameter + ( + n.get_parameter_name(), + current_value + ); + + for + ( + final tonkadur.fate.v1.lang.meta.Instruction fate_instr: n.get_body() + ) + { + final InstructionCompiler ic; + + ic = new InstructionCompiler(compiler); - /* TODO */ + fate_instr.get_visited_by(ic); + new_body.add(ic.get_result()); + } + + new_body.add + ( + new SetValue + ( + current_value, + new ValueOf + ( + new RelativeRef + ( + collection, + new Cast(value_of_index, Type.STRING), + member_type + ) + ) + ) + ); + + new_body.add + ( + new SetValue(index, Operation.plus(Constant.ONE, value_of_index)) + ); + + result.add + ( + compiler.assembler().mark_after + ( + While.generate + ( + compiler.anonymous_variables(), + compiler.assembler(), + Operation.less_than + ( + value_of_index, + new ValueOf(collection_size) + ), + compiler.assembler.merge(new_body) + ), + end_of_loop_label + ) + ); + compiler.macros().remove_wild_parameter(n.get_parameter_name()); compiler.assembler().pop_context_label("breakable"); + + compiler.anonymous_variables().release(index); + compiler.anonymous_variables().release(current_value); + compiler.anonymous_variables().release(collection_size); } @Override @@ -1113,11 +1268,9 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor * Wyrd (add_choice label i0) */ final ComputationCompiler cc; - final InstructionCompiler ic; final String start_of_effect, end_of_effect; cc = new ComputationCompiler(compiler); - ic = new InstructionCompiler(compiler); start_of_effect = compiler.assembler().generate_label(""); end_of_effect = compiler.assembler().generate_label(""); @@ -1155,7 +1308,7 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor n.get_effects() ) { - fate_instruction.get_visited_by(ic); + fate_instruction.get_visited_by(this); } result.add diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/MacroManager.java b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/MacroManager.java index 085524a..fe2ab67 100644 --- a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/MacroManager.java +++ b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/MacroManager.java @@ -10,13 +10,30 @@ import tonkadur.wyrd.v1.lang.computation.Ref; public class MacroManager { + protected final Map wild_parameters; protected final Stack> context_stack; public MacroManager () { + wild_parameters = new HashMap(); context_stack = new Stack>(); } + public void add_wild_parameter (final String name, final Ref ref) + { + if (wild_parameters.containsKey(name)) + { + System.err.println("[P] duplicate wild parameter '" + name + "'."); + + return; + } + } + + public void remove_wild_parameter (final String name) + { + wild_parameters.remove(name); + } + public void pop () { context_stack.pop(); @@ -51,13 +68,18 @@ public class MacroManager public Ref get_parameter_ref (final String parameter) { - final Ref result; + Ref result; - result = context_stack.peek().get(parameter); + result = wild_parameters.get(parameter); if (result == null) { - System.err.println("[P] No such parameter '" + parameter + "'."); + result = context_stack.peek().get(parameter); + + if (result == null) + { + System.err.println("[P] No such parameter '" + parameter + "'."); + } } return result; diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/util/AnonymousVariableManager.java b/src/core/src/tonkadur/wyrd/v1/compiler/util/AnonymousVariableManager.java index df0da53..8bec40a 100644 --- a/src/core/src/tonkadur/wyrd/v1/compiler/util/AnonymousVariableManager.java +++ b/src/core/src/tonkadur/wyrd/v1/compiler/util/AnonymousVariableManager.java @@ -2,6 +2,7 @@ package tonkadur.wyrd.v1.compiler.util; import java.util.Map; import java.util.HashMap; +import java.util.Collection; import java.util.List; import java.util.ArrayList; @@ -32,6 +33,20 @@ public class AnonymousVariableManager generated_variables = 0; } + public Collection get_all_variables () + { + final Collection result; + + result = new ArrayList(); + + for (final Cons variable: by_name.values()) + { + result.add(variable.get_cdr()); + } + + return result; + } + public Ref reserve (final Type t) { final String name; diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/util/RemoveAt.java b/src/core/src/tonkadur/wyrd/v1/compiler/util/RemoveAt.java index 55f5f02..5fc7489 100644 --- a/src/core/src/tonkadur/wyrd/v1/compiler/util/RemoveAt.java +++ b/src/core/src/tonkadur/wyrd/v1/compiler/util/RemoveAt.java @@ -90,7 +90,7 @@ public class RemoveAt /* (set .next (+ (val index) 1)) */ while_body.add ( - new SetValue(next, Operation.plus(value_of_end, Constant.ONE)) + new SetValue(next, Operation.plus(value_of_index, Constant.ONE)) ); /* (set collection[index] (val collection[.next])) */ diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/util/ReverseList.java b/src/core/src/tonkadur/wyrd/v1/compiler/util/ReverseList.java new file mode 100644 index 0000000..226e86a --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/compiler/util/ReverseList.java @@ -0,0 +1,152 @@ +package tonkadur.wyrd.v1.compiler.util; + +import java.util.List; +import java.util.ArrayList; +import java.util.Collections; + +import tonkadur.wyrd.v1.lang.type.Type; +import tonkadur.wyrd.v1.lang.type.MapType; + +import tonkadur.wyrd.v1.lang.meta.Instruction; +import tonkadur.wyrd.v1.lang.meta.Computation; + +import tonkadur.wyrd.v1.lang.computation.Cast; +import tonkadur.wyrd.v1.lang.computation.Constant; +import tonkadur.wyrd.v1.lang.computation.Operation; +import tonkadur.wyrd.v1.lang.computation.Ref; +import tonkadur.wyrd.v1.lang.computation.RelativeRef; +import tonkadur.wyrd.v1.lang.computation.ValueOf; + +import tonkadur.wyrd.v1.lang.instruction.SetValue; + +public class ReverseList +{ + /* Utility Class */ + private ReverseList () {} + + /* + * (Computation int collection_size) + * (declare_variable global collection) + * + * (declare_variable E .buffer + * (declare_variable int .top) + * (declare_variable int .bot) + * + * (set .top (- (collection_size) 1)) + * (set .bot 0) + * + * (while (< (var .bot) (var .top)) + * (set .buffer collection[.top]) + * (set collection[.top] collection[.bot]) + * (set collection[.bot] .buffer) + * (set .bot (+ 1 (var .bot))) + * (set .top (- 1 (var .top))) + * ) + */ + public static Instruction generate + ( + final AnonymousVariableManager anonymous_variables, + final InstructionManager assembler, + final Computation collection_size, + final Ref collection + ) + { + final List result, while_body; + final Type element_type; + final Ref buffer, top, bot; + final Computation value_of_top, value_of_bot; + final Ref collection_at_top, collection_at_bot; + + result = new ArrayList(); + while_body = new ArrayList(); + + element_type = + ((MapType) collection.get_target_type()).get_member_type(); + + buffer = anonymous_variables.reserve(element_type); + top = anonymous_variables.reserve(Type.INT); + bot = anonymous_variables.reserve(Type.INT); + + value_of_top = new ValueOf(top); + value_of_bot = new ValueOf(bot); + + collection_at_top = + new RelativeRef + ( + collection, + new Cast(value_of_top, Type.STRING), + element_type + ); + + collection_at_bot = + new RelativeRef + ( + collection, + new Cast(value_of_bot, Type.STRING), + element_type + ); + + /* (set .top (- (collection_size) 1)) */ + result.add + ( + new SetValue(top, Operation.minus(collection_size, Constant.ONE)) + ); + + /* (set .bot 0) */ + result.add(new SetValue(bot, Constant.ZERO)); + + + /* (set .buffer collection[.top]) */ + while_body.add(new SetValue(buffer, new ValueOf(collection_at_top))); + + /* (set collection[.top] collection[.bot]) */ + while_body.add + ( + new SetValue(collection_at_top, new ValueOf(collection_at_bot)) + ); + + /* (set collection[.bot] .buffer) */ + while_body.add + ( + new SetValue(collection_at_bot, new ValueOf(buffer)) + ); + + /* (set .bot (+ 1 (var .bot))) */ + while_body.add + ( + new SetValue(bot, Operation.plus(Constant.ONE, value_of_bot)) + ); + + /* (set .top (- 1 (var .top))) */ + while_body.add + ( + new SetValue(top, Operation.minus(Constant.ONE, value_of_top)) + ); + + /* + * (while (< (var .bot) (var .top)) + * (set .buffer collection[.top]) + * (set collection[.top] collection[.bot]) + * (set collection[.bot] .buffer) + * (set .bot (+ 1 (var .bot))) + * (set .top (- 1 (var .top))) + * ) + */ + result.add + ( + While.generate + ( + anonymous_variables, + assembler, + Operation.less_than(value_of_bot, value_of_top), + assembler.merge(while_body) + ) + ); + + anonymous_variables.release(buffer); + anonymous_variables.release(top); + anonymous_variables.release(bot); + + return assembler.merge(result); + } +} diff --git a/src/core/src/tonkadur/wyrd/v1/lang/instruction/Assert.java b/src/core/src/tonkadur/wyrd/v1/lang/instruction/Assert.java index 7bfa25b..57dd7c1 100644 --- a/src/core/src/tonkadur/wyrd/v1/lang/instruction/Assert.java +++ b/src/core/src/tonkadur/wyrd/v1/lang/instruction/Assert.java @@ -10,14 +10,16 @@ public class Assert extends Instruction /**** MEMBERS **************************************************************/ /***************************************************************************/ protected final Computation condition; + protected final Computation message; /***************************************************************************/ /**** PUBLIC ***************************************************************/ /***************************************************************************/ /**** Constructors *********************************************************/ - public Assert (final Computation condition) + public Assert (final Computation condition, final Computation message) { this.condition = condition; + this.message = message; } /**** Accessors ************************************************************/ @@ -26,6 +28,11 @@ public class Assert extends Instruction return condition; } + public Computation get_message () + { + return message; + } + @Override public void get_visited_by (final InstructionVisitor iv) throws Throwable @@ -43,6 +50,8 @@ public class Assert extends Instruction sb.append("(Assert "); sb.append(condition.toString()); + sb.append(" "); + sb.append(message.toString()); sb.append(")"); return sb.toString(); diff --git a/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java b/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java index 00445c7..8f7913b 100644 --- a/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java +++ b/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java @@ -33,16 +33,19 @@ public class InstructionCompiler implements InstructionVisitor public void visit_assert (final Assert n) throws Throwable { - final ComputationCompiler cc; + final ComputationCompiler cond_cc, msg_cc; - cc = new ComputationCompiler(); + cond_cc = new ComputationCompiler(); + msg_cc = new ComputationCompiler(); - n.get_condition().get_visited_by(cc); + n.get_condition().get_visited_by(cond_cc); + n.get_message().get_visited_by(msg_cc); result = new JSONObject(); result.put("category", "assert"); - result.put("condition", cc.get_result()); + result.put("condition", cond_cc.get_result()); + result.put("message", msg_cc.get_result()); } public void visit_display (final Display n) diff --git a/src/json-export/src/tonkadur/jsonexport/Translator.java b/src/json-export/src/tonkadur/jsonexport/Translator.java index edd0a7f..cc22e7c 100644 --- a/src/json-export/src/tonkadur/jsonexport/Translator.java +++ b/src/json-export/src/tonkadur/jsonexport/Translator.java @@ -36,9 +36,6 @@ public class Translator out = new PrintWriter(output_file); out.println(result.toJSONString()); out.close(); - - System.out.println("JSON Result:"); - System.out.println(result.toJSONString()); } public static JSONArray get_compiled_variables (final World wyrd_world) -- cgit v1.2.3-70-g09d2