emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/sweeprolog 24b5e1637e 5/5: Use term_string/2 to parse M:F/


From: ELPA Syncer
Subject: [nongnu] elpa/sweeprolog 24b5e1637e 5/5: Use term_string/2 to parse M:F/N terms encoded in strings
Date: Tue, 25 Oct 2022 13:59:17 -0400 (EDT)

branch: elpa/sweeprolog
commit 24b5e1637e4e07049c437372f4f1f7818320cc27
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>

    Use term_string/2 to parse M:F/N terms encoded in strings
---
 sweeprolog.el | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/sweeprolog.el b/sweeprolog.el
index 1b64376dbb..389cef1b3c 100644
--- a/sweeprolog.el
+++ b/sweeprolog.el
@@ -6,7 +6,7 @@
 ;; Maintainer: Eshel Yaron <~eshel/dev@lists.sr.ht>
 ;; Keywords: prolog languages extensions
 ;; URL: https://git.sr.ht/~eshel/sweep
-;; Package-Version: 0.8.0
+;; Package-Version: 0.8.1
 ;; Package-Requires: ((emacs "28.1"))
 
 ;; This file is NOT part of GNU Emacs.
@@ -696,9 +696,21 @@ FLAG and VALUE are specified as strings and read as Prolog 
terms."
       (cdr sol))))
 
 (defun sweeprolog--mfn-to-functor-arity (mfn)
-  (let ((functor-arity (split-string (car (reverse (split-string mfn ":"))) 
"/")))
-    (cons (car functor-arity)
-          (string-to-number (cadr functor-arity)))))
+  (sweeprolog--open-query "user" "system" "term_string" mfn t)
+  (let ((sol (sweeprolog-next-solution)))
+    (sweeprolog-close-query)
+    (when (sweeprolog-true-p sol)
+      (pcase (cdr sol)
+        (`(compound ":"
+                    (atom . ,_)
+                    (compound "/"
+                              (atom . ,functor)
+                              ,arity))
+         (cons functor arity))
+        (`(compound "/"
+                    (atom . ,functor)
+                    ,arity)
+         (cons functor arity))))))
 
 (defun sweeprolog--swipl-source-directory ()
   (when sweeprolog-swipl-sources



reply via email to

[Prev in Thread] Current Thread [Next in Thread]