Skip to content

Commit

Permalink
Merge pull request #383 from EvgSkv/ti2023
Browse files Browse the repository at this point in the history
Automatically include stop as satellite.
  • Loading branch information
EvgSkv authored Sep 27, 2024
2 parents 7ad2da9 + 564219e commit f84bddb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
7 changes: 7 additions & 0 deletions compiler/universe.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,15 @@ def InscribeOrbits(self, rules, depth_map):
# satellites. You are responsible for those whom you tamed.
master = {}
for p, args in depth_map.items():
satellite_names = []
for s in args.get('satellites', []):
master[s['predicate_name']] = p
satellite_names.append(s['predicate_name'])
if stop_predicate := args.get('stop', None):
if stop_predicate['predicate_name'] not in satellite_names:
if 'satellites' not in args:
args['satellites'] = []
args['satellites'] += [stop_predicate]
for r in rules:
p = r['head']['predicate_name']
if p in depth_map:
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/duckdb_stop_test.l
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

@Engine("duckdb");

@Recursive(N, 100, stop: S);
N() = 0 :- ~S() || true;
@Recursive(N, -1, stop: S);
N() = 0 :- ~N();
N() = N() + 1;

S("yes") :- N() > 10;

Test(!~ (N() > 10), !~ (N() < 20));
Test(!~ (N() > 10), !~ (N() < 20), Array{n -> n :- n = N()});
10 changes: 5 additions & 5 deletions integration_tests/duckdb_stop_test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
+------+------+
| col0 | col1 |
+------+------+
| True | True |
+------+------+
+------+------+------+
| col0 | col1 | col2 |
+------+------+------+
| True | True | [14] |
+------+------+------+

0 comments on commit f84bddb

Please sign in to comment.