[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/parseclj bad1fb8745 119/185: Merge pull request #12 from l
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/parseclj bad1fb8745 119/185: Merge pull request #12 from lambdaisland/nested-2-items-reduction |
Date: |
Tue, 28 Dec 2021 14:05:27 -0500 (EST) |
branch: elpa/parseclj
commit bad1fb8745bbf8d72e252006abbdb7aa4f4a7906
Merge: 2588470302 aeac6a1755
Author: Arne Brasseur <arne.brasseur@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #12 from lambdaisland/nested-2-items-reduction
Loop reduction over the first 2 elements of the stack
---
parseclj-lex.el | 4 ++--
parseclj-parser.el | 14 +++++++++-----
test/parseclj-lex-test.el | 14 ++++++--------
test/parseclj-test-data.el | 28 ++++++++++++++++++++++++++--
4 files changed, 43 insertions(+), 17 deletions(-)
diff --git a/parseclj-lex.el b/parseclj-lex.el
index d835457903..1d4f28a5b5 100644
--- a/parseclj-lex.el
+++ b/parseclj-lex.el
@@ -297,11 +297,11 @@ token is returned."
(right-char 7)
(parseclj-lex-token :character (buffer-substring-no-properties pos
(point)) pos))
- ((equal (char-after (point)) ?u)
+ ((string-match-p "^u[0-9a-fA-F]\\{4\\}" (parseclj-lex-lookahead 5))
(right-char 5)
(parseclj-lex-token :character (buffer-substring-no-properties pos
(point)) pos))
- ((equal (char-after (point)) ?o)
+ ((string-match-p "^o[0-8]\\{3\\}" (parseclj-lex-lookahead 4))
(right-char 4)
(parseclj-lex-token :character (buffer-substring-no-properties pos
(point)) pos))
diff --git a/parseclj-parser.el b/parseclj-parser.el
index 1e07d2d0a7..83303d45b5 100644
--- a/parseclj-parser.el
+++ b/parseclj-parser.el
@@ -205,13 +205,17 @@ functions. Additionally the following options are
recognized
;; 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)
+ new-stack)
+ (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-lex-test.el b/test/parseclj-lex-test.el
index 6589809c48..eae02a07af 100644
--- a/test/parseclj-lex-test.el
+++ b/test/parseclj-lex-test.el
@@ -114,15 +114,13 @@
(should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\c"
30))))
(with-temp-buffer
- (insert "\\newline\\return\\space\\tab\\a\\b\\c")
+ (insert "\\u \\v \\w")
(goto-char 1)
- (should (equal (parseclj-lex-next) (parseclj-lex-token :character
"\\newline" 1)))
- (should (equal (parseclj-lex-next) (parseclj-lex-token :character
"\\return" 9)))
- (should (equal (parseclj-lex-next) (parseclj-lex-token :character
"\\space" 16)))
- (should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\tab"
22)))
- (should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\a"
26)))
- (should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\b"
28)))
- (should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\c"
30))))
+ (should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\u"
1)))
+ (should (equal (parseclj-lex-next) (parseclj-lex-token :whitespace " " 3)))
+ (should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\v"
4)))
+ (should (equal (parseclj-lex-next) (parseclj-lex-token :whitespace " " 6)))
+ (should (equal (parseclj-lex-next) (parseclj-lex-token :character "\\w"
7))))
(with-temp-buffer
(insert "\\u0078\\o170")
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 496c965edc 074/185: Make t print as true - thanks @martinklepsch, (continued)
- [nongnu] elpa/parseclj 496c965edc 074/185: Make t print as true - thanks @martinklepsch, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 1cf0fb9d3f 065/185: More build related fixes, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 0644bcdbf4 085/185: Implement :fail-fast, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 6d40b39cec 082/185: Rename clj-edn to parseedn, keep it in this package for now., ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 185ce6367b 090/185: Add :discard support for :lexical-preservation t, and show that it's broken, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 1be462e0f2 108/185: Move parser to its own module, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj f86a3be4bf 107/185: Add last rewordings, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 388bb2bde2 115/185: Fix test case for `\u` and `\o` characters, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d3cb78544d 106/185: Use Emacs Lisp predicate style convention, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj aeac6a1755 118/185: Fix code's organization for 2-item stack reduction, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj bad1fb8745 119/185: Merge pull request #12 from lambdaisland/nested-2-items-reduction,
ELPA Syncer <=
- [nongnu] elpa/parseclj b377e12d7e 125/185: Add test case for invalid input error token, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 903d60284e 130/185: Update the Travis CI badge, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d691df5d63 131/185: Update the copyright years, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj acf4a29778 132/185: Update the README, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d42b4ad744 144/185: Require a couple of dependencies to `parseclj-ast.el`, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj c32017ecc9 143/185: Merge pull request #20 from clojure-emacs/remove-parseedn, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj ece9648128 179/185: Merge pull request #33 from clojure-emacs/arne/remove-a-from-tests, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj c7f50e3414 178/185: Update CHANGELOG, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 30c950a4ad 167/185: Use map-contains-key, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 0d157d759b 163/185: Merge branch 'master' into shebang-and-symbolic-values, ELPA Syncer, 2021/12/28