File tree Expand file tree Collapse file tree 3 files changed +56
-16
lines changed
Expand file tree Collapse file tree 3 files changed +56
-16
lines changed Original file line number Diff line number Diff line change 4343 blocks (loop [[group & groups] groups blocks [] i 1 ]
4444 (let [blocks (conj blocks
4545 (-> group
46- yamlscript.composer/compose
46+ ( yamlscript.composer/compose ( = i 1 ))
4747 yamlscript.resolver/resolve
4848 yamlscript.builder/build
4949 yamlscript.transformer/transform
8080 (let [blocks (conj blocks
8181 (-> group
8282 (#(stage-with-options " compose"
83- yamlscript.composer/compose [%1 ]))
83+ yamlscript.composer/compose
84+ [%1 (= i 1 )]))
8485 (#(stage-with-options " resolve"
8586 yamlscript.resolver/resolve [%1 ]))
8687 (#(stage-with-options " build"
Original file line number Diff line number Diff line change 3232
3333(defn compose
3434 " Compose YAML parse events into a tree."
35- [events]
36- (let [node (if (seq events)
37- (->
38- events
39- compose-events
40- first)
41- {:! " yamlscript/v0" , := " " })]
42- (if (and
43- (= " YS" (get-in node [:% 0 :! ]))
44- (= " v0" (get-in node [:% 0 := ]))
45- (= {:= " " } (get-in node [:% 1 ])))
46- (let [node (assoc-in node [:%] (vec (drop 2 (get-in node [:%]))))]
47- (merge {:! " yamlscript/v0:" } node))
48- node)))
35+ ([events]
36+ (compose events true ))
37+ ([events first]
38+ (let [node (if (seq events)
39+ (->
40+ events
41+ compose-events
42+ clojure.core/first)
43+ {:! " yamlscript/v0" , := " " })
44+ node (if (and
45+ (= " YS" (get-in node [:% 0 :! ]))
46+ (= " v0" (get-in node [:% 0 := ]))
47+ (= {:= " " } (get-in node [:% 1 ])))
48+ (let [node (assoc-in node [:%]
49+ (vec (drop 2 (get-in node [:%]))))]
50+ (merge {:! " yamlscript/v0:" } node))
51+ node)
52+ node (if (not first)
53+ (cond
54+ (= " code" (:! node)) (assoc node :! " yamlscript/v0/code" )
55+ (= " data" (:! node)) (assoc node :! " yamlscript/v0/data" )
56+ :else node)
57+ node)]
58+ node)))
4959
5060(defn compose-mapping [events]
5161 (let [[event & events] events
Original file line number Diff line number Diff line change 15141514 clojure : |
15151515 (def name "World")
15161516 {"foo" name}
1517+
1518+
1519+ - name : Support top level !code and !data tags
1520+ yamlscript : |
1521+ !yamlscript/v0
1522+ x =: 1
1523+ --- !code
1524+ y =: 2
1525+ --- !data
1526+ z:: x + y
1527+ clojure : |
1528+ (def x 1)
1529+ (def y 2)
1530+ {"z" (add+ x y)}
1531+
1532+
1533+ - name : Support top level !code and !data tags with '!YS v0:'
1534+ yamlscript : |
1535+ !YS v0:
1536+ --- !code
1537+ x =: 1
1538+ y =: 2
1539+ --- !data
1540+ z:: x + y
1541+ clojure : |
1542+ {}
1543+ (def x 1)
1544+ (def y 2)
1545+ {"z" (add+ x y)}
You can’t perform that action at this time.
0 commit comments