[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/parseclj 91dd43667c 110/185: Fix `parseclj-ast--reduce-bra
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/parseclj 91dd43667c 110/185: Fix `parseclj-ast--reduce-branch` for tags. |
Date: |
Tue, 28 Dec 2021 14:05:26 -0500 (EST) |
branch: elpa/parseclj
commit 91dd43667c889194fe67eed3b4d9ad93025c6690
Author: Daniel Barreto <daniel.barreto.n@gmail.com>
Commit: Daniel Barreto <daniel.barreto.n@gmail.com>
Fix `parseclj-ast--reduce-branch` for tags.
Reduction was returning only the reduced tag without the rest of the stack,
so
all previous elements were lost.
---
parseclj-ast.el | 5 +-
test/parseclj-test-data.el | 517 +++++++++++++++++++++++----------------------
2 files changed, 273 insertions(+), 249 deletions(-)
diff --git a/parseclj-ast.el b/parseclj-ast.el
index 9d16549806..f812191bf9 100644
--- a/parseclj-ast.el
+++ b/parseclj-ast.el
@@ -111,10 +111,11 @@ on available options."
(cl-case type
(:root (cons (parseclj-ast-node :root pos :children children) stack))
(:discard stack)
- (:tag (list (parseclj-ast-node :tag
+ (:tag (cons (parseclj-ast-node :tag
pos
:tag (intern (substring (a-get
opening-token :form) 1))
- :children children)))
+ :children children)
+ stack))
(t (cons
(parseclj-ast-node type pos :children children)
stack)))))
diff --git a/test/parseclj-test-data.el b/test/parseclj-test-data.el
index 8ec8a000b6..28a03d91dc 100644
--- a/test/parseclj-test-data.el
+++ b/test/parseclj-test-data.el
@@ -28,271 +28,294 @@
;;; Code:
(setq parseclj-test-data
- (a-list
+ (a-list
- "simple-list"
- (a-list
- :tags '(:edn-roundtrip)
- :source "(1 2 3)"
- :edn '((1 2 3))
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :list)
- (:position . 1)
- (:children . (((:node-type . :number)
- (:position . 2)
- (:form . "1")
- (:value . 1))
- ((:node-type . :number)
- (:position . 4)
- (:form . "2")
- (:value . 2))
- ((:node-type . :number)
- (:position . 6)
- (:form . "3")
- (:value . 3)))))))))
+ "simple-list"
+ (a-list
+ :tags '(:edn-roundtrip)
+ :source "(1 2 3)"
+ :edn '((1 2 3))
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :list)
+ (:position . 1)
+ (:children . (((:node-type . :number)
+ (:position . 2)
+ (:form . "1")
+ (:value . 1))
+ ((:node-type . :number)
+ (:position . 4)
+ (:form . "2")
+ (:value . 2))
+ ((:node-type . :number)
+ (:position . 6)
+ (:form . "3")
+ (:value . 3)))))))))
- "empty-list"
- (a-list
- :source "()"
- :edn '(())
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :list)
- (:position . 1)
- (:children . nil))))))
+ "empty-list"
+ (a-list
+ :source "()"
+ :edn '(())
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :list)
+ (:position . 1)
+ (:children . nil))))))
- "size-1"
- (a-list
- :tags '(:edn-roundtrip)
- :source "(1)"
- :edn '((1))
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :list)
- (:position . 1)
- (:children . (((:node-type . :number)
- (:position . 2)
- (:form . "1")
- (:value . 1)))))))))
+ "size-1"
+ (a-list
+ :tags '(:edn-roundtrip)
+ :source "(1)"
+ :edn '((1))
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :list)
+ (:position . 1)
+ (:children . (((:node-type . :number)
+ (:position . 2)
+ (:form . "1")
+ (:value . 1)))))))))
- "leafs"
- (a-list
- :source "(nil true false hello-world)"
- :edn '((nil t nil hello-world))
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :list)
- (:position . 1)
- (:children . (((:node-type . :nil)
- (:position . 2)
- (:form . "nil")
- (:value . nil))
- ((:node-type . :true)
- (:position . 6)
- (:form . "true")
- (:value . t))
- ((:node-type . :false)
- (:position . 11)
- (:form . "false")
- (:value . nil))
- ((:node-type . :symbol)
- (:position . 17)
- (:form . "hello-world")
- (:value . hello-world)))))))))
+ "leafs"
+ (a-list
+ :source "(nil true false hello-world)"
+ :edn '((nil t nil hello-world))
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :list)
+ (:position . 1)
+ (:children . (((:node-type . :nil)
+ (:position . 2)
+ (:form . "nil")
+ (:value . nil))
+ ((:node-type . :true)
+ (:position . 6)
+ (:form . "true")
+ (:value . t))
+ ((:node-type . :false)
+ (:position . 11)
+ (:form . "false")
+ (:value . nil))
+ ((:node-type . :symbol)
+ (:position . 17)
+ (:form . "hello-world")
+ (:value . hello-world)))))))))
- "qualified-symbol"
- (a-list
- :tags '(:edn-roundtrip)
- :source "clojure.string/join"
- :edn '(clojure.string/join)
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :symbol)
- (:position . 1)
- (:form . "clojure.string/join")
- (:value . clojure.string/join))))))
+ "qualified-symbol"
+ (a-list
+ :tags '(:edn-roundtrip)
+ :source "clojure.string/join"
+ :edn '(clojure.string/join)
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :symbol)
+ (:position . 1)
+ (:form . "clojure.string/join")
+ (:value . clojure.string/join))))))
- "nested-lists"
- (a-list
- :source "((.9 abc (true) (hello)))"
- :edn '(((0.9 abc (t) (hello))))
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :list)
- (:position . 1)
- (:children . (((:node-type . :list)
- (:position . 2)
- (:children ((:node-type . :number)
- (:position . 3)
- (:form . ".9")
- (:value . 0.9))
- ((:node-type . :symbol)
- (:position . 6)
- (:form . "abc")
- (:value . abc))
- ((:node-type . :list)
- (:position . 10)
- (:children ((:node-type .
:true)
- (:position .
11)
- (:form .
"true")
- (:value .
t))))
- ((:node-type . :list)
- (:position . 17)
- (:children ((:node-type .
:symbol)
- (:position .
18)
- (:form .
"hello")
- (:value .
hello)))))))))))))
+ "nested-lists"
+ (a-list
+ :source "((.9 abc (true) (hello)))"
+ :edn '(((0.9 abc (t) (hello))))
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :list)
+ (:position . 1)
+ (:children . (((:node-type . :list)
+ (:position . 2)
+ (:children ((:node-type . :number)
+ (:position . 3)
+ (:form . ".9")
+ (:value . 0.9))
+ ((:node-type . :symbol)
+ (:position . 6)
+ (:form . "abc")
+ (:value . abc))
+ ((:node-type . :list)
+ (:position . 10)
+ (:children
((:node-type . :true)
+
(:position . 11)
+ (:form .
"true")
+ (:value .
t))))
+ ((:node-type . :list)
+ (:position . 17)
+ (:children
((:node-type . :symbol)
+
(:position . 18)
+ (:form .
"hello")
+ (:value .
hello)))))))))))))
- "strings-1"
- (a-list
- :tags '(:edn-roundtrip)
- :source "\"abc hello \\t\\\"x\""
- :edn '("abc hello \t\"x")
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :string)
- (:position . 1)
- (:form . "\"abc hello \\t\\\"x\"")
- (:value . "abc hello \t\"x"))))))
+ "strings-1"
+ (a-list
+ :tags '(:edn-roundtrip)
+ :source "\"abc hello \\t\\\"x\""
+ :edn '("abc hello \t\"x")
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :string)
+ (:position . 1)
+ (:form . "\"abc hello \\t\\\"x\"")
+ (:value . "abc hello \t\"x"))))))
- "strings-2"
- (a-list
- :source "(\"---\\f---\\\"-'\\'-\\\\-\\r\\n\")"
- :edn '(("---\f---\"-''-\\-\r\n"))
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :list)
- (:position . 1)
- (:children . (((:node-type . :string)
- (:position . 2)
- (:form .
"\"---\\f---\\\"-'\\'-\\\\-\\r\\n\"")
- (:value .
"---\f---\"-''-\\-\r\n")))))))))
+ "strings-2"
+ (a-list
+ :source "(\"---\\f---\\\"-'\\'-\\\\-\\r\\n\")"
+ :edn '(("---\f---\"-''-\\-\r\n"))
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :list)
+ (:position . 1)
+ (:children . (((:node-type . :string)
+ (:position . 2)
+ (:form .
"\"---\\f---\\\"-'\\'-\\\\-\\r\\n\"")
+ (:value .
"---\f---\"-''-\\-\r\n")))))))))
- "chars-1"
- (a-list
- :source "(\\newline \\return \\space \\tab \\a \\b \\c \\u0078 \\o171)"
- :edn '((?\n ?\r ?\ ?\t ?a ?b ?c ?x ?y))
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :list)
- (:position . 1)
- (:children . (((:node-type . :character) (:position
. 2) (:form . "\\newline") (:value . ?\n))
- ((:node-type . :character) (:position
. 11) (:form . "\\return") (:value . ?\r))
- ((:node-type . :character) (:position
. 19) (:form . "\\space") (:value . 32))
- ((:node-type . :character) (:position
. 26) (:form . "\\tab") (:value . ?\t))
- ((:node-type . :character) (:position
. 31) (:form . "\\a") (:value . ?a))
- ((:node-type . :character) (:position
. 34) (:form . "\\b") (:value . ?b))
- ((:node-type . :character) (:position
. 37) (:form . "\\c") (:value . ?c))
- ((:node-type . :character) (:position
. 40) (:form . "\\u0078") (:value . ?x))
- ((:node-type . :character) (:position
. 47) (:form . "\\o171") (:value . ?y)))))))))
+ "chars-1"
+ (a-list
+ :source "(\\newline \\return \\space \\tab \\a \\b \\c \\u0078 \\o171)"
+ :edn '((?\n ?\r ?\ ?\t ?a ?b ?c ?x ?y))
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :list)
+ (:position . 1)
+ (:children . (((:node-type . :character)
(:position . 2) (:form . "\\newline") (:value . ?\n))
+ ((:node-type . :character)
(:position . 11) (:form . "\\return") (:value . ?\r))
+ ((:node-type . :character)
(:position . 19) (:form . "\\space") (:value . 32))
+ ((:node-type . :character)
(:position . 26) (:form . "\\tab") (:value . ?\t))
+ ((:node-type . :character)
(:position . 31) (:form . "\\a") (:value . ?a))
+ ((:node-type . :character)
(:position . 34) (:form . "\\b") (:value . ?b))
+ ((:node-type . :character)
(:position . 37) (:form . "\\c") (:value . ?c))
+ ((:node-type . :character)
(:position . 40) (:form . "\\u0078") (:value . ?x))
+ ((:node-type . :character)
(:position . 47) (:form . "\\o171") (:value . ?y)))))))))
- "chars-2"
- (a-list
- :source "\"\\u0078 \\o171\""
- :edn '("x y")
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :string)
- (:position . 1)
- (:form . "\"\\u0078 \\o171\"")
- (:value . "x y"))))))
+ "chars-2"
+ (a-list
+ :source "\"\\u0078 \\o171\""
+ :edn '("x y")
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :string)
+ (:position . 1)
+ (:form . "\"\\u0078 \\o171\"")
+ (:value . "x y"))))))
- "keywords"
- (a-list
- :tags '(:edn-roundtrip)
- :source ":foo-bar"
- :edn '(:foo-bar)
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :keyword)
- (:position . 1)
- (:form . ":foo-bar")
- (:value . :foo-bar))))))
+ "keywords"
+ (a-list
+ :tags '(:edn-roundtrip)
+ :source ":foo-bar"
+ :edn '(:foo-bar)
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :keyword)
+ (:position . 1)
+ (:form . ":foo-bar")
+ (:value . :foo-bar))))))
- "vector"
- (a-list
- :tags '(:edn-roundtrip)
- :source "[123]"
- :edn '([123])
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :vector)
- (:position . 1)
- (:children . (((:node-type . :number)
- (:position . 2)
- (:form . "123")
- (:value . 123)))))))))
+ "vector"
+ (a-list
+ :tags '(:edn-roundtrip)
+ :source "[123]"
+ :edn '([123])
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :vector)
+ (:position . 1)
+ (:children . (((:node-type . :number)
+ (:position . 2)
+ (:form . "123")
+ (:value . 123)))))))))
- "map"
- (a-list
- :tags '(:edn-roundtrip)
- :source "{:count 123}"
- :edn (list (a-hash-table :count 123))
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :map)
- (:position . 1)
- (:children . (((:node-type . :keyword)
- (:position . 2)
- (:form . ":count")
- (:value . :count))
- ((:node-type . :number)
- (:position . 9)
- (:form . "123")
- (:value . 123)))))))))
+ "map"
+ (a-list
+ :tags '(:edn-roundtrip)
+ :source "{:count 123}"
+ :edn (list (a-hash-table :count 123))
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :map)
+ (:position . 1)
+ (:children . (((:node-type . :keyword)
+ (:position . 2)
+ (:form . ":count")
+ (:value . :count))
+ ((:node-type . :number)
+ (:position . 9)
+ (:form . "123")
+ (:value . 123)))))))))
- "set"
- (a-list
- :tags '(:edn-roundtrip)
- :source "#{:x}"
- :edn '((edn-set (:x)))
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :set)
- (:position . 1)
- (:children . (((:node-type . :keyword)
- (:position . 3)
- (:form . ":x")
- (:value . :x)))))))))
+ "set"
+ (a-list
+ :tags '(:edn-roundtrip)
+ :source "#{:x}"
+ :edn '((edn-set (:x)))
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :set)
+ (:position . 1)
+ (:children . (((:node-type . :keyword)
+ (:position . 3)
+ (:form . ":x")
+ (:value . :x)))))))))
- "discard"
- (a-list
- :source "(10 #_11 12 #_#_ 13 14)"
- :edn '((10 12))
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :list)
- (:position . 1)
- (:children . (((:node-type . :number)
- (:position . 2)
- (:form . "10")
- (:value . 10))
- ((:node-type . :number)
- (:position . 10)
- (:form . "12")
- (:value . 12)))))))))
+ "discard"
+ (a-list
+ :source "(10 #_11 12 #_#_ 13 14)"
+ :edn '((10 12))
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :list)
+ (:position . 1)
+ (:children . (((:node-type . :number)
+ (:position . 2)
+ (:form . "10")
+ (:value . 10))
+ ((:node-type . :number)
+ (:position . 10)
+ (:form . "12")
+ (:value . 12)))))))))
- "tag"
- (a-list
- :source "#foo/bar [1]"
- :ast '((:node-type . :root)
- (:position . 1)
- (:children . (((:node-type . :tag)
- (:position . 1)
- (:tag . foo/bar)
- (:children . (((:node-type . :vector)
- (:position . 10)
- (:children . (((:node-type . :number)
- (:position . 11)
- (:form . "1")
- (:value . 1))))))))))))
+ "tag"
+ (a-list
+ :source "#foo/bar [1]"
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :tag)
+ (:position . 1)
+ (:tag . foo/bar)
+ (:children . (((:node-type . :vector)
+ (:position . 10)
+ (:children . (((:node-type .
:number)
+ (:position . 11)
+ (:form . "1")
+ (:value .
1))))))))))))
- "booleans"
- (a-list
- :source "[nil true false]"
- :edn '([nil t nil]))))
+ "nested-tag"
+ (a-list
+ :source "(fn #param :param-name 1)"
+ :ast '((:node-type . :root)
+ (:position . 1)
+ (:children . (((:node-type . :list)
+ (:position . 1)
+ (:children . (((:node-type . :symbol)
+ (:position . 2)
+ (:form . "fn")
+ (:value . fn))
+ ((:node-type . :tag)
+ (:position . 5)
+ (:tag . param)
+ (:children . (((:node-type .
:keyword)
+ (:position . 12)
+ (:form .
":param-name")
+ (:value .
:param-name)))))
+ ((:node-type . :number)
+ (:position . 24)
+ (:form . "1")
+ (:value . 1)))))))))
+
+ "booleans"
+ (a-list
+ :source "[nil true false]"
+ :edn '([nil t nil]))))
;;; parseclj-test-data.el ends here
- [nongnu] elpa/parseclj 48abe456c6 155/185: Update the installation instructions, (continued)
- [nongnu] elpa/parseclj 48abe456c6 155/185: Update the installation instructions, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj b234692020 157/185: error on unmatched closing paren/brace, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 1bb3800f8f 162/185: Update CHANGELOG, ELPA Syncer, 2021/12/28
- [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 <=
- [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, 2021/12/28
- [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