File tree Expand file tree Collapse file tree 1 file changed +12
-19
lines changed Expand file tree Collapse file tree 1 file changed +12
-19
lines changed Original file line number Diff line number Diff line change 26
26
(list
27
27
(api/token-node 'defn)
28
28
(api/token-node (symbol (str " ->" (:string-value name))))
29
- bindings
30
- ))))}))
29
+ bindings))))}))
31
30
32
31
(defn- seq-node? [node]
33
32
(or (api/vector-node? node)
36
35
(defn- nth-child [node n] (nth (:children node) n))
37
36
38
37
(defn both [call]
39
- (let [body (-> call :node :children second :children )]
38
+ (let [body (-> call :node :children second :children )
39
+ expand-nth
40
+ (fn [n item]
41
+ (if (and (seq-node? item) (= 'either (:value (nth-child item 0 ))))
42
+ (:children (nth-child item n))
43
+ [item]))]
40
44
41
45
{:node
42
46
(api/list-node
43
47
(list
44
48
(api/token-node 'do)
45
49
46
50
(api/list-node
47
- (->> body
48
- (mapcat
49
- #(if (and (seq-node? %) (= 'either (:value (nth-child % 0 ))))
50
- (:children (nth-child % 1 ))
51
- [%]))))
51
+ (->> body (mapcat (partial expand-nth 1 ))))
52
52
53
53
(api/list-node
54
- (->> body
55
- (mapcat
56
- #(if (and (seq-node? %) (= 'either (:value (nth-child % 0 ))))
57
- (:children (nth-child % 2 ))
58
- [%]))))))}))
54
+ (->> body (mapcat (partial expand-nth 2 ))))))}))
59
55
60
56
61
57
(def fallback-value
86
82
(list
87
83
(api/token-node 'let)
88
84
(api/vector-node (vector success-value fallback-value))
89
- success-clause
90
- ))
85
+ success-clause))
91
86
92
87
(api/list-node
93
88
(list
94
89
(api/token-node 'let)
95
90
(api/vector-node (vector error-value fallback-value))
96
- error-clause
97
- ))
91
+ error-clause))
98
92
99
- unrealized-clause
100
- ))}))
93
+ unrealized-clause))}))
You can’t perform that action at this time.
0 commit comments