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

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

[nongnu] elpa/parseclj 811f35e05a 117/185: Loops reduction over the firs


From: ELPA Syncer
Subject: [nongnu] elpa/parseclj 811f35e05a 117/185: Loops reduction over the first 2 elements of the stack
Date: Tue, 28 Dec 2021 14:05:27 -0500 (EST)

branch: elpa/parseclj
commit 811f35e05ad6f690224ddf25891e4a42a1d00a36
Author: Daniel Barreto <daniel.barreto.n@gmail.com>
Commit: Daniel Barreto <daniel.barreto.n@gmail.com>

    Loops reduction over the first 2 elements of the stack
    
    Now the parser can consume nested tags.
---
 parseclj-parser.el         | 20 +++++++++++++-------
 test/parseclj-test-data.el | 28 ++++++++++++++++++++++++++--
 2 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/parseclj-parser.el b/parseclj-parser.el
index 1e07d2d0a7..b71c5a0bff 100644
--- a/parseclj-parser.el
+++ b/parseclj-parser.el
@@ -203,15 +203,21 @@ functions. Additionally the following options are 
recognized
        (t (push token stack)))
 
       ;; Reduce based on top two items on the stack (special prefixed elements)
-      (let* ((top-value (parseclj--take-value stack value-p))
-             (opening-token (parseclj--take-token (nthcdr (length top-value) 
stack) value-p '(:discard :tag)))
-             (new-stack (nthcdr (+ (length top-value) (length opening-token)) 
stack)))
-        (when (and top-value opening-token)
+      (let (top-value
+            opening-token
+            new-stack)
+        (setq top-value (parseclj--take-value stack value-p))
+        (setq opening-token (parseclj--take-token (nthcdr (length top-value) 
stack) value-p '(:discard :tag)))
+        (while (and top-value opening-token)
           ;; (message "Reducing...")
           ;; (message "  - STACK %S" stack)
-          ;; (message "  - OPENING_TOKEN %S" opening-token)
-          ;; (message "  - TOP_VALUE %S\n" top-value)
-          (setq stack (funcall reduce-branch new-stack (car opening-token) 
(append (cdr opening-token) top-value) options))))
+          ;; (message "  - OPENING-TOKEN %S" opening-token)
+          ;; (message "  - TOP-VALUE %S" top-value)
+          (setq new-stack (nthcdr (+ (length top-value) (length 
opening-token)) stack))
+          (setq stack (funcall reduce-branch new-stack (car opening-token) 
(append (cdr opening-token) top-value) options))
+
+          (setq top-value (parseclj--take-value stack value-p))
+          (setq opening-token (parseclj--take-token (nthcdr (length top-value) 
stack) value-p '(:discard :tag)))))
 
       (setq token (parseclj-lex-next)))
 
diff --git a/test/parseclj-test-data.el b/test/parseclj-test-data.el
index 28a03d91dc..a390e77c2f 100644
--- a/test/parseclj-test-data.el
+++ b/test/parseclj-test-data.el
@@ -275,7 +275,7 @@
                                              (:value . 12)))))))))
 
 
-       "tag"
+       "tag-1"
        (a-list
         :source "#foo/bar [1]"
         :ast '((:node-type . :root)
@@ -290,7 +290,7 @@
                                                             (:form . "1")
                                                             (:value . 
1))))))))))))
 
-       "nested-tag"
+       "tag-2"
        (a-list
         :source "(fn #param :param-name 1)"
         :ast '((:node-type . :root)
@@ -313,6 +313,30 @@
                                              (:form . "1")
                                              (:value . 1)))))))))
 
+       "nested-tags"
+       (a-list
+        :source "[#lazy-error #error {:cause \"Divide by zero\"}]"
+        :ast '((:node-type . :root)
+               (:position . 1)
+               (:children ((:node-type . :vector)
+                           (:position . 1)
+                           (:children ((:node-type . :tag)
+                                       (:position . 2)
+                                       (:tag . lazy-error)
+                                       (:children ((:node-type . :tag)
+                                                   (:position . 14)
+                                                   (:tag . error)
+                                                   (:children ((:node-type . 
:map)
+                                                               (:position . 21)
+                                                               (:children 
((:node-type . :keyword)
+                                                                           
(:position . 22)
+                                                                           
(:form . ":cause")
+                                                                           
(:value . :cause))
+                                                                          
((:node-type . :string)
+                                                                           
(:position . 29)
+                                                                           
(:form . "\"Divide by zero\"")
+                                                                           
(:value . "Divide by zero")))))))))))))
+
        "booleans"
        (a-list
         :source "[nil true false]"



reply via email to

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