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

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

[elpa] externals/yaml 891e158930 008/124: Got parser mostly working.


From: ELPA Syncer
Subject: [elpa] externals/yaml 891e158930 008/124: Got parser mostly working.
Date: Fri, 29 Nov 2024 15:59:52 -0500 (EST)

branch: externals/yaml
commit 891e1589301e6ff3b4f0d5a025b30d9ff978735a
Author: Zachary Romero <zacromero@posteo.net>
Commit: Zachary Romero <zacromero@posteo.net>

    Got parser mostly working.
---
 yaml-tests.el | 25 ++++++++++++++++++++-----
 yaml.el       |  9 +++++++--
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/yaml-tests.el b/yaml-tests.el
index 74111c176a..62dc20a257 100644
--- a/yaml-tests.el
+++ b/yaml-tests.el
@@ -270,11 +270,26 @@
 (ert-deftest yaml-parsing-yaml ()
   "Tests YAML parsing."
   (should (yaml--hash-table-equal
+           (yaml-parse-string "key: value")
            (let ((ht (make-hash-table :test 'equal)))
-             (puthash "test" 3 ht))
-           (yaml-parse-string "key: value"))))
-(yaml-parse-string "value")
+             (prog1 ht
+               (puthash "key" "value" ht)))))
+  (should (equal (yaml-parse-string "value")
+                 "value"))
+  (should (equal (yaml-parse-string "[abc, def, ghi]")
+                 '("abc" "def" "ghi")))
+  (should (equal (yaml-parse-string "- abc\n- def\n- ghi")
+                 '("abc" "def" "ghi")))
+  (should (equal (yaml-parse-string "- abc\n- def\n- ghi")
+                 '("abc" "def" "ghi")))
+  (should (equal (yaml-parse-string "- [abc, def, ghi]\n- [jkl, mno, pqr]\n- 
[stu, vwx, yz]")
+                 '(("abc" "def" "ghi") ("jkl" "mno" "pqr") ("stu" "vwx" 
"yz"))))
+;;   (should (equal (yaml-parse-string "%YAML 1.2
+;; ---
+;; !!map {
+;;   ? !!str foo : !!seq [ !!str \"abc\", !!str \"def\"],
+;;   ? !!str xzy : !!str zyx
+;; }")))
+  )
 
 (provide 'yaml-tests)
-
-;;; yaml-tests.el ends here
diff --git a/yaml.el b/yaml.el
index a4d6c5a323..7966cfe55a 100644
--- a/yaml.el
+++ b/yaml.el
@@ -233,6 +233,9 @@
 (defun yaml--check-document-start () t)
 (defun yaml--check-document-end () t)
 
+(defun yaml--revers-at-list ()
+  (setcar yaml--object-stack (reverse (car yaml--object-stack))))
+
 (defconst yaml--grammar-events-in
   '(("l-yaml-stream" . (lambda ()
                          (yaml--add-event (yaml--stream-start-event))
@@ -275,12 +278,13 @@
                             (setq yaml--document-end-explicit t))
                           (yaml--check-document-end)))
     ("c-flow-mapping" . (lambda (text)
-                          (yaml--add-event (yaml--mapping-end-event t))))
+                          (yaml--add-event (yaml--mapping-end-event))))
     ("c-flow-sequence" . (lambda (text)
                            (yaml--add-event (yaml--sequence-end-event ))))
     ("l+block-mapping" . (lambda (text)
                            (yaml--add-event (yaml--mapping-end-event))))
     ("l+block-sequence" . (lambda (text)
+                            (yaml--revers-at-list)
                             (yaml--add-event (yaml--sequence-end-event))))
     ("ns-l-compact-mapping" . (lambda (text)
                                 (yaml--add-event (yaml--mapping-end-event))))
@@ -381,7 +385,8 @@
     ("c-ns-anchor-property" . (lambda (text)
                                 (setq yaml--anchor (substring text 1))))
     ("c-ns-tag-property" . (lambda (text)
-                             (error "not implemented")))
+                             ;; (error "not implemented: %s" text)
+                             ))
     ("c-ns-alias-node" . (lambda (text)
                            (yaml--add-event (yaml--alias-event (substring text 
1)))))))
 



reply via email to

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