From: Eshel Yaron Date: Fri, 21 Oct 2022 09:09:08 +0000 (+0300) Subject: Handle operators that contain '.' more reliably X-Git-Tag: V8.5.20-sweep-0.8.0~3 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e86b1faebd7d6a047d9650e849d60bc3eee04638;p=sweep.git Handle operators that contain '.' more reliably --- diff --git a/sweeprolog-tests.el b/sweeprolog-tests.el index f3a7d5e..a51afcc 100644 --- a/sweeprolog-tests.el +++ b/sweeprolog-tests.el @@ -6,7 +6,7 @@ "Hello from Elisp from Prolog from Elisp from Prolog from Elisp!") (defun sweeprolog-tests-greet () - (sweeprolog-open-query "user" "user" + (sweeprolog--open-query "user" "user" "sweep_funcall" "sweeprolog-tests-greet-1") (let ((sol (sweeprolog-next-solution))) @@ -18,7 +18,7 @@ (ert-deftest elisp->prolog->elisp->prolog->elisp () "Tests calling Elisp from Prolog from Elisp from Prolog from Elisp." - (should (equal (sweeprolog-open-query "user" "user" + (should (equal (sweeprolog--open-query "user" "user" "sweep_funcall" "sweeprolog-tests-greet") t)) @@ -27,7 +27,7 @@ (ert-deftest lists:member/2 () "Tests calling the Prolog predicate permutation/2 from Elisp." - (should (equal (sweeprolog-open-query "user" "lists" "member" (list 1 2 3) t) t)) + (should (equal (sweeprolog--open-query "user" "lists" "member" (list 1 2 3) t) t)) (should (equal (sweeprolog-next-solution) (cons t 1))) (should (equal (sweeprolog-next-solution) (cons t 2))) (should (equal (sweeprolog-next-solution) (cons '! 3))) @@ -35,7 +35,7 @@ (ert-deftest lists:permutation/2 () "Tests calling the Prolog predicate permutation/2 from Elisp." - (should (equal (sweeprolog-open-query "user" "lists" "permutation" (list 1 2 3)) t)) + (should (equal (sweeprolog--open-query "user" "lists" "permutation" (list 1 2 3)) t)) (should (equal (sweeprolog-next-solution) (list t 1 2 3))) (should (equal (sweeprolog-next-solution) (list t 1 3 2))) (should (equal (sweeprolog-next-solution) (list t 2 1 3))) @@ -47,7 +47,7 @@ (ert-deftest system:=/2 () "Tests unifying Prolog terms with =/2 from Elisp." - (should (equal (sweeprolog-open-query "user" "system" "=" (list 1 nil (list "foo" "bar") 3.14)) t)) + (should (equal (sweeprolog--open-query "user" "system" "=" (list 1 nil (list "foo" "bar") 3.14)) t)) (should (equal (sweeprolog-next-solution) (list '! 1 nil (list "foo" "bar") 3.14))) (should (equal (sweeprolog-next-solution) nil)) (should (equal (sweeprolog-cut-query) t))) @@ -96,6 +96,27 @@ scasp_and_show(Q, Model, Tree) :- (sweeprolog-end-of-top-term) (should (= (point) 252)))) +(ert-deftest end-of-top-term-with-other-symbols () + "Tests detecting the fullstop in presence of `.=.'." + (with-temp-buffer + (sweeprolog-mode) + (insert " +loop_term(I, Arity, Goal1, Goal2) :- + I =< Arity, + arg(I, Goal1, A), + arg(I, Goal2, B), + ( loop_var_disequality(A,B) + -> true + ; A .=. B, + I2 is I+1, + loop_term(I2, Arity, Goal1, Goal2) + ). +") + (goto-char (point-min)) + (sweeprolog-end-of-top-term) + (should (= (point) 232)))) + + (defun sweeprolog-test-indentation (given expected) (with-temp-buffer (sweeprolog-mode) diff --git a/sweeprolog.el b/sweeprolog.el index 838eb05..b862772 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -1991,7 +1991,10 @@ Interactively, a prefix arg means to prompt for BUFFER." (nth 8 (syntax-ppss (max (point-min) (1- (point)))))) (save-match-data - (looking-back (rx "=.." (or white "\n")) + (looking-back (rx (or "#" "$" "&" "*" "+" "-" + "." "/" ":" "<" "=" ">" + "?" "@" "\\" "^" "~") + "." (or white "\n")) (line-beginning-position)))) (not (eobp))) (while (and (nth 8 (syntax-ppss)) (not (eobp)))