branch: elpa/parseclj
commit 43f59dcb91b6cd78bc9e753b1ad53abd0bef0fa8
Author: Daniel Barreto <[email protected]>
Commit: Daniel Barreto <[email protected]>

    Avoid dropping whitespaces, handling them while reducing
---
 clj-parse.el | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/clj-parse.el b/clj-parse.el
index 618d8f169b..bd2156f071 100644
--- a/clj-parse.el
+++ b/clj-parse.el
@@ -99,14 +99,10 @@
      ((eq first-char ?o) (string-to-number (substring c 2) 8))
      (t first-char))))
 
-(defun clj-parse--next ()
-  (setq next (clj-lex-next))
-  (while (eq (clj-lex-token-type next) :whitespace)
-    (setq next (clj-parse--next)))
-  next)
-
 (defun clj-parse--ast-reduce1 (stack leaf)
-  (push leaf stack))
+  (if (eq (clj-lex-token-type leaf) :whitespace)
+      stack
+    (push leaf stack)))
 
 (defun clj-parse--ast-reduceN (stack node subnodes)
   (push
@@ -142,7 +138,7 @@
 (defun clj-parse-reduce (reduce1 reduceN)
   (let ((stack nil))
 
-    (while (not (eq (clj-lex-token-type (setq token (clj-parse--next))) :eof))
+    (while (not (eq (clj-lex-token-type (setq token (clj-lex-next))) :eof))
       (message "STACK: %S" stack)
       (message "TOKEN: %S\n" token)
 

Reply via email to