Skip to content

Commit

Permalink
Fix parsing of boolstructs and rules that have GIVETH but no GIVEN
Browse files Browse the repository at this point in the history
  • Loading branch information
joewatt95 committed Apr 3, 2024
1 parent f049120 commit 2528148
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/l4_lp/syntax/l4_to_prolog.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@
rewrite and transform each node."
(r/top-down
(r/rewrite
(m/or (!xs ... GIVETH . !xs ...)
(!xs ... OTHERWISE))
(GIVETH !giveths ..1 DECIDE & ?horn-clause)
((GIVEN & (!giveths ...) DECIDE & ?horn-clause))

(m/or (!xs ..1 GIVETH . !xs ..1)
(!xs ..1 OTHERWISE))
((!xs ...))

(GIVEN
Expand Down Expand Up @@ -88,7 +91,9 @@
(DECIDE . !head ..1) ((!head ...))

(m/with
[%xs (m/seqable !xs ..1 (m/pred #{'AND 'OR} !bool-op) & %xs)]
[%bool-op (m/pred #{'AND 'OR} !bool-op)
%xs (m/or (m/seqable !xs ..1 %bool-op & %xs)
(m/seqable !xs ..1 %bool-op))]
(m/seqable & %xs . !x ..1))

((!xs ...) !bool-op ... (!x ...))
Expand Down
4 changes: 3 additions & 1 deletion src/l4_lp/webeditor/main.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
;; - The whole pipeline, from parsing and transpilation to evaluation and processing of
;; traces, runs directly in the browser.
GIVETH x
DECIDE query
WHEN MIN 0 (SUM 1 2) < PRODUCT (MAX 3 4) 5
WHEN x > 0
AND MIN 0 (SUM 1 2) < PRODUCT (MAX 3 4) x
GIVEN (x IS A Number)
DECIDE x is between 0 and 10 or is 100
Expand Down

0 comments on commit 2528148

Please sign in to comment.