[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/parseclj 811f35e05a 117/185: Loops reduction over the firs
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/parseclj 811f35e05a 117/185: Loops reduction over the first 2 elements of the stack |
Date: |
Tue, 28 Dec 2021 14:05:27 -0500 (EST) |
branch: elpa/parseclj
commit 811f35e05ad6f690224ddf25891e4a42a1d00a36
Author: Daniel Barreto <daniel.barreto.n@gmail.com>
Commit: Daniel Barreto <daniel.barreto.n@gmail.com>
Loops reduction over the first 2 elements of the stack
Now the parser can consume nested tags.
---
parseclj-parser.el | 20 +++++++++++++-------
test/parseclj-test-data.el | 28 ++++++++++++++++++++++++++--
2 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/parseclj-parser.el b/parseclj-parser.el
index 1e07d2d0a7..b71c5a0bff 100644
--- a/parseclj-parser.el
+++ b/parseclj-parser.el
@@ -203,15 +203,21 @@ functions. Additionally the following options are
recognized
(t (push token stack)))
;; Reduce based on top two items on the stack (special prefixed elements)
- (let* ((top-value (parseclj--take-value stack value-p))
- (opening-token (parseclj--take-token (nthcdr (length top-value)
stack) value-p '(:discard :tag)))
- (new-stack (nthcdr (+ (length top-value) (length opening-token))
stack)))
- (when (and top-value opening-token)
+ (let (top-value
+ opening-token
+ new-stack)
+ (setq top-value (parseclj--take-value stack value-p))
+ (setq opening-token (parseclj--take-token (nthcdr (length top-value)
stack) value-p '(:discard :tag)))
+ (while (and top-value opening-token)
;; (message "Reducing...")
;; (message " - STACK %S" stack)
- ;; (message " - OPENING_TOKEN %S" opening-token)
- ;; (message " - TOP_VALUE %S\n" top-value)
- (setq stack (funcall reduce-branch new-stack (car opening-token)
(append (cdr opening-token) top-value) options))))
+ ;; (message " - OPENING-TOKEN %S" opening-token)
+ ;; (message " - TOP-VALUE %S" top-value)
+ (setq new-stack (nthcdr (+ (length top-value) (length
opening-token)) stack))
+ (setq stack (funcall reduce-branch new-stack (car opening-token)
(append (cdr opening-token) top-value) options))
+
+ (setq top-value (parseclj--take-value stack value-p))
+ (setq opening-token (parseclj--take-token (nthcdr (length top-value)
stack) value-p '(:discard :tag)))))
(setq token (parseclj-lex-next)))
diff --git a/test/parseclj-test-data.el b/test/parseclj-test-data.el
index 28a03d91dc..a390e77c2f 100644
--- a/test/parseclj-test-data.el
+++ b/test/parseclj-test-data.el
@@ -275,7 +275,7 @@
(:value . 12)))))))))
- "tag"
+ "tag-1"
(a-list
:source "#foo/bar [1]"
:ast '((:node-type . :root)
@@ -290,7 +290,7 @@
(:form . "1")
(:value .
1))))))))))))
- "nested-tag"
+ "tag-2"
(a-list
:source "(fn #param :param-name 1)"
:ast '((:node-type . :root)
@@ -313,6 +313,30 @@
(:form . "1")
(:value . 1)))))))))
+ "nested-tags"
+ (a-list
+ :source "[#lazy-error #error {:cause \"Divide by zero\"}]"
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children ((:node-type . :vector)
+ (:position . 1)
+ (:children ((:node-type . :tag)
+ (:position . 2)
+ (:tag . lazy-error)
+ (:children ((:node-type . :tag)
+ (:position . 14)
+ (:tag . error)
+ (:children ((:node-type .
:map)
+ (:position . 21)
+ (:children
((:node-type . :keyword)
+
(:position . 22)
+
(:form . ":cause")
+
(:value . :cause))
+
((:node-type . :string)
+
(:position . 29)
+
(:form . "\"Divide by zero\"")
+
(:value . "Divide by zero")))))))))))))
+
"booleans"
(a-list
:source "[nil true false]"
- [nongnu] elpa/parseclj fcebf65075 180/185: Provide parseclj-alist-merge for older Emacsen, (continued)
- [nongnu] elpa/parseclj fcebf65075 180/185: Provide parseclj-alist-merge for older Emacsen, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj eff9411268 161/185: Merge pull request #26 from ikappaki/master, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 689ebddbdd 158/185: Add support for shebang and symbolic values, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 1e46607912 015/185: Split files into packages, More test setup, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj a9dba19760 086/185: Clean up node and token types, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 9480ae09b3 068/185: push is destructive, in this case cons will do, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj f395b9cbcc 097/185: Move `parseclj--leaf-token-value` to `parseedn` module, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 91dd43667c 110/185: Fix `parseclj-ast--reduce-branch` for tags., ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 9a586f267d 103/185: Remove `parseedn` requirement from `parseclj`, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj e65eb085ad 114/185: Remove duplicated test, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 811f35e05a 117/185: Loops reduction over the first 2 elements of the stack,
ELPA Syncer <=
- [nongnu] elpa/parseclj 5b4b222b4f 124/185: Return error token when there's invalid input in `parseclj-lex-next`, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj b26fadbc05 128/185: Get rid of `parseclj-lex-error-token` side-effect, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 2ffadc6239 134/185: Mark OPTIONS as unused in `parseedn-reduce-leaf`, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 45cd754c32 140/185: Remove parseedn files, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 3e48aa7b40 141/185: Remove mentions to parseedn in README.md, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj c62a11884d 165/185: First pass in inlining the necessary bits from a.el, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 8a361f4c05 175/185: Merge pull request #32 from dawranliou/dawranliou/remove-a-el-part-3, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 6f9ab8f89c 181/185: Replace `cl-case` calls with `cond`, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 1dc147f552 027/185: Support character literals, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj da1929be0b 031/185: Add vector support, ELPA Syncer, 2021/12/28