[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/parseclj 4f54ba52fe 033/185: Add support for sets
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/parseclj 4f54ba52fe 033/185: Add support for sets |
Date: |
Tue, 28 Dec 2021 14:05:11 -0500 (EST) |
branch: elpa/parseclj
commit 4f54ba52fe8a97c6792a9fb5a360822a43a3dfef
Author: Arne Brasseur <arne@arnebrasseur.net>
Commit: Arne Brasseur <arne@arnebrasseur.net>
Add support for sets
---
clj-lex-test.el | 9 ++++++++-
clj-lex.el | 8 ++++++++
clj-parse-test.el | 6 +++++-
clj-parse.el | 12 +++++++++++-
4 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/clj-lex-test.el b/clj-lex-test.el
index 3710ad2945..99cea11c28 100644
--- a/clj-lex-test.el
+++ b/clj-lex-test.el
@@ -125,7 +125,14 @@
(should (equal (clj-lex-next) (clj-lex-token :keyword ":count" 2)))
(should (equal (clj-lex-next) (clj-lex-token :whitespace " " 8)))
(should (equal (clj-lex-next) (clj-lex-token :number "123" 9)))
- (should (equal (clj-lex-next) (clj-lex-token :rbrace "}" 12)))))
+ (should (equal (clj-lex-next) (clj-lex-token :rbrace "}" 12))))
+
+ (with-temp-buffer
+ (insert "#{:x}")
+ (goto-char 1)
+ (should (equal (clj-lex-next) (clj-lex-token :set "#{" 1)))
+ (should (equal (clj-lex-next) (clj-lex-token :keyword ":x" 3)))
+ (should (equal (clj-lex-next) (clj-lex-token :rbrace "}" 5)))))
(ert-deftest clj-lex-test-at-number? ()
(dolist (str '("123" ".9" "+1" "0" "-456"))
diff --git a/clj-lex.el b/clj-lex.el
index 94e5c5823d..4901667d3f 100644
--- a/clj-lex.el
+++ b/clj-lex.el
@@ -208,6 +208,14 @@
((equal char ?:)
(clj-lex-keyword))
+ ((equal char ?#)
+ (right-char)
+ (let ((char (char-after (point))))
+ (cl-case char
+ (?{
+ (right-char)
+ (clj-lex-token :set "#{" pos)))))
+
":("))))
(provide 'clj-lex)
diff --git a/clj-parse-test.el b/clj-parse-test.el
index 0554f5d1a5..ef06cb6d04 100644
--- a/clj-parse-test.el
+++ b/clj-parse-test.el
@@ -89,8 +89,12 @@
(with-temp-buffer
(insert "{:count 123}")
(goto-char 1)
- (should (equal (clj-parse) '(((:count . 123)))))))
+ (should (equal (clj-parse) '(((:count . 123))))))
+ (with-temp-buffer
+ (insert "#{:x}")
+ (goto-char 1)
+ (should (equal (clj-parse) '((:x))))))
(provide 'clj-parse-test)
diff --git a/clj-parse.el b/clj-parse.el
index 3c90cd302d..85cfd7db66 100644
--- a/clj-parse.el
+++ b/clj-parse.el
@@ -98,6 +98,7 @@
(:whitespace :ws)
(:number coll)
(:list (-butlast (cdr coll)))
+ (:set (-butlast (cdr coll)))
(:vector (apply #'vector (-butlast (cdr coll))))
(:map (mapcar (lambda (pair)
(cons (car pair) (cadr pair)))
@@ -138,7 +139,16 @@
(cl-case (clj-parse--token-type (car stack))
(:rparen (setf stack (clj-parse--reduce-coll stack :lparen :list
reduceN)))
(:rbracket (setf stack (clj-parse--reduce-coll stack :lbracket :vector
reduceN)))
- (:rbrace (setf stack (clj-parse--reduce-coll stack :lbrace :map
reduceN))))
+ (:rbrace
+ (let ((open-token (-find (lambda (token)
+ (member (clj-parse--token-type token)
'(:lbrace :set)))
+ stack)))
+
+ (cl-case (clj-parse--token-type open-token)
+ (:lbrace
+ (setf stack (clj-parse--reduce-coll stack :lbrace :map reduceN)))
+ (:set
+ (setf stack (clj-parse--reduce-coll stack :set :set
reduceN)))))))
(setq token (clj-lex-next)))
- [nongnu] elpa/parseclj 7cf7dc99cd 011/185: Travis: only install the necessary ppa/package for each matrix line, (continued)
- [nongnu] elpa/parseclj 7cf7dc99cd 011/185: Travis: only install the necessary ppa/package for each matrix line, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 710511ff79 013/185: Seems these packages dont actually package the versioned executable names, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj b2e97ecb57 017/185: Lets try that again #travis, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d7adaa5177 018/185: Lets try that again #travis, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj abe7edb04b 019/185: Bunch of refactoring, but we're green now, supposedly, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 56bb020a9e 020/185: Fix the travis yaml?, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 972161dd23 022/185: Make sure we test against the version we think we are testing against, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 792ba04647 024/185: A more elaborate test, nesting works!, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 452fe7cc76 023/185: Implement nil, true, false, symbol, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 67171853f5 026/185: lex characters, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 4f54ba52fe 033/185: Add support for sets,
ELPA Syncer <=
- [nongnu] elpa/parseclj 4f647c8cff 036/185: Remove duplicate defination of clj-lex--token-token, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 1b2b221c98 038/185: Add AST to Elisp and Clojure/EDN printers, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 9404763e11 042/185: Make sure Travis uses the right Emacs, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 29411e2103 045/185: Add a design document to share vision and collect feedback, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 0702332e5d 046/185: Merge branch 'master' of https://github.com/lambdaisland/clj-parse, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 553f8618e1 044/185: Rework `clj-parse-deftest` macro, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj da89bf82a3 050/185: Allow colons inside symbols, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 81fe979450 051/185: Handle parsing of semicolon-based comments., ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj a424f87c1b 054/185: :#/# is a valid keyword. :::hello is not, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj f34b8460a8 055/185: Correctly parse numbers in scientific notation, ELPA Syncer, 2021/12/28