Support the destructuring & syntax in queries

This commit is contained in:
Jeremy Dormitzer 2019-07-20 14:38:21 -04:00
parent 46db76253a
commit d05d055ec3

View File

@ -54,6 +54,10 @@
;; If the patterns are already equal, the frame already ;; If the patterns are already equal, the frame already
;; has the correct bindings ;; has the correct bindings
(= pattern1 pattern2) frame (= pattern1 pattern2) frame
;; If pattern1 is a rest-pattern (e.g. [& ?rest]), unify its rest
;; part with pattern2 in the current frame
(and (sequential? pattern1) (= (first pattern1) '&))
(unify-match (second pattern1) pattern2 frame)
;; If pattern1 is a variable, try to bind it to pattern2 ;; If pattern1 is a variable, try to bind it to pattern2
(var? pattern1) (extend-if-possible pattern1 pattern2 frame) (var? pattern1) (extend-if-possible pattern1 pattern2 frame)
;; If pattern1 is not a variable but pattern2 is, try to bind ;; If pattern1 is not a variable but pattern2 is, try to bind