[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/parseclj adb55fa579 183/185: Merge pull request #34 from c
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/parseclj adb55fa579 183/185: Merge pull request #34 from clojure-emacs/cl-case-to-cond |
Date: |
Tue, 28 Dec 2021 14:05:34 -0500 (EST) |
branch: elpa/parseclj
commit adb55fa579c99b6b3de573d44d52a5053e9ca949
Merge: fcebf65075 5cf5cd5f53
Author: Arne Brasseur <arne.brasseur@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #34 from clojure-emacs/cl-case-to-cond
Replace `cl-case` calls with `cond`
---
CHANGELOG.md | 2 ++
parseclj-alist.el | 10 ++++++----
parseclj-ast.el | 58 +++++++++++++++++++++++++++---------------------------
parseclj-lex.el | 38 ++++++++++++++++++-----------------
parseclj-parser.el | 25 ++++++++++++-----------
5 files changed, 70 insertions(+), 63 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 32565015c8..dfa6b0e93a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
# Unreleased
+- [#34](https://github.com/clojure-emacs/parseclj/pull/34) Replace `cl-case`
with `cond`
+
## 1.0.4 (2021-09-30)
- Provide parseclj-alist-merge, since we can't use `(map-merge 'alist)` yet in
Emacs 25/26.
diff --git a/parseclj-alist.el b/parseclj-alist.el
index 824f491667..dcca15f598 100644
--- a/parseclj-alist.el
+++ b/parseclj-alist.el
@@ -82,10 +82,12 @@ For example: (parseclj-hash-table :foo 123 :bar 456)"
;; Emacs 27: (map-merge 'alist l1 l2)
(let ((keys (delete-dups (append (mapcar #'car l1) (mapcar #'car l2))))
(res '()))
- (seq-doseq (key keys)
- (push (or (assoc key l2)
- (assoc key l1))
- res))
+ (mapcar
+ (lambda (key)
+ (push (or (assoc key l2)
+ (assoc key l1))
+ res))
+ keys)
(nreverse res)))
(provide 'parseclj-alist)
diff --git a/parseclj-ast.el b/parseclj-ast.el
index 63b25612ae..94255c866b 100644
--- a/parseclj-ast.el
+++ b/parseclj-ast.el
@@ -120,29 +120,29 @@ OPTIONS is an association list. See `parseclj-parse' for
more information
on available options."
(let* ((pos (map-elt opening-token :pos))
(type (parseclj-lex-token-type opening-token))
- (type (cl-case type
- (:lparen :list)
- (:lbracket :vector)
- (:lbrace :map)
- (t type))))
- (cl-case type
- (:root (cons (parseclj-ast-node :root pos :children children) stack))
- (:discard stack)
- (:tag (cons (parseclj-ast-node :tag
- pos
- :tag (intern (substring (map-elt
opening-token :form) 1))
- :children children)
- stack))
- (:metadata (cons (parseclj-ast-node :with-meta
- pos
- :children children)
- stack))
- (:map-prefix (cons (parseclj-alist-assoc (car children)
- :map-prefix opening-token)
- stack))
- (t (cons
- (parseclj-ast-node type pos :children children)
- stack)))))
+ (type (cond
+ ((eq :lparen type) :list)
+ ((eq :lbracket type) :vector)
+ ((eq :lbrace type) :map)
+ (t type))))
+ (cond
+ ((eq :root type) (cons (parseclj-ast-node :root pos :children children)
stack))
+ ((eq :discard type) stack)
+ ((eq :tag type) (cons (parseclj-ast-node :tag
+ pos
+ :tag (intern (substring (map-elt
opening-token :form) 1))
+ :children children)
+ stack))
+ ((eq :metadata type) (cons (parseclj-ast-node :with-meta
+ pos
+ :children children)
+ stack))
+ ((eq :map-prefix type) (cons (parseclj-alist-assoc (car children)
+ :map-prefix
opening-token)
+ stack))
+ (t (cons
+ (parseclj-ast-node type pos :children children)
+ stack)))))
(defun parseclj-ast--reduce-branch-with-lexical-preservation (stack
opening-token children options)
"Reduce STACK with an AST branch node representing a collection of elements.
@@ -176,12 +176,12 @@ on available options."
(defun parseclj-ast--unparse-collection (node)
"Insert a string representation of the given AST branch NODE into buffer."
(let* ((token-type (parseclj-ast-node-type node))
- (delimiters (cl-case token-type
- (:root (cons "" ""))
- (:list (cons "(" ")"))
- (:vector (cons "[" "]"))
- (:set (cons "#{" "}"))
- (:map (cons "{" "}")))))
+ (delimiters (cond
+ ((eq :root token-type) (cons "" ""))
+ ((eq :list token-type) (cons "(" ")"))
+ ((eq :vector token-type) (cons "[" "]"))
+ ((eq :set token-type) (cons "#{" "}"))
+ ((eq :map token-type) (cons "{" "}")))))
(insert (car delimiters))
(let ((nodes (alist-get ':children node)))
(when-let (node (car nodes))
diff --git a/parseclj-lex.el b/parseclj-lex.el
index 8b30393251..8f2d6722e5 100644
--- a/parseclj-lex.el
+++ b/parseclj-lex.el
@@ -140,14 +140,15 @@ S goes through three transformations:
(make-string 1 (string-to-number (substring x 2) 16)))
(replace-regexp-in-string "\\\\[tbnrf'\"\\]"
(lambda (x)
- (cl-case (elt x 1)
- (?t "\t")
- (?f "\f")
- (?\" "\"")
- (?r "\r")
- (?n "\n")
- (?\\ "\\\\")
- (t (substring x 1))))
+ (let ((ch (elt x 1)))
+ (cond
+ ((eq ?t ch) "\t")
+ ((eq ?f ch) "\f")
+ ((eq ?\" ch) "\"")
+ ((eq ?r ch) "\r")
+ ((eq ?n ch) "\n")
+ ((eq ?\\ ch) "\\\\")
+ (t (substring x 1)))))
(substring s 1 -1)))))
(defun parseclj-lex--character-value (c)
@@ -164,16 +165,17 @@ S goes through three transformations:
(defun parseclj-lex--leaf-token-value (token)
"Parse the given leaf TOKEN to an Emacs Lisp value."
- (cl-case (parseclj-lex-token-type token)
- (:number (string-to-number (alist-get :form token)))
- (:nil nil)
- (:true t)
- (:false nil)
- (:symbol (intern (alist-get :form token)))
- (:keyword (intern (alist-get :form token)))
- (:string (parseclj-lex--string-value (alist-get :form token)))
- (:character (parseclj-lex--character-value (alist-get :form token)))
- (:symbolic-value (intern (substring (alist-get :form token) 2)))))
+ (let ((token-type (parseclj-lex-token-type token)))
+ (cond
+ ((eq :number token-type) (string-to-number (alist-get :form token)))
+ ((eq :nil token-type) nil)
+ ((eq :true token-type) t)
+ ((eq :false token-type) nil)
+ ((eq :symbol token-type) (intern (alist-get :form token)))
+ ((eq :keyword token-type) (intern (alist-get :form token)))
+ ((eq :string token-type) (parseclj-lex--string-value (alist-get :form
token)))
+ ((eq :character token-type) (parseclj-lex--character-value (alist-get
:form token)))
+ ((eq :symbolic-value token-type) (intern (substring (alist-get :form
token) 2))))))
;; Stream tokenization
diff --git a/parseclj-parser.el b/parseclj-parser.el
index aaad607d39..f83e760908 100644
--- a/parseclj-parser.el
+++ b/parseclj-parser.el
@@ -43,18 +43,19 @@ can be handled with `condition-case'."
(defun parseclj--find-opening-token (stack closing-token)
"Scan STACK for an opening-token matching CLOSING-TOKEN."
- (cl-case (parseclj-lex-token-type closing-token)
- (:rparen (parseclj-lex-token-type
- (seq-find (lambda (token)
- (member (parseclj-lex-token-type token)
- '(:lparen :lambda)))
- stack)))
- (:rbracket :lbracket)
- (:rbrace (parseclj-lex-token-type
- (seq-find (lambda (token)
- (member (parseclj-lex-token-type token)
- '(:lbrace :set)))
- stack)))))
+ (let ((token-type (parseclj-lex-token-type closing-token)))
+ (cond
+ ((eq :rparen token-type) (parseclj-lex-token-type
+ (seq-find (lambda (token)
+ (member (parseclj-lex-token-type
token)
+ '(:lparen :lambda)))
+ stack)))
+ ((eq :rbracket token-type) :lbracket)
+ ((eq :rbrace token-type) (parseclj-lex-token-type
+ (seq-find (lambda (token)
+ (member (parseclj-lex-token-type
token)
+ '(:lbrace :set)))
+ stack))))))
(defun parseclj--reduce-coll (stack closing-token reduce-branch options)
"Reduce collection based on the top of the STACK and a CLOSING-TOKEN.
- [nongnu] elpa/parseclj d691df5d63 131/185: Update the copyright years, (continued)
- [nongnu] elpa/parseclj d691df5d63 131/185: Update the copyright years, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj acf4a29778 132/185: Update the README, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d42b4ad744 144/185: Require a couple of dependencies to `parseclj-ast.el`, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj c32017ecc9 143/185: Merge pull request #20 from clojure-emacs/remove-parseedn, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj ece9648128 179/185: Merge pull request #33 from clojure-emacs/arne/remove-a-from-tests, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj c7f50e3414 178/185: Update CHANGELOG, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 30c950a4ad 167/185: Use map-contains-key, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 0d157d759b 163/185: Merge branch 'master' into shebang-and-symbolic-values, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 089160a487 169/185: Drop a.el dependency, bump copyright year, bump version, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 93a0f43529 150/185: Merge pull request #21 from clojure-emacs/add-more-syntax-features, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj adb55fa579 183/185: Merge pull request #34 from clojure-emacs/cl-case-to-cond,
ELPA Syncer <=
- [nongnu] elpa/parseclj dec638c5ca 153/185: Tweak the keywords, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 5cf5cd5f53 182/185: Replace seq-doseq with mapcar... IDK, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 3de700b057 154/185: Add a changelog, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj f5f7ec1660 173/185: Release v1.0.1, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj b34d3e13a2 156/185: Support eval #=(foo...) forms, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d659079598 174/185: Remove the remaining a.el dependency from non-test code, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 507720a632 170/185: Release 1.0, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 6d1c9c348a 184/185: Update CHANGELOG, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 61513d2c99 164/185: Merge pull request #27 from clojure-emacs/shebang-and-symbolic-values, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj e6bce85062 159/185: Update the CHANGELOG, ELPA Syncer, 2021/12/28