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

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

[nongnu] elpa/parseclj a424f87c1b 054/185: :#/# is a valid keyword. :::h


From: ELPA Syncer
Subject: [nongnu] elpa/parseclj a424f87c1b 054/185: :#/# is a valid keyword. :::hello is not
Date: Tue, 28 Dec 2021 14:05:16 -0500 (EST)

branch: elpa/parseclj
commit a424f87c1beec89727798ded682245376bda0942
Author: Arne Brasseur <arne@arnebrasseur.net>
Commit: Arne Brasseur <arne@arnebrasseur.net>

    :#/# is a valid keyword. :::hello is not
---
 clj-lex.el                 | 14 +++++++++-----
 tests/edn-el-test-suite.el | 36 ++++++++++++++++++------------------
 2 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/clj-lex.el b/clj-lex.el
index 604f29d1e9..66f307deef 100644
--- a/clj-lex.el
+++ b/clj-lex.el
@@ -168,13 +168,17 @@ behavior."
 (defun clj-lex-keyword ()
   (let ((pos (point)))
     (right-char)
-    (when (equal (char-after (point)) ?:)
+    (when (equal (char-after (point)) ?:) ;; same-namespace keyword
       (right-char))
-    (if (clj-lex-symbol-start? (char-after (point)))
-        (clj-lex-token :keyword (clj-lex-get-symbol-at-point pos) pos)
+    (if (equal (char-after (point)) ?:) ;; three colons in a row => lex-error
+        (progn
+          (right-char)
+          (clj-lex-token :lex-error (buffer-substring-no-properties pos 
(point)) pos 'error-type :invalid-keyword))
       (progn
-        (right-char)
-        (clj-lex-token :lex-error (buffer-substring-no-properties pos (point)) 
pos 'error-type :invalid-keyword)))))
+        (while (or (clj-lex-symbol-rest? (char-after (point)))
+                   (equal (char-after (point)) ?#))
+          (right-char))
+        (clj-lex-token :keyword (buffer-substring-no-properties pos (point)) 
pos)))))
 
 (defun clj-lex-comment ()
   (let ((pos (point)))
diff --git a/tests/edn-el-test-suite.el b/tests/edn-el-test-suite.el
index d42e021fd4..7e11b695df 100644
--- a/tests/edn-el-test-suite.el
+++ b/tests/edn-el-test-suite.el
@@ -60,24 +60,24 @@
   (should (equal [a d] (clj-parse-edn-str "[a #_ ;we are discarding what comes 
next
  c d]"))))
 
-;; (ert-deftest string ()
-;;   :tags '(edn string)
-;;   (should (equal "this is a string" (clj-parse-edn-str "\"this is a 
string\"")))
-;;   (should (equal "this has an escaped \"quote in it"
-;;                  (clj-parse-edn-str "\"this has an escaped \\\"quote in 
it\"")))
-;;   (should (equal "foo\tbar" (clj-parse-edn-str "\"foo\\tbar\"")))
-;;   (should (equal "foo\nbar" (clj-parse-edn-str "\"foo\\nbar\"")))
-;;   (should (equal "this is a string \\ that has an escaped backslash"
-;;                  (clj-parse-edn-str "\"this is a string \\\\ that has an 
escaped backslash\"")))
-;;   (should (equal "[" (clj-parse-edn-str "\"[\""))))
-
-;; (ert-deftest keywords ()
-;;   :tags '(edn keywords)
-;;   (should (equal :namespace\.of\.some\.length/keyword-name
-;;                  (clj-parse-edn-str 
":namespace.of.some.length/keyword-name")))
-;;   (should (equal :\#/\# (clj-parse-edn-str ":#/#")))
-;;   (should (equal :\#/:a (clj-parse-edn-str ":#/:a")))
-;;   (should (equal :\#foo (clj-parse-edn-str ":#foo"))))
+(ert-deftest string ()
+  :tags '(edn string)
+  (should (equal "this is a string" (clj-parse-edn-str "\"this is a 
string\"")))
+  (should (equal "this has an escaped \"quote in it"
+                 (clj-parse-edn-str "\"this has an escaped \\\"quote in 
it\"")))
+  (should (equal "foo\tbar" (clj-parse-edn-str "\"foo\\tbar\"")))
+  (should (equal "foo\nbar" (clj-parse-edn-str "\"foo\\nbar\"")))
+  (should (equal "this is a string \\ that has an escaped backslash"
+                 (clj-parse-edn-str "\"this is a string \\\\ that has an 
escaped backslash\"")))
+  (should (equal "[" (clj-parse-edn-str "\"[\""))))
+
+(ert-deftest keywords ()
+  :tags '(edn keywords)
+  (should (equal :namespace\.of\.some\.length/keyword-name
+                 (clj-parse-edn-str ":namespace.of.some.length/keyword-name")))
+  (should (equal :\#/\# (clj-parse-edn-str ":#/#")))
+  (should (equal :\#/:a (clj-parse-edn-str ":#/:a")))
+  (should (equal :\#foo (clj-parse-edn-str ":#foo"))))
 
 ;; (ert-deftest integers ()
 ;;   :tags '(edn integers)



reply via email to

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