[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/parseclj 07739abe2c 030/185: support keywords
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/parseclj 07739abe2c 030/185: support keywords |
Date: |
Tue, 28 Dec 2021 14:05:11 -0500 (EST) |
branch: elpa/parseclj
commit 07739abe2cd126530d903ea4aa5dcdf5ba470277
Author: Arne Brasseur <arne@arnebrasseur.net>
Commit: Arne Brasseur <arne@arnebrasseur.net>
support keywords
---
clj-lex-test.el | 17 ++++++++++++++++-
clj-lex.el | 17 +++++++++++++++++
clj-parse-test.el | 7 ++++++-
clj-parse.el | 2 ++
4 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/clj-lex-test.el b/clj-lex-test.el
index 426698303a..baea9dcd0f 100644
--- a/clj-lex-test.el
+++ b/clj-lex-test.el
@@ -94,7 +94,22 @@
(with-temp-buffer
(insert "\"\\u0078\\o170\"")
(goto-char 1)
- (should (equal (clj-lex-next) (clj-lex-token :string "\"\\u0078\\o170\""
1)))))
+ (should (equal (clj-lex-next) (clj-lex-token :string "\"\\u0078\\o170\""
1))))
+
+ (with-temp-buffer
+ (insert ":hello-world")
+ (goto-char 1)
+ (should (equal (clj-lex-next) (clj-lex-token :keyword ":hello-world" 1))))
+
+ (with-temp-buffer
+ (insert "::hello-world")
+ (goto-char 1)
+ (should (equal (clj-lex-next) (clj-lex-token :keyword "::hello-world" 1))))
+
+ (with-temp-buffer
+ (insert ":::hello-world")
+ (goto-char 1)
+ (should (equal (clj-lex-next) (clj-lex-token :lex-error ":::" 1
'error-type :invalid-keyword)))))
(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 765cc578f9..94874aa6d0 100644
--- a/clj-lex.el
+++ b/clj-lex.el
@@ -146,6 +146,20 @@
(right-char)
(clj-lex-token :character (buffer-substring-no-properties pos (point))
pos)))))
+(defun clj-lex-keyword ()
+ (let ((pos (point)))
+ (right-char)
+ (when (equal (char-after (point)) ?:)
+ (right-char))
+ (if (clj-lex-symbol-start? (char-after (point)))
+ (progn
+ (while (clj-lex-symbol-rest? (char-after (point)))
+ (right-char))
+ (clj-lex-token :keyword (buffer-substring-no-properties pos (point))
pos))
+ (progn
+ (right-char)
+ (clj-lex-token :lex-error (buffer-substring-no-properties pos (point))
pos 'error-type :invalid-keyword)))))
+
(defun clj-lex-next ()
(if (clj-lex-at-eof?)
(clj-lex-token :eof nil (point))
@@ -175,6 +189,9 @@
((equal char ?\\)
(clj-lex-character))
+ ((equal char ?:)
+ (clj-lex-keyword))
+
":("))))
(provide 'clj-lex)
diff --git a/clj-parse-test.el b/clj-parse-test.el
index 9636e964d6..d026bbc172 100644
--- a/clj-parse-test.el
+++ b/clj-parse-test.el
@@ -74,7 +74,12 @@
(with-temp-buffer
(insert "\"\\u0078 \\o171\"")
(goto-char 1)
- (should (equal (clj-parse) '("x y")))))
+ (should (equal (clj-parse) '("x y"))))
+
+ (with-temp-buffer
+ (insert ":foo-bar")
+ (goto-char 1)
+ (should (equal (clj-parse) '(:foo-bar)))))
(provide 'clj-parse-test)
diff --git a/clj-parse.el b/clj-parse.el
index 004901090b..6cf49aac9e 100644
--- a/clj-parse.el
+++ b/clj-parse.el
@@ -35,6 +35,7 @@
:true
:false
:symbol
+ :keyword
:string
:character)
"Tokens that represent leaf nodes in the AST.")
@@ -87,6 +88,7 @@
(:true (cons t stack))
(:false (cons nil stack))
(:symbol (cons (intern (cdr (assq 'form token))) stack))
+ (:keyword (cons (intern (cdr (assq 'form token))) stack))
(:string (cons (clj-parse-string (cdr (assq 'form token))) stack))
(:character (cons (clj-parse-character (cdr (assq 'form token))) stack))))
- [nongnu] branch elpa/parseclj created (now a8c4cf30fb), ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 2d10ef3742 002/185: Travis CI / test setup, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 01608b7537 007/185: Seriously thinking of sticking to Emacs 25. This is getting ridiculous., ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj ee71cb8afe 005/185: Try again for the Travis build, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 4df6ae1bc7 012/185: Travis: only install the necessary ppa/package for each matrix line, 2nd attempt, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj e179a11ec4 016/185: More of trying to appease the mighty gods of Travis, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d5167bf4ad 021/185: Test/lint stuff, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 22f2eb106f 028/185: Support \uxxxx and \oxxx escape codes in strings, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 343052c01a 014/185: Add linting to the build, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 07739abe2c 030/185: support keywords,
ELPA Syncer <=
- [nongnu] elpa/parseclj ced0b91c08 029/185: "Support" namespaces symbols, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 1eef0b62c8 034/185: Support #_discard forms, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 0974b56833 035/185: Stick to non CL functions, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj f8822bb43c 040/185: Add support for tags in lexer, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 43f59dcb91 043/185: Avoid dropping whitespaces, handling them while reducing, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 7733985037 047/185: DESIGN.md-related adjustments, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj c906de33a1 048/185: Rewrite all tests, and add new tests for the AST "printer", ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 697618dbb1 049/185: Merge pull request #1 from volrath/master, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj e7686c49ed 052/185: Greater parity with edn.el, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 2da47798d9 057/185: Enable more edn.el tests, document how time/uuid are stored, ELPA Syncer, 2021/12/28