[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/parseclj b40670a561 149/185: Add namespaced maps, fix back
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/parseclj b40670a561 149/185: Add namespaced maps, fix backquote implementation |
Date: |
Tue, 28 Dec 2021 14:05:31 -0500 (EST) |
branch: elpa/parseclj
commit b40670a56147214f0486763529897cb688a09692
Author: Arne Brasseur <arne@arnebrasseur.net>
Commit: Arne Brasseur <arne@arnebrasseur.net>
Add namespaced maps, fix backquote implementation
Namespaced maps are parsed to a regular :map AST token, but with an extra
`:map-prefix` key, which is the map-prefix lex token.
---
parseclj-ast.el | 3 +++
parseclj-lex.el | 17 +++++++++++++++--
test/parseclj-lex-test.el | 11 +++++++++++
test/parseclj-test.el | 12 ++++++++++++
4 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/parseclj-ast.el b/parseclj-ast.el
index dd3cc86475..e7b3cebc71 100644
--- a/parseclj-ast.el
+++ b/parseclj-ast.el
@@ -137,6 +137,9 @@ on available options."
pos
:children children)
stack))
+ (:map-prefix (cons (a-assoc (car children)
+ :map-prefix opening-token)
+ stack))
(t (cons
(parseclj-ast-node type pos :children children)
stack)))))
diff --git a/parseclj-lex.el b/parseclj-lex.el
index 6a53f55b05..5f73d90d43 100644
--- a/parseclj-lex.el
+++ b/parseclj-lex.el
@@ -54,7 +54,8 @@
:reader-conditional
:reader-conditional-splice
:var
- :deref)
+ :deref
+ :map-prefix)
"Tokens that modify the form that follows.")
(defvar parseclj-lex--prefix-2-tokens '(:metadata)
@@ -406,6 +407,16 @@ See `parseclj-lex-symbol', `parseclj-lex-symbol-start-p'."
(right-char))
(parseclj-lex-token :comment (buffer-substring-no-properties pos (point))
pos)))
+(defun parseclj-lex-map-prefix ()
+ "Return a lex token representing a map prefix."
+ (let ((pos (1- (point))))
+ (right-char)
+ (when (equal (char-after (point)) ?:)
+ (right-char))
+ (while (parseclj-lex-symbol-rest-p (char-after (point)))
+ (right-char))
+ (parseclj-lex-token :map-prefix (buffer-substring-no-properties pos
(point)) pos)))
+
(defun parseclj-lex-next ()
"Consume characters at point and return the next lexical token.
@@ -448,7 +459,7 @@ See `parseclj-lex-token'."
((equal char ?`)
(right-char)
- (parseclj-lex-token :backquote "'" pos))
+ (parseclj-lex-token :backquote "`" pos))
((equal char ?~)
(right-char)
@@ -502,6 +513,8 @@ See `parseclj-lex-token'."
(parseclj-lex-token :var "#'" pos))
((equal char ?\")
(parseclj-lex-regex))
+ ((equal char ?:)
+ (parseclj-lex-map-prefix))
((equal char ?\?)
(right-char)
(if (eq ?@ (char-after (point)))
diff --git a/test/parseclj-lex-test.el b/test/parseclj-lex-test.el
index 10cdac81d3..289fa72026 100644
--- a/test/parseclj-lex-test.el
+++ b/test/parseclj-lex-test.el
@@ -326,6 +326,17 @@
(goto-char 1)
(should (equal (parseclj-lex-next) (parseclj-lex-token :tag "#foo/bar"
1)))))
+(ert-deftest parseclj-lex-test-quote ()
+ (with-temp-buffer
+ (insert "'foo")
+ (goto-char 1)
+ (should (equal (parseclj-lex-next) (parseclj-lex-token :quote "'" 1))))
+
+ (with-temp-buffer
+ (insert "`foo")
+ (goto-char 1)
+ (should (equal (parseclj-lex-next) (parseclj-lex-token :backquote "`"
1)))))
+
(provide 'parseclj-lex-test)
;;; parseclj-lex-test.el ends here
diff --git a/test/parseclj-test.el b/test/parseclj-test.el
index afc447b7cd..a25d2e4e3b 100644
--- a/test/parseclj-test.el
+++ b/test/parseclj-test.el
@@ -252,6 +252,18 @@
(:form . "foo")
(:value . foo)))))))))
+(ert-deftest parseclj--parse-namespaced-map-test ()
+ (should (equal
+ (parseclj-parse-clojure "#:foo.bar{}")
+ '((:node-type . :root)
+ (:position . 1)
+ (:children ((:map-prefix . ((:token-type . :map-prefix)
+ (:form . "#:foo.bar")
+ (:pos . 1)))
+ (:node-type . :map)
+ (:position . 10)
+ (:children)))))))
+
(ert-deftest parseclj--take-token-test ()
(should (equal
(parseclj--take-token
- [nongnu] elpa/parseclj 0ef32ad912 120/185: Add support for having single quotes in symbols/keywords, (continued)
- [nongnu] elpa/parseclj 0ef32ad912 120/185: Add support for having single quotes in symbols/keywords, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 0afb8c5f09 123/185: Add `parseclj-lex-error-token` helper, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj b2588ce0fb 126/185: Use EVM to setup Travis CI, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 46cfcd3120 129/185: Merge pull request #16 from lambdaisland/parseclj-lex-error-token, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 61577603f2 136/185: Update README.md with installation and usage information, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj a82f229014 139/185: Ignore *.elc files, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 7fba1624e0 142/185: Update DESIGN.md to name difference between parseclj and parseedn, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 3693dd148f 145/185: Fix Cask file, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj af6102c4a8 146/185: Minor fix to README file, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 91c2ad82af 147/185: Add enough feature to be able to parse clojure.core, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj b40670a561 149/185: Add namespaced maps, fix backquote implementation,
ELPA Syncer <=
- [nongnu] elpa/parseclj ff0443c27c 151/185: Add :read-one option, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 40e36c41eb 006/185: alist-get was only introduced in 25.1? :sadpanda:, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 6f36bbf6b4 009/185: Try to set up a build matrix, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d4286f9071 010/185: Give README the right extension, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj ce7ad0e427 025/185: implement strings, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj a08b85ffa8 032/185: Implement parsing maps, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 60fd8eb965 053/185: Copy tests from edn.el, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 212e0dc42b 063/185: silly typo, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 96b8180987 087/185: Unparse ASTs that have lexical preservation., ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj da0c877940 069/185: Remove dash, using seq is good enough, ELPA Syncer, 2021/12/28