From 8e0972cf478cdce6afbf60ff436d7631eeb25e14 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sun, 22 Dec 2024 13:14:37 +0100 Subject: [PATCH] update parseedn Signed-off-by: Andreas Gerler --- .../parseedn-autoloads.el | 26 ------- elpa/parseedn-20220520.835/parseedn-pkg.el | 15 ---- .../parseedn-autoloads.el | 28 +++++++ elpa/parseedn-20231203.1909/parseedn-pkg.el | 12 +++ .../parseedn.el | 77 +++++++++++++------ elpa/parseedn-readme.txt | 10 --- 6 files changed, 93 insertions(+), 75 deletions(-) delete mode 100644 elpa/parseedn-20220520.835/parseedn-autoloads.el delete mode 100644 elpa/parseedn-20220520.835/parseedn-pkg.el create mode 100644 elpa/parseedn-20231203.1909/parseedn-autoloads.el create mode 100644 elpa/parseedn-20231203.1909/parseedn-pkg.el rename elpa/{parseedn-20220520.835 => parseedn-20231203.1909}/parseedn.el (76%) delete mode 100644 elpa/parseedn-readme.txt diff --git a/elpa/parseedn-20220520.835/parseedn-autoloads.el b/elpa/parseedn-20220520.835/parseedn-autoloads.el deleted file mode 100644 index 511be462..00000000 --- a/elpa/parseedn-20220520.835/parseedn-autoloads.el +++ /dev/null @@ -1,26 +0,0 @@ -;;; parseedn-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- -;; -;;; Code: - -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) - - -;;;### (autoloads nil "parseedn" "parseedn.el" (0 0 0 0)) -;;; Generated autoloads from parseedn.el - -(register-definition-prefixes "parseedn" '("parseedn-")) - -;;;*** - -;;;### (autoloads nil nil ("parseedn-pkg.el") (0 0 0 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; parseedn-autoloads.el ends here diff --git a/elpa/parseedn-20220520.835/parseedn-pkg.el b/elpa/parseedn-20220520.835/parseedn-pkg.el deleted file mode 100644 index 1bdee448..00000000 --- a/elpa/parseedn-20220520.835/parseedn-pkg.el +++ /dev/null @@ -1,15 +0,0 @@ -(define-package "parseedn" "20220520.835" "Clojure/EDN parser" - '((emacs "26") - (parseclj "1.1.0") - (map "2")) - :commit "a09686fbb9113b8b1b4f20c9e1dc0d6fea01a64f" :authors - '(("Arne Brasseur" . "arne@arnebrasseur.net")) - :maintainers - '(("Arne Brasseur" . "arne@arnebrasseur.net")) - :maintainer - '("Arne Brasseur" . "arne@arnebrasseur.net") - :keywords - '("lisp" "clojure" "edn" "parser")) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/parseedn-20231203.1909/parseedn-autoloads.el b/elpa/parseedn-20231203.1909/parseedn-autoloads.el new file mode 100644 index 00000000..43928ff1 --- /dev/null +++ b/elpa/parseedn-20231203.1909/parseedn-autoloads.el @@ -0,0 +1,28 @@ +;;; parseedn-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + +;;; Code: + +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + + + +;;; Generated autoloads from parseedn.el + +(register-definition-prefixes "parseedn" '("parseedn-")) + +;;; End of scraped data + +(provide 'parseedn-autoloads) + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; no-native-compile: t +;; coding: utf-8-emacs-unix +;; End: + +;;; parseedn-autoloads.el ends here diff --git a/elpa/parseedn-20231203.1909/parseedn-pkg.el b/elpa/parseedn-20231203.1909/parseedn-pkg.el new file mode 100644 index 00000000..d38183b7 --- /dev/null +++ b/elpa/parseedn-20231203.1909/parseedn-pkg.el @@ -0,0 +1,12 @@ +;; -*- no-byte-compile: t; lexical-binding: nil -*- +(define-package "parseedn" "20231203.1909" + "Clojure/EDN parser." + '((emacs "26") + (parseclj "1.1.1") + (map "2")) + :url "https://github.com/clojure-emacs/parseedn" + :commit "3407e4530a367b6c2b857dae261cdbb67a440aaa" + :revdesc "3407e4530a36" + :keywords '("lisp" "clojure" "edn" "parser") + :authors '(("Arne Brasseur" . "arne@arnebrasseur.net")) + :maintainers '(("Arne Brasseur" . "arne@arnebrasseur.net"))) diff --git a/elpa/parseedn-20220520.835/parseedn.el b/elpa/parseedn-20231203.1909/parseedn.el similarity index 76% rename from elpa/parseedn-20220520.835/parseedn.el rename to elpa/parseedn-20231203.1909/parseedn.el index eb367827..9e43a8fc 100644 --- a/elpa/parseedn-20220520.835/parseedn.el +++ b/elpa/parseedn-20231203.1909/parseedn.el @@ -3,9 +3,11 @@ ;; Copyright (C) 2017-2021 Arne Brasseur ;; Author: Arne Brasseur +;; URL: http://www.github.com/clojure-emacs/parseedn ;; Keywords: lisp clojure edn parser -;; Package-Requires: ((emacs "26") (parseclj "1.1.0") (map "2")) -;; Version: 1.1.0 +;; Package-Requires: ((emacs "26") (parseclj "1.1.1") (map "2")) +;; Package-Version: 20231203.1909 +;; Package-Revision: 3407e4530a36 ;; This file is not part of GNU Emacs. @@ -32,7 +34,7 @@ ;; EDN and Emacs Lisp have some important differences that make ;; translation from one to the other not transparent (think ;; representing an EDN map into Elisp, or being able to differentiate -;; between false and nil in Elisp). Because of this, parseedn takes +;; between false and nil in Elisp). Because of this, parseedn takes ;; certain decisions when parsing and transforming EDN data into Elisp ;; data types. For more information please refer to parseclj's design ;; documentation. @@ -91,6 +93,33 @@ on available options." stack (cons (parseclj-lex--leaf-token-value token) stack))) +(defun parseedn--build-prefixed-map (prefix-token kvs) + "Build a map that has a prefix for non-qualified keywords. +PREFIX-TOKEN is the AST token for the map prefix. +KVS is a list of key, value pairs." + (let* ((hash-map (make-hash-table :test 'equal :size (length kvs))) + ;; map-prefix forms are always "#:...." + (map-prefix (substring (parseclj-lex-token-form prefix-token) 2))) + (seq-do (lambda (pair) + (let* ((key-name (substring (symbol-name (car pair)) 1)) + (k (if (string-match-p "/" key-name) + ;; keyword is already qualified, we must not add the prefix. + (car pair) + (intern (concat ":" map-prefix "/" key-name)))) + (v (cadr pair))) + (puthash k v hash-map))) + kvs) + hash-map)) + +(defun parseedn--build-non-prefixed-map (kvs) + "Build a non-prefixed map out of KVS. +KVS is a list of pairs (key value)" + (let ((hash-map (make-hash-table :test 'equal :size (length kvs)))) + (seq-do (lambda (pair) + (puthash (car pair) (cadr pair) hash-map)) + kvs) + hash-map)) + (defun parseedn-reduce-branch (stack opening-token children options) "Reduce STACK with an sequence containing a collection of other elisp values. Ignores discard tokens. @@ -105,28 +134,27 @@ on available options." (token-type (parseclj-lex-token-type opening-token))) (if (eq token-type :discard) stack - (cons - (cond - ((eq :root token-type) children) - ((eq :lparen token-type) children) - ((eq :lbracket token-type) (apply #'vector children)) - ((eq :set token-type) (list 'edn-set children)) - ((eq :lbrace token-type) (let* ((kvs (seq-partition children 2)) - (hash-map (make-hash-table :test 'equal :size (length kvs)))) - (seq-do (lambda (pair) - (puthash (car pair) (cadr pair) hash-map)) - kvs) - hash-map)) - ((eq :tag token-type) (let* ((tag (intern (substring (alist-get :form opening-token) 1))) - (reader (alist-get tag tag-readers)) - (default-reader (alist-get :default tag-readers parseedn-default-data-reader-fn))) + (cond + ((eq :root token-type) (cons children stack)) + ((eq :lparen token-type) (cons children stack)) + ((eq :lbracket token-type) (cons (apply #'vector children) stack)) + ((eq :set token-type) (cons (list 'edn-set children) stack)) + ((eq :lbrace token-type) (let* ((kvs (seq-partition children 2)) + (prefixed-map? (eq :map-prefix (parseclj-lex-token-type (car stack))))) + (if prefixed-map? + (cons (parseedn--build-prefixed-map (car stack) kvs) (cdr stack)) + (cons (parseedn--build-non-prefixed-map kvs) stack)))) + ((eq :tag token-type) (let* ((tag (intern (substring (alist-get :form opening-token) 1))) + (reader (alist-get tag tag-readers)) + (default-reader (alist-get :default tag-readers parseedn-default-data-reader-fn))) + (cons (cond ((functionp reader) (funcall reader (car children))) ((functionp default-reader) (funcall default-reader tag (car children))) - (t (user-error "No reader for tag #%S in %S" tag (map-keys tag-readers))))))) - stack)))) + (t (user-error "No reader for tag #%S in %S" tag (map-keys tag-readers)))) + stack))))))) (defun parseedn-read (&optional tag-readers) "Read content from current buffer and parse it as EDN source. @@ -164,7 +192,8 @@ TAG-READERS is an optional association list. For more information, see (delete-char -1))) (defun parseedn-print-hash-or-alist (map &optional ks) - "Insert hash table MAP or elisp alist as an EDN map into the current buffer." + "Insert hash table MAP or elisp alist as an EDN map into the current buffer. +Selects KS from MAP if specified, otherwise all keys will be selected." (when-let ((keys (or ks (map-keys map)))) (parseedn-print (car keys)) (insert " ") @@ -175,7 +204,7 @@ TAG-READERS is an optional association list. For more information, see (parseedn-print-hash-or-alist map next))))) (defun parseedn-print-plist (plist) - "Insert an elisp property list as an EDN map into the current buffer." + "Insert an elisp property list PLIST as an EDN map into the current buffer." (parseedn-print (car plist)) (insert " ") (parseedn-print (cadr plist)) @@ -185,9 +214,9 @@ TAG-READERS is an optional association list. For more information, see (parseedn-print-plist next)))) (defun parseedn-print-inst (time) - "Insert an inst value into the current buffer. + "Insert an inst value TIME into the current buffer. -Take an encode-time style value and print it as a timestamp +Take an `encode-time' style value and print it as a timestamp deliniated by double quotes." (insert (format-time-string "\"%Y-%m-%dT%T\"" time))) diff --git a/elpa/parseedn-readme.txt b/elpa/parseedn-readme.txt deleted file mode 100644 index 48bb53e4..00000000 --- a/elpa/parseedn-readme.txt +++ /dev/null @@ -1,10 +0,0 @@ -parseedn is an Emacs Lisp library for parsing EDN (Clojure) data. -It uses parseclj's shift-reduce parser internally. - -EDN and Emacs Lisp have some important differences that make -translation from one to the other not transparent (think -representing an EDN map into Elisp, or being able to differentiate -between false and nil in Elisp). Because of this, parseedn takes -certain decisions when parsing and transforming EDN data into Elisp -data types. For more information please refer to parseclj's design -documentation. -- 2.47.3