summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-12-05 02:04:24 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-12-05 02:04:24 +0100
commitd597bdec8c47fd388fb056f6a3238be23bd509b6 (patch)
tree03ac33936d77aa1fbe627fabdddfab0800acc3f2 /src/core
parent2ec3d993e86f64db38df970dbccfa2eacbc86de4 (diff)
Working on the merge operator...
Diffstat (limited to 'src/core')
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/FateLexer.g46
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/FateParser.g436
-rw-r--r--src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java2
-rw-r--r--src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java14
4 files changed, 37 insertions, 21 deletions
diff --git a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
index c2ed078..10bb692 100644
--- a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
+++ b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
@@ -98,6 +98,12 @@ INDEXED_MERGE_TO_LIST_KW : L_PAREN 'indexed'US'merge'US'to'US'list' SEP+;
INDEXED_MERGE_TO_SET_KW : L_PAREN 'indexed'US'merge'US'to'US'set' SEP+;
IMP_MERGE_KW : L_PAREN 'merge!' SEP+;
IMP_INDEXED_MERGE_KW : L_PAREN 'indexed'US'merge!' SEP+;
+SAFE_MERGE_TO_LIST_KW : L_PAREN 'safe'US'merge'US'to'US'list' SEP+;
+SAFE_MERGE_TO_SET_KW : L_PAREN 'safe'US'merge'US'to'US'set' SEP+;
+SAFE_INDEXED_MERGE_TO_LIST_KW : L_PAREN (('safe'US'indexed')|('indexed'US'safe'))US'merge'US'to'US'list' SEP+;
+SAFE_INDEXED_MERGE_TO_SET_KW : L_PAREN (('safe'US'indexed')|('indexed'US'safe'))US'merge'US'to'US'set' SEP+;
+SAFE_IMP_MERGE_KW : L_PAREN 'safe'US'merge!' SEP+;
+SAFE_IMP_INDEXED_MERGE_KW : L_PAREN (('indexed'US'safe')|('safe'US'indexed'))US'merge!' SEP+;
NEWLINE_KW: L_PAREN 'newline)';
NEW_KW: L_PAREN ('new'|'reserve'|'create') SEP+;
NOT_KW: L_PAREN ('not'|'~'|'!') SEP+;
diff --git a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
index 2ea8bc4..4d791e3 100644
--- a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
+++ b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
@@ -1044,7 +1044,7 @@ returns [Instruction result]
);
}
- | IMP_MERGE_KW
+ | SAFE_IMP_MERGE_KW
fun=non_text_value WS+
def0=value WS+
value_reference WS+
@@ -1057,8 +1057,8 @@ returns [Instruction result]
(
CONTEXT.get_origin_at
(
- ($IMP_MERGE_KW.getLine()),
- ($IMP_MERGE_KW.getCharPositionInLine())
+ ($SAFE_IMP_MERGE_KW.getLine()),
+ ($SAFE_IMP_MERGE_KW.getCharPositionInLine())
),
($fun.result),
($value_reference.result),
@@ -1069,7 +1069,7 @@ returns [Instruction result]
);
}
- | IMP_MERGE_KW
+ | SAFE_IMP_MERGE_KW
fun=non_text_value WS+
def0=value WS+
value_reference WS+
@@ -1083,8 +1083,8 @@ returns [Instruction result]
(
CONTEXT.get_origin_at
(
- ($IMP_MERGE_KW.getLine()),
- ($IMP_MERGE_KW.getCharPositionInLine())
+ ($SAFE_IMP_MERGE_KW.getLine()),
+ ($SAFE_IMP_MERGE_KW.getCharPositionInLine())
),
($fun.result),
($value_reference.result),
@@ -4392,7 +4392,7 @@ returns [Computation result]
);
}
- | MERGE_TO_LIST_KW
+ | SAFE_MERGE_TO_LIST_KW
fun=non_text_value WS+
def0=value WS+
inv0=non_text_value WS+
@@ -4405,8 +4405,8 @@ returns [Computation result]
(
CONTEXT.get_origin_at
(
- ($MERGE_TO_LIST_KW.getLine()),
- ($MERGE_TO_LIST_KW.getCharPositionInLine())
+ ($SAFE_MERGE_TO_LIST_KW.getLine()),
+ ($SAFE_MERGE_TO_LIST_KW.getCharPositionInLine())
),
($fun.result),
($inv0.result),
@@ -4418,7 +4418,7 @@ returns [Computation result]
);
}
- | MERGE_TO_LIST_KW
+ | SAFE_MERGE_TO_LIST_KW
fun=non_text_value WS+
def0=value WS+
inv0=non_text_value WS+
@@ -4432,8 +4432,8 @@ returns [Computation result]
(
CONTEXT.get_origin_at
(
- ($MERGE_TO_LIST_KW.getLine()),
- ($MERGE_TO_LIST_KW.getCharPositionInLine())
+ ($SAFE_MERGE_TO_LIST_KW.getLine()),
+ ($SAFE_MERGE_TO_LIST_KW.getCharPositionInLine())
),
($fun.result),
($inv0.result),
@@ -4539,7 +4539,7 @@ returns [Computation result]
);
}
- | MERGE_TO_SET_KW
+ | SAFE_MERGE_TO_SET_KW
fun=non_text_value WS+
def0=value WS+
inv0=non_text_value WS+
@@ -4552,8 +4552,8 @@ returns [Computation result]
(
CONTEXT.get_origin_at
(
- ($MERGE_TO_SET_KW.getLine()),
- ($MERGE_TO_SET_KW.getCharPositionInLine())
+ ($SAFE_MERGE_TO_SET_KW.getLine()),
+ ($SAFE_MERGE_TO_SET_KW.getCharPositionInLine())
),
($fun.result),
($inv0.result),
@@ -4565,7 +4565,7 @@ returns [Computation result]
);
}
- | MERGE_TO_SET_KW
+ | SAFE_MERGE_TO_SET_KW
fun=non_text_value WS+
def0=value WS+
inv0=non_text_value WS+
@@ -4579,8 +4579,8 @@ returns [Computation result]
(
CONTEXT.get_origin_at
(
- ($MERGE_TO_SET_KW.getLine()),
- ($MERGE_TO_SET_KW.getCharPositionInLine())
+ ($SAFE_MERGE_TO_SET_KW.getLine()),
+ ($SAFE_MERGE_TO_SET_KW.getCharPositionInLine())
),
($fun.result),
($inv0.result),
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 2587769..9fb288d 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
@@ -2951,7 +2951,7 @@ implements tonkadur.fate.v1.lang.meta.ComputationVisitor
)
throws Throwable
{
- if (n.get_default_a() == null)
+ if (n.get_default_a() != null)
{
visit_merge_with_defaults(n);
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 147f2f1..2f82d3c 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
@@ -890,10 +890,9 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor
)
throws Throwable
{
- /* TODO: handle default values. */
/* This is one dangerous operation to do in-place, so we don't. */
- if (n.get_default_a() == null)
+ if (n.get_default_a() != null)
{
visit_merge_with_defaults(n);
return;
@@ -938,6 +937,17 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor
new SetValue(holder.get_address(), collection_cc.get_computation())
);
+ result.add
+ (
+ Clear.generate
+ (
+ compiler.registers(),
+ compiler.assembler(),
+ collection_cc.get_address()
+ )
+ );
+
+
in_collection_b_cc = new ComputationCompiler(compiler);
n.get_collection_in_b().get_visited_by(in_collection_b_cc);