branch: elpa/parseclj
commit 792ba0464745d75138b69b8a164fbc5776d0c1c6
Author: Arne Brasseur <[email protected]>
Commit: Arne Brasseur <[email protected]>
A more elaborate test, nesting works!
---
clj-parse-test.el | 7 ++++++-
clj-parse.el | 20 +++++++++++---------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/clj-parse-test.el b/clj-parse-test.el
index a6ef69b1e4..8de09a3e8c 100644
--- a/clj-parse-test.el
+++ b/clj-parse-test.el
@@ -44,7 +44,12 @@
(with-temp-buffer
(insert "(nil true false hello-world)")
(goto-char 1)
- (should (equal (clj-parse) '((nil t nil hello-world))))))
+ (should (equal (clj-parse) '((nil t nil hello-world)))))
+
+ (with-temp-buffer
+ (insert "((.9 abc (true) (hello)))")
+ (goto-char 1)
+ (should (equal (clj-parse) '(((0.9 abc (t) (hello))))))))
;; (ert-deftest clj-parse-test--reduce-list ()
;; (clj-parse-test--reduce-list ))
diff --git a/clj-parse.el b/clj-parse.el
index 17ec7cdf58..cc40237278 100644
--- a/clj-parse.el
+++ b/clj-parse.el
@@ -25,12 +25,18 @@
;;; Code:
(require 'cl-lib)
-
;; Before emacs 25.1 it's an ELPA package
(require 'let-alist)
-
(require 'clj-lex)
+(defvar clj-parse--leaf-tokens '(:whitespace
+ :number
+ :nil
+ :true
+ :false
+ :symbol)
+ "Tokens that represent leaf nodes in the AST.")
+
(defun clj-parse-edn-reduce1 (stack token)
(cl-case (cdr (assq 'type token))
(:whitespace stack)
@@ -48,14 +54,10 @@
(:list (-butlast (cdr coll))))
stack))
-(defvar clj-parse--leaf-tokens '(:whitespace :number :nil :true :false
:symbol))
-
-
+;; TODO move this to clj-lex
(defun clj-parse--token-type (token)
- (and (listp token) (cdr (assq 'type token))))
-
-(defun clj-parse--unwind-stack (stack target)
- (let ((result nil))))
+ (and (listp token)
+ (cdr (assq 'type token))))
(defun clj-parse--reduce-list (stack reducN)
(let ((coll nil))