File tree Expand file tree Collapse file tree 3 files changed +29
-7
lines changed Expand file tree Collapse file tree 3 files changed +29
-7
lines changed Original file line number Diff line number Diff line change 23
23
" Parse all forms from the given reader."
24
24
[#?(:cljs ^not-native reader :default reader)]
25
25
(let [nodes (->> (repeatedly #(parse reader))
26
- (take-while identity)
27
- ( doall ))]
28
- ( with- meta
29
- ( nforms/forms-node nodes)
30
- ( meta (first nodes)) )))
26
+ (take-while identity))
27
+ position-meta ( merge ( meta ( first nodes))
28
+ ( select-keys ( meta ( last nodes))
29
+ [ :end-row :end-col ]))]
30
+ ( with- meta (nforms/forms-node nodes) position-meta )))
31
31
32
32
; ; ## Specialized Parsers
33
33
Original file line number Diff line number Diff line change 541
541
[2 4 ] [2 5 ] :token " x" 'x
542
542
[3 3 ] [3 14 ] :list " (println x)" '(println x)
543
543
[3 4 ] [3 11 ] :token " println" 'println
544
- [3 12 ] [3 13 ] :token " x" 'x)))
544
+ [3 12 ] [3 13 ] :token " x" 'x))
545
+ ; ; root node
546
+ (let [s (str
547
+ ; 1234567890
548
+ " (def a 1)\n "
549
+ " (def b\n "
550
+ " 2)" )
551
+ n (p/parse-string-all s)
552
+ start-pos ((juxt :row :col ) (meta n))
553
+ end-pos ((juxt :end-row :end-col ) (meta n))]
554
+ (is (= [1 1 ] start-pos))
555
+ (is (= [3 5 ] end-pos))))
545
556
546
557
547
558
(deftest t-os-specific-line-endings
Original file line number Diff line number Diff line change 58
58
[2 4 ] [2 5 ] :token " x" 'x
59
59
[3 3 ] [3 14 ] :list " (println x)" '(println x)
60
60
[3 4 ] [3 11 ] :token " println" 'println
61
- [3 12 ] [3 13 ] :token " x" 'x)))
61
+ [3 12 ] [3 13 ] :token " x" 'x))
62
+ ; ; root node
63
+ (let [s (str
64
+ ; 1234567890
65
+ " (def a 1)\n "
66
+ " (def b\n "
67
+ " 2)" )
68
+ [start-pos end-pos] (-> (z/of-string s {:track-position? true })
69
+ z/up
70
+ z/position-span)]
71
+ (is (= [1 1 ] start-pos))
72
+ (is (= [3 5 ] end-pos))))
62
73
63
74
(deftest namespaced-keywords
64
75
(is (= " :dill" (-> " :dill" z/of-string z/root-string)))
You can’t perform that action at this time.
0 commit comments