[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/parseclj 81fe979450 051/185: Handle parsing of semicolon-b
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/parseclj 81fe979450 051/185: Handle parsing of semicolon-based comments. |
Date: |
Tue, 28 Dec 2021 14:05:16 -0500 (EST) |
branch: elpa/parseclj
commit 81fe9794500ba9434c2078d8a00945bfc13b62ba
Author: Arne Brasseur <arne@arnebrasseur.net>
Commit: Arne Brasseur <arne@arnebrasseur.net>
Handle parsing of semicolon-based comments.
The lexer treats each comment line as a separate token, starting with the
first
semicolon, and up to and including the closing newline. A parser/reducer may
choose to merge consecutive comment/whitespace tokens into a single comment
AST
token.
---
clj-lex.el | 10 ++++++++++
clj-parse.el | 3 ++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/clj-lex.el b/clj-lex.el
index bc12a7b4bc..604f29d1e9 100644
--- a/clj-lex.el
+++ b/clj-lex.el
@@ -176,6 +176,13 @@ behavior."
(right-char)
(clj-lex-token :lex-error (buffer-substring-no-properties pos (point))
pos 'error-type :invalid-keyword)))))
+(defun clj-lex-comment ()
+ (let ((pos (point)))
+ (goto-char (line-end-position))
+ (when (equal (char-after (point)) ?\n)
+ (right-char))
+ (clj-lex-token :comment (buffer-substring-no-properties pos (point)) pos)))
+
(defun clj-lex-next ()
(if (clj-lex-at-eof?)
(clj-lex-token :eof nil (point))
@@ -224,6 +231,9 @@ behavior."
((equal char ?:)
(clj-lex-keyword))
+ ((equal char ?\;)
+ (clj-lex-comment))
+
((equal char ?#)
(right-char)
(let ((char (char-after (point))))
diff --git a/clj-parse.el b/clj-parse.el
index 655af83d20..a447ca8a43 100644
--- a/clj-parse.el
+++ b/clj-parse.el
@@ -34,6 +34,7 @@
(require 'clj-lex)
(defvar clj-parse--leaf-tokens '(:whitespace
+ :comment
:number
:nil
:true
@@ -197,7 +198,7 @@
; Elisp
(defun clj-parse--edn-reduce-leaf (stack token)
- (if (eq (clj-lex-token-type token) :whitespace)
+ (if (member (clj-lex-token-type token) (list :whitespace :comment))
stack
(push (clj-parse--leaf-token-value token) stack)))
- [nongnu] elpa/parseclj 452fe7cc76 023/185: Implement nil, true, false, symbol, (continued)
- [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, 2021/12/28
- [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 <=
- [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
- [nongnu] elpa/parseclj 6fe4ce6095 058/185: Add script to compare speed of edn.el and clj-parse.el, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 7d70ee4c38 059/185: Add support for tagged literals, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 4367db07aa 061/185: Move tests to tests/, bench to benchmark/, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 46570ce843 060/185: A # can be part of a symbol, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj fcd1a086f6 081/185: Rename clj-ast to parseclj-ast, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 987bd16a57 089/185: Position starts at 1, not at 0 (just like (point)), ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 313fc4e630 077/185: Rename to parseclj, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 7f8bcd405e 095/185: Make checkdoc happy with parseclj.el, ELPA Syncer, 2021/12/28