branch: elpa/parseclj
commit 987bd16a575c59bf7ed2b3e7476267781fab18ff
Author: Arne Brasseur <[email protected]>
Commit: Arne Brasseur <[email protected]>
Position starts at 1, not at 0 (just like (point))
---
parseclj-ast.el | 2 +-
test/parseclj-test-data.el | 32 ++++++++++++++++----------------
test/parseclj-test.el | 8 ++++----
test/parseclj-unparse-test.el | 18 +++++++++---------
4 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/parseclj-ast.el b/parseclj-ast.el
index 43a82bd6e9..88d6654820 100644
--- a/parseclj-ast.el
+++ b/parseclj-ast.el
@@ -84,7 +84,7 @@ Other ATTRIBUTES can be given as a flat list of key-value
pairs. "
(:lbrace :map)
(t type))))
(cl-case type
- (:root (cons (parseclj-ast-node :root 0 :children children) stack))
+ (:root (cons (parseclj-ast-node :root pos :children children) stack))
(:discard stack)
(:tag (list (parseclj-ast-node :tag
pos
diff --git a/test/parseclj-test-data.el b/test/parseclj-test-data.el
index a584b350d4..8ec8a000b6 100644
--- a/test/parseclj-test-data.el
+++ b/test/parseclj-test-data.el
@@ -36,7 +36,7 @@
:source "(1 2 3)"
:edn '((1 2 3))
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :list)
(:position . 1)
(:children . (((:node-type . :number)
@@ -58,7 +58,7 @@
:source "()"
:edn '(())
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :list)
(:position . 1)
(:children . nil))))))
@@ -69,7 +69,7 @@
:source "(1)"
:edn '((1))
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :list)
(:position . 1)
(:children . (((:node-type . :number)
@@ -82,7 +82,7 @@
:source "(nil true false hello-world)"
:edn '((nil t nil hello-world))
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :list)
(:position . 1)
(:children . (((:node-type . :nil)
@@ -108,7 +108,7 @@
:source "clojure.string/join"
:edn '(clojure.string/join)
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :symbol)
(:position . 1)
(:form . "clojure.string/join")
@@ -119,7 +119,7 @@
:source "((.9 abc (true) (hello)))"
:edn '(((0.9 abc (t) (hello))))
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :list)
(:position . 1)
(:children . (((:node-type . :list)
@@ -151,7 +151,7 @@
:source "\"abc hello \\t\\\"x\""
:edn '("abc hello \t\"x")
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :string)
(:position . 1)
(:form . "\"abc hello \\t\\\"x\"")
@@ -162,7 +162,7 @@
:source "(\"---\\f---\\\"-'\\'-\\\\-\\r\\n\")"
:edn '(("---\f---\"-''-\\-\r\n"))
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :list)
(:position . 1)
(:children . (((:node-type . :string)
@@ -175,7 +175,7 @@
:source "(\\newline \\return \\space \\tab \\a \\b \\c \\u0078 \\o171)"
:edn '((?\n ?\r ?\ ?\t ?a ?b ?c ?x ?y))
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :list)
(:position . 1)
(:children . (((:node-type . :character) (:position
. 2) (:form . "\\newline") (:value . ?\n))
@@ -193,7 +193,7 @@
:source "\"\\u0078 \\o171\""
:edn '("x y")
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :string)
(:position . 1)
(:form . "\"\\u0078 \\o171\"")
@@ -205,7 +205,7 @@
:source ":foo-bar"
:edn '(:foo-bar)
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :keyword)
(:position . 1)
(:form . ":foo-bar")
@@ -217,7 +217,7 @@
:source "[123]"
:edn '([123])
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :vector)
(:position . 1)
(:children . (((:node-type . :number)
@@ -231,7 +231,7 @@
:source "{:count 123}"
:edn (list (a-hash-table :count 123))
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :map)
(:position . 1)
(:children . (((:node-type . :keyword)
@@ -249,7 +249,7 @@
:source "#{:x}"
:edn '((edn-set (:x)))
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :set)
(:position . 1)
(:children . (((:node-type . :keyword)
@@ -262,7 +262,7 @@
:source "(10 #_11 12 #_#_ 13 14)"
:edn '((10 12))
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :list)
(:position . 1)
(:children . (((:node-type . :number)
@@ -279,7 +279,7 @@
(a-list
:source "#foo/bar [1]"
:ast '((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :tag)
(:position . 1)
(:tag . foo/bar)
diff --git a/test/parseclj-test.el b/test/parseclj-test.el
index 35f563c8ff..ee9eb51b66 100644
--- a/test/parseclj-test.el
+++ b/test/parseclj-test.el
@@ -34,7 +34,7 @@
(should (equal
(parseclj-parse-clojure ";; foo\nbar")
'((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children ((:node-type . :symbol)
(:position . 8)
(:form . "bar")
@@ -43,7 +43,7 @@
(parseclj-parse-clojure ";; foo\nbar" :lexical-preservation t)
'((:node-type . :root)
(:lexical-preservation . t)
- (:position . 0)
+ (:position . 1)
(:children ((:node-type . :comment)
(:position . 1)
(:form . ";; foo\n"))
@@ -55,7 +55,7 @@
(parseclj-parse-clojure ";; foo\n;;baz\nbar" :lexical-preservation
t)
'((:node-type . :root)
(:lexical-preservation . t)
- (:position . 0)
+ (:position . 1)
(:children ((:node-type . :comment)
(:position . 1)
(:form . ";; foo\n;;baz\n"))
@@ -122,7 +122,7 @@
(should (equal (parseclj-parse-clojure "(1 [2 {3 ( 4}])" :fail-fast nil)
'((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children ((:node-type . :list)
(:position . 1)
(:children ((:node-type . :number)
diff --git a/test/parseclj-unparse-test.el b/test/parseclj-unparse-test.el
index 37be1631dd..3572567e8f 100644
--- a/test/parseclj-unparse-test.el
+++ b/test/parseclj-unparse-test.el
@@ -37,7 +37,7 @@
(should (equal "(0 1 2)"
(parseclj-unparse-clojure-to-string
'((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :list)
(:position . 1)
(:children . (((:node-type . :number)
@@ -57,7 +57,7 @@
(should (equal "()"
(parseclj-unparse-clojure-to-string
'((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :list)
(:position . 1)
(:children . nil)))))))))
@@ -66,7 +66,7 @@
(should (equal "((.9 abc (true) (hello)))"
(parseclj-unparse-clojure-to-string
'((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :list)
(:position . 1)
(:children . (((:node-type . :list)
@@ -96,7 +96,7 @@
(should (equal "\"abc hello \\t\\\"x\""
(parseclj-unparse-clojure-to-string
'((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :string)
(:position . 1)
(:form . "\"abc hello \\t\\\"x\"")
@@ -106,7 +106,7 @@
(should (equal "(\\newline \\return \\space \\tab \\a \\b \\c \\u0078
\\o171)"
(parseclj-unparse-clojure-to-string
'((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :list)
(:position . 1)
(:children . (((:node-type . :character)
(:position . 2) (:form . "\\newline") (:value . ?\n))
@@ -124,7 +124,7 @@
(should (equal ":foo-bar"
(parseclj-unparse-clojure-to-string
'((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :keyword)
(:position . 1)
(:form . ":foo-bar")
@@ -134,7 +134,7 @@
(should (equal "[123]"
(parseclj-unparse-clojure-to-string
'((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :vector)
(:position . 1)
(:children . (((:node-type . :number)
@@ -146,7 +146,7 @@
(should (equal "{:count 123}"
(parseclj-unparse-clojure-to-string
'((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :map)
(:position . 1)
(:children . (((:node-type . :keyword)
@@ -162,7 +162,7 @@
(should (equal "#{:x}"
(parseclj-unparse-clojure-to-string
'((:node-type . :root)
- (:position . 0)
+ (:position . 1)
(:children . (((:node-type . :set)
(:position . 1)
(:children . (((:node-type . :keyword)